Hibernate version: 2.1.8
JBoss version: 4.0.0
Hi,
I'm trying, in a web application, to programmatically configure the Hibernate properties, so that I can determine the database URL according to the host I'm running on.
The association is performed through a properties file present in the .war file.
The goal is to have the same configuration code working in J2EE and J2SE environments.
My problem is the following: if, in the JBoss environment, I only add the jdbc driver (for Oracle 9.2.0.6) to the war file, I get an exception raised on the first call to Session.beginTransaction() saying that no suitable driver can be found.
I could remote debug JBoss, so I know that the configuration properties are set the way I want them.
I also tried the following: added the Oracle driver jar into the <jboss>/server/default/lib folder, and the problem went away.
My analysis is that the hibernate classes are loaded in a separate class loader (probably a parent of the web app classloader), so the content of the war file is not visible to them. Do you confirm that?
However there is a catch in my situation (actually 2 catches):
- I am not allowed to deploy the jdbc driver jar in JBoss in the QA and production environment
- we need to have those jars in our war file since we use the Oracle OCI jdbc driver, which requires the Oracle client to be installed on the same machine, and of course jdbc drivers for different versions of the client are not compatible.
I would rather avoid having to configure several dastasources in JBoss, which would be wasteful since I'd only use one per instance.
Do you have any alternative approach that you think I might try?
Thank you very much for your time,
-Laurent
|