Question

I added a system property in my run.conf of my JBOSS like this:

JAVA_OPTS="$JAVA_OPTS -Dfoo=bar"

Now my question is, if there is a way to resolve this property in a web.xml file in a way something like this:

...
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>
    classpath:applicationContext-common.xml
    classpath:conf/${foo}/applicationContext-local.xml
  </param-value>
</context-param>
...
Was it helpful?

Solution

I don't know any possibility. But in my opinion this should be implemented in the application. Why you wanna increase the indirection? Normaly you access the contents of the web.xml from within you application ( app > web.xml). Why do this: app > web.xml > environment variable?

OTHER TIPS

You have to set spec-descriptor-property-replacement in standalone.xml to true

    <subsystem xmlns="urn:jboss:domain:ee:1.2">
        <spec-descriptor-property-replacement>true</spec-descriptor-property-replacement>
        <jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
    </subsystem>

Since JBoss internally uses the tomcat web-container, it should work like your example (${foo}/applicationContext-local.xml). I haven't tried the JBoss case, but we use this technique all the time in Tomcat.

web.xml should apply to a single web application only. It should not have global configuration. So no. In any case, by the time the server and your webapp has loaded, it's way to late to start playing command line arguments.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top