1

I have a JavaEE application that communicates with other services via RESTful API. The hostname:port of remote services is set through environment entries (<env-entry/> in web.xml, not to confuse with environment variables!). This value is later obtained through field annotated with @Resource.

As the build process is isolated from deployment, I want to override the defaults in web.xml (where the variable is set to localhost) that ends up in app.war to actual hostname. I suppose this is done by providing another web.xml or jboss-web.xml (on WildFly) along with , but I can't find how this is set up; I guess this must be a simple process, not involving repackaging the app.war.

Radim Vansa
  • 5,686
  • 2
  • 25
  • 40
  • is this what you are looking for?: http://stackoverflow.com/questions/3298763/maven-customize-web-xml-of-web-app-project – Tea Curran Apr 08 '16 at 19:09
  • No, that tells you how to switch the contents of `app.war` through profile. I want single `app.war`, and configure the environment entry only during deployment (when the sources, and Maven are not available). – Radim Vansa Apr 08 '16 at 20:42
  • Actually I have never used this kind of config (prefering properties files), but it seems that this mechanism is using JNDI. Therefore, maybe this link maybe helpful: https://docs.jboss.org/author/display/WFLY8/JNDI+Reference – user140547 Apr 09 '16 at 20:16
  • I read that document before, but I don't see how the local JNDI properties could be set (obviously, it's not in standalone.xml as this allows to set only global properties). – Radim Vansa Apr 12 '16 at 14:32

1 Answers1

1

You can use descriptor replacement property. Maybe these links can help you:

Java EE Application Deployment and Configuration

Property substitution of deployment descriptor

S.Stavreva
  • 577
  • 4
  • 8
  • According to the second document, those properties allow to override only jboss-web.xml - is overriding web.xml allowed by default? – Radim Vansa Apr 12 '16 at 14:30
  • You can use jboss-web.xml, it can replace web.xml. So you should be able to achieve properties override. https://docs.jboss.org/author/display/WFLY8/Deployment+Descriptors+used+In+WildFly – S.Stavreva Apr 12 '16 at 16:55
  • That's not very handy, since the WAR shouldn't be tied to WildFly (adding jboss-web.xml kind of suggests that). – Radim Vansa Apr 15 '16 at 09:11