How to create global context variables in JBoss?

This is a continuation of the question that I posted some time ago: " Can I use one WAR in several environments? ". I was able to create an instant solution in Tomcat, but now we are porting our application to JBoss 4.2, and I cannot figure out how to set up global environment variables.

In Tomcat 6, this was pretty simple: I just put the following snippet in tomcat/conf/Catalina/myappname.xml:

<Context ...>
   <Environment name="TARGET_ENV" value="DEV" type="java.lang.String" override="false"/>
</Context>

Then in my application, I was able to resolve the environment name with the following:

Context context = (Context) InitialContext().lookup("java:comp/env");
String targetEnvironment = (String) context.lookup("TARGET_ENV");

The problem is that I cannot find out where / how to place global variables in JBoss. I tried putting the tag <Environment>in the following files to no avail:

  • server/all/deploy/jboss-web.deployer/context.xml
  • server/default/deploy/jboss-web.deployer/context.xml

, web.xml, - .war dev, qa prod.

JBoss, , - , , .

+3
1

PropertiesService URL- .

, , .

+1

Source: https://habr.com/ru/post/1749266/


All Articles