We will walk through a quick example of how to resolve “weblogic.common.resourcepool.ResourceSystemException: Cannot load driver class:” errors and learn where to install the JDBC driver libraries to fix runtime issues.
I was playing with ADF samples and had a database connection to a MySQL instance. This was achieved by adding the MySQL-Connector library during design time.
Now, when I had the sample application ready and ran a test on the local Weblogic server – I got the following errors:
<Oct 9, 2010 4:14:45 PM EST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004 weblogic.application.ModuleException: at weblogic.jdbc.module.JDBCModule.prepare(JDBCModule.java:290) at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199) at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:507) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41) at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:149) Truncated. see log file for complete stacktrace Caused By: weblogic.common.resourcepool.ResourceSystemException: Cannot load driver class: com.mysql.jdbc.Driver at weblogic.jdbc.common.internal.JDBCUtil.parseException(JDBCUtil.java:301) at weblogic.jdbc.common.internal.ConnectionEnvFactory.loadDriver(ConnectionEnvFactory.java:75) at weblogic.jdbc.common.internal.ConnectionEnvFactory.<init>(ConnectionEnvFactory.java:131) at weblogic.jdbc.common.internal.ConnectionPool.initPooledResourceFactory(ConnectionPool.java:686) at weblogic.common.resourcepool.ResourcePoolImpl.start(ResourcePoolImpl.java:230) Truncated. see log file for complete stacktrace
It was clear that I was missing the MySQL-Connector libraries and had to stick it into some lib folder. But the question was which lib folder?
The best way to find out about your application server is to …. *hint* “logs”…. yes! Read the startup logs. I agree it is sometimes hard to read when stuff is flying by so fast, so it is good practice to “grab”/”copy” from the Weblogic console and paste it into Notepad++ or your favorite text-editor.
Now, you should be looking for a few things … where is the JVM which launched the app (i.e. bootstrap libraries) and in Weblogic server’s case …where is the domain home.
I will skip the story about how I put the jar in “c:\Oracle\Middleware\wlserver_10.3\server\lib”, “c:\Oracle\Middleware\wlserver_10.3\common\lib”, “c:\Oracle\Middleware\jdeveloper\lib” … and it did not work!
What worked was when I put it (the mysql lib jar) in the domain home as indicated in the server-startup (so you are looking at a line that is something like)Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode) Starting WLS with line: C:\Oracle\MIDDLE~1\JDK160~1\bin\java -client ...-Ddomain.home=C:\Users\<username>\AppData\Roaming\JDEVEL~1\SYSTEM~1.60\DEFAUL~1
Notice the domain home. This is where we ought to stick the connector jar into.
Another way to look at it – nodemanager props
I also looked at the server start-up logs and the nodemanager properties to get a better idea of the server setup. As you can see the details are in the properties file here, just need to pick the right home – the logical “Domain”‘s home."c:\Oracle\Middleware\wlserver_10.3\common\nodemanager>more nodemanager.domains"#Domains and directories created by Configuration Wizard #Fri Oct 08 20:18:00 EST 2010 base_domain=C\:\\Oracle\\Middleware\\user_projects\\domains\\base_domain DefaultDomain=C\:\\Users\\<username>\\AppData\\Roaming\\JDeveloper\\system22.214.171.124.37.56.60\\DefaultDomain
I tried putting the jar in the base domain and stopped/started the server but that did not work. It only worked when I put the jar in the default domain.