Reputation: 309
I have a project running on a JBoss 7 server that I'm trying to use c3p0 for. JBoss 7 doesn't support just dumping the jars in a /lib folder like in previous versions. As I understand it I need to use the new module system. Here are the steps I have taken:
Downloaded the c3p0 jars from here: http://sourceforge.net/projects/c3p0/?source=dlp
Copied the 3 jars into my Eclipse project and added them to the build path (I'm fairly certain this was done correctly).
Made a folder at JBOSS_HOME\modules\com\c3p0\main and I added the 3 jars there, plus I made a file "module.xml" with the following contents:
<?xml version="1.0" encoding="UTF-8
<module xmlns="urn:jboss:module:1.0" name="com.c3p0">
<resources>
<resource-root path="c3p0-0.9.5-pre8.jar"/>
<resource-root path="c3p0-oracle-thin-extras-0.9.5-pre8.jar"/>
<resource-root path="mchange-commons-java-0.2.7.jar"/>
</resources>
</module>
I added the following to my JBoss standalone.xml (the sun.jdk part was already there):
<subsystem xmlns="urn:jboss:domain:ee:1.0">
<global-modules>
<module name="sun.jdk" slot="main"/>
<module name="com.c3p0" slot="main"/>
</global-modules>
</subsystem>
Ran the server and accessed the part of the code that uses a class from the c3p0 jar. Got the following error message (abridged):
WARN [org.jboss.modules] (http-localhost-127.0.0.1-9091-2) Failed to define class com.mchange.v2.c3p0.ComboPooledDataSource in Module "com.c3p0:main" from local module loader @50908fa9 (roots: C:\jboss-as-web-7.0.2.Final\modules): java.lang.LinkageError: Failed to link com/mchange/v2/c3p0/ComboPooledDataSource (Module "com.c3p0:main" from local module loader @50908fa9 (roots: C:\jboss-as-web-7.0.2.Final\modules))
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:401)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:261)
at org.jboss.modules.ModuleClassLoader$1. loadClassLocal(ModuleClassLoader.java:76)
... LOTS MORE
Caused by: java.lang.NoClassDefFoundError: javax/naming/Referenceable
at java.lang.ClassLoader.defineClass1(Native Method) [:1.7.0_45]
at java.lang.ClassLoader.defineClass(Unknown Source) [:1.7.0_45]
at java.security.SecureClassLoader.defineClass(Unknown Source) [:1.7.0_45]
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:397)
... 86 more
Caused by: java.lang.ClassNotFoundException: javax.naming.Referenceable from [Module "com.c3p0:main" from local module loader @50908fa9 (roots: C:\jboss-as-web-7.0.2.Final\modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
... 90 more
javax.ejb.EJBException: Unexpected Error
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:157)
...
Caused by: java.lang.LinkageError: Failed to link com/mchange/v2/c3p0/ComboPooledDataSource (Module "com.c3p0:main" from local module loader @50908fa9 (roots: C:\jboss-as-web-7.0.2.Final\modules))
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:401)
...
Caused by: java.lang.NoClassDefFoundError: javax/naming/Referenceable
at java.lang.ClassLoader.defineClass1(Native Method)
...
Caused by: java.lang.ClassNotFoundException: javax.naming.Referenceable from [Module "com.c3p0:main" from local module loader @50908fa9 (roots: C:\jboss-as-web-7.0.2.Final\modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
...
What am I doing wrong? Any help is much appreciated!
SOLUTION:
My module.xml was missing dependencies. The one that works is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.c3p0">
<resources>
<resource-root path="c3p0-0.9.5-pre8.jar"/>
<resource-root path="c3p0-oracle-thin-extras-0.9.5-pre8.jar"/>
<resource-root path="mchange-commons-java-0.2.7.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="org.hibernate"/>
</dependencies>
</module>
Upvotes: 2
Views: 1880
Reputation: 5673
You need to define the <dependencies>
for your custom c3p0 module. I would start with this and add others as necessary.
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.c3p0">
<resources>
<resource-root path="c3p0-0.9.5-pre8.jar"/>
<resource-root path="c3p0-oracle-thin-extras-0.9.5-pre8.jar"/>
<resource-root path="mchange-commons-java-0.2.7.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Note that the javax.api
module is just an aggregation of a bunch of other EE module dependencies.
Upvotes: 4