aspose file tools*
The moose likes BEA/Weblogic and the fly likes Web Application Class Loader and Weblogic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Web Application Class Loader and Weblogic" Watch "Web Application Class Loader and Weblogic" New topic
Author

Web Application Class Loader and Weblogic

Wasim Ayoubi
Ranch Hand

Joined: Nov 21, 2004
Posts: 46
I am working on J2EE project that I am trying to deploy on weblogic8.1 and 9.2 servers;
this project supports multi-database vendors, oracle is one of the supported databases.

In this project we use the following oracle jdbc driver by placing it�s jar file into WEB-INF\lib folder of our web application

�Specification-Title: "Oracle JDBC driver classes for use with JDK1.4"
Specification-Version: "Oracle JDBC Driver version - 9.0.2.0.0"
Specification-Vendor: "Oracle Corporation" .
Implementation-Title: "ojdbc14.jar"
Implementation-Version: "Oracle JDBC Driver version - 9.0.2.0.0"
Implementation-Vendor: "Oracle Corporation"
Implementation-Time: "Thu Apr 25 23:14:02 2002"�


My problem is as follows:

Weblogic server 8.1 and 9.2 uses the following oracle jdbc driver by default

Specification-Title: Oracle JDBC driver classes for use with JDK14
Sealed: true
Created-By: 1.4.2_08 (Sun Microsystems Inc.)
Implementation-Title: ojdbc14.jar
Specification-Vendor: Oracle Corporation
Specification-Version: Oracle JDBC Driver version - "10.2.0.2.0"
Implementation-Version: Oracle JDBC Driver version - "10.2.0.2.0"
Implementation-Vendor: Oracle Corporation
Implementation-Time: Tue Jan 24 08:55:21 2006

the driver I am using in my project which is 9.0.2 reads dates from database as java.sql.Timestamp objects
but the bundled 10g jdbc driver reads dates as java.sql.Date objects which make my code not to run and throws ClassCastException exceptions.

I want to figure how to make my application uses the ojdbc driver in the WEB-INF/lib folder, as I know from J2EE specs
every web application has it's own classloader that loads classes by order and it starts loading from the WEB-INF/lib folder. but
it seems loading the 10g driver classes first.

I can make a work around by creating managed server and modify the startWLS.cmd file by adding the jar file I want in front of the classpath
but this may be not applicable for customers who do not want to create a new managed server! also I have customers who have other third party
application which run using oracle 10g driver and the customer wants these applications to still using the weblogic OTB 10g driver.

What I want exactly, how to make a specific web application deployed on Weblogic server uses a specific driver jar file without affecting the server
classpath or any other third part applications deployed on the same server instance.

Email: wayoubi@etq.com


Wasim Ayoubi<br />SCJA1.0(BETA), SCJP1.4, SCWCD1.4<br />Next ???
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8713
    
    6

How are you obtaining your database connections? If you are configuring it through the Weblogic console and getting the connection through JNDI, I would assume that Weblogic would use the classes in the system classpath, which is not what you want.
If you register the driver name in your code and obtain the connection through a call to DriverManager.getConnection(), I would assume that you would get the classes in your web application's classpath.
I've never tried it.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Wasim Ayoubi
Ranch Hand

Joined: Nov 21, 2004
Posts: 46
Hi

The Jar file is placed into the WEB-INF/lib folder and I am using DriverManager.getConnection to obtain connection to the database.

I posted the this question to BEA support and got a great answer from them, I shall provide a special weblogic deployment descriptor (next to web.xml) which is weblogic-web.xml and use a custom weblogic deployment tag to prefer using classes from the WEB-INF/lib folder.

I tried this and it is working fine

see link below for more details
http://e-docs.bea.com/wls/docs81/programming/classloading.html#1082452

http://e-docs.bea.com/wls/docs92/programming/classloading.html
[ December 07, 2006: Message edited by: Wasim Ayoubi ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web Application Class Loader and Weblogic
 
Similar Threads
[OAS] Change jdbc driver
problem occurs when connecting to thin driver...
Oracle 10g driver throws java.sql.SQLException: OALL8 is in an inconsistent state Web
Type mismatch: cannot convert from AccessType to XmlAccessType
ORACLE DRIVER