tags:

views:

479

answers:

1

Is it possible to override the settings in war file's WEB-INF/jboss-web.xml? I have a war file from a vendor, and I'd like to change the datasource which it uses without modifying the war file itself.

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
  ....
  <resource-ref>
    <res-ref-name>jdbc/primaryDatasource</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
   <jndi-name>java:/primaryDS</jndi-name>
 </resource-ref>

I want to have two copies of the same war file running in the same container, but each pointing to a different database. I could modify the war file itself, but I'd have to remodify it each time the vendor ships an update.

I'd like the first war file to continue to use primaryDS, but have the second instance use secondaryDS. The container I'm using is jboss-4.2.3.GA.

+1  A: 

Do you mean you want to change how 'primaryDS' is configured? That is nothing to do with web.xml or JBoss's web.xml defaults then. This is configured in JBoss-specific container configuration. I forget where this file is but it's the one that contains elements.

Do you mean you want the .war to refer to something besides 'primaryDS'? The J2EE model says that is really your job as deployer, to connect the vendor/app's virtual name of 'jdbc/primaryDatasource' to an actual datasource in the container.

But... could you not also simply rename, or copy, your desired configuration to one called 'primaryDS' in your container?

If you have one .war file, two copies, and want to configure them differently, no I am afraid there does not seem to be a way around modifying web.xml. 'primaryDS' can't resolve to two different things.

Sean Owen