views:

708

answers:

2

Currently my setup is:

in my ear META-INF/jboss-app.xml

<jboss-app>
  <service>datasource-ds.xml</service>
</module>

and datasource-ds.xml

<datasources>
  <local-tx-datasource>
    <jndi-name>jdbc/mydeployment</jndi-name>
    <connection-url>jdbc:oracle:thin:@eir:myport:mydbname</connection-url>
        <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <user-name>myuser</user-name>
    <password>mypassword</password>
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
       <metadata>
         <type-mapping>Oracle9i</type-mapping>
      </metadata>
  </local-tx-datasource>
</datasources>

and it works when ojdbc5.jar is in my servername/lib.

How can I config my oracle driver information in my .ear file so that I can have two different ear deployments, one using Oracle 10g and one using oracle 11g?

EDIT: I phrased the question wrong. I meant how can I deploy an ear using the ojbc*.jar in the ear file, not in the server/lib directory. In my setup there are multiply different apps deployed and I want them all self contained. One of the apps uses 11g and the rest use 10g. Right now the ones that use 10g are ear files and the one that uses 11g is a war file so it works. Now I'm going to convert the ear files to war files(I don't need the ear functionality) in order to test how much Permgen space is used. So I guess my question is: I meant how can I deploy an ear using the ojbc*.jar in the ear file, not in the server/lib directory?

A: 

Just duplicate you datasource.xml i.g. datasource-ds10g.xml and datasource-ds11g.xml with correct connection-url's. And refer from your .ear to on of the datasources.

stacker
A: 

On ojdbc.jar version, unless there are specific features of the driver that you need that do not exist in the latest version, then always just use the latest, since they will always be backwards compatibile. In that case then using the server's central lib repo is best...but that being said I fully understand the requirement to make each web application independant and more easily deployable.

On deployment, if you are using an IDE, you can define the jdbc jar as a "library", and then in the "deployment" you can set it to deploy the libraries with the code. In JDeveloper, when you define a User Library you can choose to "Deploy it by default" which will automatically assign it to be grouped into an WAR or EAR file builds that come from projects that use this library. If you do not set the User Library as "deploy by default" or your IDE doesn't have this option, typically the "deployment" parameters (or whatever part of your IDE manages the WAR and EAR file builds) will have a section to select which libraries to include.

If you are not using an IDE, then you can push these jar files in manually into WEB-INF/lib in your warfile structure.

REW
The app server creates the connection pool, not the webapp (so the driver can't be in `WEB-INF/lib`)
Pascal Thivent
Ok. If you are relying on connection pools by your app server, then your driver needs to be available to the app server, independant of the web applications that are deployed to it. IDE's conveniently deploy datasources with projects to the app server for us typically, but these are independant entities, so I don't think you can have the app server context dependant on the app deployment.
REW