Using properties / variables in jboss-web.xml

I have a WAR that is configured to use a cloud class loader under JBoss. All this works great and dandy. The configuration for it in jboss-web.xml looks something like this:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 4.2//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd"> <jboss-web> <class-loading> <loader-repository> com.mycompany:loader='com.mycompany.repository' <loader-repository-config>java2ParentDelegation=false</loader-repository-config> </loader-repository> </class-loading> </jboss-web> 

Now the client wants to deploy two copies of our WAR file under the same JBoss instance. They are configured to use the same classloader repository, which causes problems.

If I manually modify jboss-web.xml inside one copy of the WAR file to indicate a different repository, for example, changing the corresponding line to:

  com.mycompany:loader='com.mycompany.repository2' 

... both copies of the WAR deployment no problem.

However, hacking internal WAR files is not a fantastic solution for the client.

If I could include, say, the context root in the repository name (or some other property that is guaranteed to be different between the two deployments), this can be done automatically.

Is it possible to use properties in jboss-web.xml ?, allowing me to do something like:

  com.mycompany:loader='com.mycompany.repository-${jboss.context-root}' 

(Note: I created this property name.)

Step back a bit, is there a better way to accomplish what I'm trying to accomplish?

+7
source share
2 answers

The usual J2EE way to achieve what you want is to separate the code from the deployment. This means that placing jboss-web.xml in a WAR is an error here. This deployment configuration file must be used during deployment. I really don't know the jboss deployment process, but for Oracle IAS it looks like this:

  • WAR / EAR contains only code-specific settings and declarations of env records, data sources used, security roles, etc. (in web.xml ), but not the values ​​for the entries
  • During deployment, the deployment descriptor ( orion-web.xml for Oracle, jboss-web.xml for jBoss) containing the associated run-time values ​​for roles, data sources, env records, etc. is passed to the container. (this is done in a specific container. Oracle accepts the deployment plan file specified using cmdline arg or via download in the form of a browser, that is, you download the EAR and the deployment plan, the deployment plan contains all the deployment descriptors of a specific provider)

JSR 88 defines the concept of a deployment plan and also defines a deployment plan . So this should be your starting point for viewing int jboss documentation.

As already mentioned, this is the standard J2EE method for separating mappings of deployment time values ​​from your WAR / EAR code. In your particular case, you will receive one EAR and two different deployment plans.

+1
source

You can deploy your war file as an exploded .WAR directory, and not as a single .WAR file. This will allow you to easily edit jboss-web.xml in each instance. Any code / resources specified in the web application must be compiled in JARS and added to the application class path. This will reduce the size of your WARS and stop editing them by mistake.

0
source

All Articles