-
1. Re: Linkage error wile using custom Oracle Driver(xa-datasource-class) in standalone.xml
pmm Sep 25, 2014 7:23 AM (in response to jtiwari)What are the contents of xmz.jar? You you have a javax.transaction.xa.XAResource class in there?
-
2. Re: Linkage error wile using custom Oracle Driver(xa-datasource-class) in standalone.xml
jtiwari Sep 25, 2014 8:22 AM (in response to pmm)Thank you Philippe for the quick reply,
Yes, xmz.jar is using javax.transaction.xa.XAResource . Actually, I have written a wrapper which is internally using avax.transaction.xa.XAResource .
I tried to debug it bit more detail level using -verbose:class and I found that javax.transaction.xa.XAResource is being loaded from jdk\rt.jar. Since, Wildfly also loads javax module(javax.transaction.api), so, I believe this may be the primary reason for the Linkage Error.
[Loaded javax.transaction.xa.XAResource from D:\Java\jdk\jre\lib\rt.jar]
Any help will be highly appreciated.
Thank you
Jitendra Tiwari
-
3. Re: Linkage error wile using custom Oracle Driver(xa-datasource-class) in standalone.xml
pmm Sep 25, 2014 10:27 AM (in response to jtiwari)Is it just using javax.transaction.xa.XAResource or do you package it into the JAR?
-
4. Re: Linkage error wile using custom Oracle Driver(xa-datasource-class) in standalone.xml
jtiwari Sep 25, 2014 12:24 PM (in response to pmm)yes , I packaged it as a jar, let me explain by the example
import javax.transaction.xa.XAResource
class xyz(){
// using XAResource/XAConnection
}
packaged it into a jar called xmz.jar
Thanks
Jitendra Tiwari
-
5. Re: Linkage error wile using custom Oracle Driver(xa-datasource-class) in standalone.xml
pmm Sep 26, 2014 6:27 AM (in response to jtiwari)You must not have any javax.transaction.* classes in the xmz.jar. It is ok to have classes there that use javax.transaction.* classes.
<module name="javax.api"/>
<module name="javax.transaction.api"/>
Will provide the javax.transaction.* classes to you at runtime.
-
6. Re: Linkage error wile using custom Oracle Driver(xa-datasource-class) in standalone.xml
jtiwari Sep 26, 2014 6:37 AM (in response to pmm)Hello Philippe,
I am using many custom wrapper classes inside xmz.jar,
MYConnection.java uses javax.transaction..xa.XAConnection.
Mydatasource.java uses javax.transaction..xa.XADatasource
Please suggest, how can I get rid of this issue.
Thanks.
Jitendra Tiwari
-
7. Re: Linkage error wile using custom Oracle Driver(xa-datasource-class) in standalone.xml
pmm Sep 26, 2014 9:34 AM (in response to jtiwari)Having custom classes that use javax.transaction.* classes in xmz.jar is totatlly fine. Packing javax.transaction.* into xmz.jar is an issue. Just build xmz.jar containing your custom wrapper classes but do not include javax.transaction.* classes in the JAR.
-
8. Re: Linkage error wile using custom Oracle Driver(xa-datasource-class) in standalone.xml
jtiwari Sep 26, 2014 10:44 AM (in response to pmm)Hello Philippe,
Thanks a lot for your suggestions.
I verified the xmz.jar, This jar does not contain any javax.transaction.* classes, only internally my custom classes are using those classes . But yes, since my code is depend on ironjacamar-jdbc-1.1.5.Final.jar and ojdbc6.jar. I used these two jar just to compile my code.
Apart from that, I tried to remove all the jar from my application having javax package.
One more thing I observed that XAResource is getting loaded by the JDK rt.jar
[Loaded javax.transaction.xa.XAResource from <JAVA_HOME>\jre\lib\rt.jar].
That I believe may be the root cause.
I am not sure how to avoid class loading from rt.jar.
I tried almost every possible options. Any help on this issue would really be appreciated .
Thank You.
Jitendra Tiwari
-
9. Re: Linkage error wile using custom Oracle Driver(xa-datasource-class) in standalone.xml
rhodan76 Jan 8, 2015 8:01 AM (in response to jtiwari)[Loaded javax.transaction.xa.XAResource from <JAVA_HOME>\jre\lib\rt.jar].
Can someone explain why javax.transaction.xa.XAResource is also loaded from JDK? As far as i understand the javax.transaction package is NOT getting exported from jboss "sun.jdk" module (and also nowhere else) and thus should not be accessible by any classloader in Jboss/Wildfly?
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2010, Red Hat, Inc., and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<module xmlns="urn:jboss:module:1.3" name="sun.jdk">
<resources>
<!-- currently jboss modules has not way of importing services from
classes.jar so we duplicate them here -->
<resource-root path="service-loader-resources"/>
</resources>
<dependencies>
<system export="true">
<paths>
<path name="com/sun/script/javascript"/>
<path name="jdk/nashorn/api/scripting"/>
<path name="com/sun/image/codec/jpeg"/>
<path name="com/sun/imageio/plugins/bmp"/>
<path name="com/sun/imageio/plugins/common"/>
<path name="com/sun/imageio/plugins/gif"/>
<path name="com/sun/imageio/plugins/jpeg"/>
<path name="com/sun/imageio/plugins/png"/>
<path name="com/sun/imageio/plugins/wbmp"/>
<path name="com/sun/imageio/spi"/>
<path name="com/sun/imageio/stream"/>
<path name="com/sun/jndi/dns"/>
<path name="com/sun/jndi/ldap"/>
<path name="com/sun/jndi/url"/>
<path name="com/sun/jndi/url/corbaname"/>
<path name="com/sun/jndi/url/dns"/>
<path name="com/sun/jndi/url/iiop"/>
<path name="com/sun/jndi/url/iiopname"/>
<path name="com/sun/jndi/url/ldap"/>
<path name="com/sun/jndi/url/ldaps"/>
<path name="com/sun/media/sound"/>
<path name="com/sun/crypto/provider"/>
<path name="com/sun/org/apache/xml/internal/security/transforms/implementations"/>
<path name="com/sun/security/auth"/>
<path name="com/sun/security/auth/login"/>
<path name="com/sun/security/auth/module"/>
<path name="com/sun/tools/internal/xjc"/>
<path name="sun/awt"/>
<path name="sun/awt/color"/>
<path name="sun/awt/datatransfer"/>
<path name="sun/awt/dnd"/>
<path name="sun/awt/event"/>
<path name="sun/awt/geom"/>
<path name="sun/awt/im"/>
<path name="sun/awt/image"/>
<path name="sun/awt/image/codec"/>
<path name="sun/awt/motif"/>
<path name="sun/awt/resources"/>
<path name="sun/awt/shell"/>
<path name="sun/awt/util"/>
<path name="sun/awt/windows"/>
<path name="sun/awt/X11"/>
<path name="sun/dc"/>
<path name="sun/print"/>
<path name="sun/print/resources"/>
<path name="sun/security/action"/>
<path name="sun/security/pkcs"/>
<path name="sun/security/x509"/>
<path name="sun/jdbc/odbc"/>
<path name="sun/jdbc/odbc/ee"/>
<path name="sun/font"/>
<path name="sun/misc"/>
<path name="sun/io"/>
<path name="sun/nio"/>
<path name="sun/nio/ch"/>
<path name="sun/nio/cs"/>
<path name="sun/nio/cs/ext"/>
<path name="sun/security"/>
<path name="sun/security/util"/>
<path name="sun/security/krb5"/>
<path name="sun/util"/>
<path name="sun/util/calendar"/>
<path name="sun/util/locale"/>
<path name="sun/util/resources"/>
<path name="sun/security/pkcs11"/>
<path name="sun/security/provider"/>
<path name="sun/text"/>
<path name="META-INF/services"/>
</paths>
<exports>
<include-set>
<path name="META-INF/services"/>
</include-set>
</exports>
</system>
</dependencies>
</module>
-
10. Re: Linkage error wile using custom Oracle Driver(xa-datasource-class) in standalone.xml
pmm Jan 8, 2015 10:59 AM (in response to rhodan76)Is it really loaded from the JDK and not from the javax.transaction.api module?
-
11. Re: Linkage error wile using custom Oracle Driver(xa-datasource-class) in standalone.xml
rhodan76 Jan 8, 2015 11:29 AM (in response to pmm)To be correct, the XAResource class is loaded from javax.transaction.api module
[Loaded javax.transaction.xa.XAResource from jar:file:/C://wildfly-8.1.0.Final/modules/system/layers/base/javax/transaction/api/main/jboss-transaction-api_1.2_spec-1.0.0.Final.jar!/]
but later in deployment there is an attempt to load XAResource class also from JDK (i think because we defined a datasource in standalone.xml using jdbcdslog) but the loader rejects this:
[Loaded javax.transaction.xa.XAResource from C:\Program Files\Java\jdk1.7.0_60\jre\lib\rt.jar]
[Constraint check failed for name javax/transaction/xa/XAResource, loader <bootloader>: the presented class object differs from that stored ]
We have jdbcdslog included as a module,
<module xmlns="urn:jboss:module:1.1" name="org.jdbcdslog">
<resources>
<resource-root path="jdbcdslog-1.0.5.jar"/>
</resources>
<dependencies>
<module name="org.slf4j"/>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<!-- TODO: add other database modules as other optional dependencies like h2 -->
<module name="com.oracle.ojdbc6" optional="true" />
</dependencies>
</module>
which runs into loader constraint violation trouble with XAResource class:
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "javax/transaction/xa/XAResource"
at java.lang.Class.getDeclaredMethods0(Native Method) [rt.jar:1.7.0_60]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2570) [rt.jar:1.7.0_60]
at java.lang.Class.privateGetPublicMethods(Class.java:2690) [rt.jar:1.7.0_60]
at java.lang.Class.getMethods(Class.java:1467) [rt.jar:1.7.0_60]
at sun.misc.ProxyGenerator.generateClassFile(ProxyGenerator.java:426) [rt.jar:1.7.0_60]
at sun.misc.ProxyGenerator.generateProxyClass(ProxyGenerator.java:323) [rt.jar:1.7.0_60]
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:671) [rt.jar:1.7.0_60]
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:591) [rt.jar:1.7.0_60]
at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:244) [rt.jar:1.7.0_60]
at java.lang.reflect.WeakCache.get(WeakCache.java:141) [rt.jar:1.7.0_60]
at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:454) [rt.jar:1.7.0_60]
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:736) [rt.jar:1.7.0_60]
at org.jdbcdslog.XAConnectionLoggingProxy.wrap(XAConnectionLoggingProxy.java:10)
at org.jdbcdslog.DataSourceProxyBase.getXAConnection(DataSourceProxyBase.java:126)
at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:497)
... 12 more
jdbcdslog problematic source seems to be:
package org.jdbcdslog;
import java.lang.reflect.Proxy;
import javax.sql.XAConnection;
public class XAConnectionLoggingProxy {
public static XAConnection wrap(XAConnection con) {
return (XAConnection)Proxy.newProxyInstance(con.getClass().getClassLoader() , new Class[]{XAConnection.class}, new GenericLoggingProxy(con));
}
}
XAConnection.getClass().getClassLoader seems to reference a classloader which tries to load another version of javax.transaction.xa.XAResource than provided by javax.transaction.api module = java.lang.LinkageError: loader constraint violation?
Am i correct?
-
12. Re: Linkage error wile using custom Oracle Driver(xa-datasource-class) in standalone.xml
rhodan76 Jan 8, 2015 4:38 PM (in response to rhodan76)Philipe Marschall schrieb:
Is it really loaded from the JDK and not from the javax.transaction.api module?
Rhodan76 schrieb:
To be correct, the XAResource class is loaded from javax.transaction.api module
[Loaded javax.transaction.xa.XAResource from jar:file:/C://wildfly-8.1.0.Final/modules/system/layers/base/javax/transaction/api/main/jboss-transaction-api_1.2_spec-1.0.0.Final.jar!/]
but later in deployment there is an attempt to load XAResource class also from JDK (i think because we defined a datasource in standalone.xml using jdbcdslog) but the loader rejects this:
[Loaded javax.transaction.xa.XAResource from C:\Program Files\Java\jdk1.7.0_60\jre\lib\rt.jar]
[Constraint check failed for name javax/transaction/xa/XAResource, loader <bootloader>: the presented class object differs from that stored ]
The question is, why is there a second attempt to load javax/transaction/xa/XAResource but from a different library (rt.jar of JDK) insteadof "javax.transaction.api" module. All modules only have declared dependencies to "javax.transaction.api" module.
-
13. Re: Linkage error wile using custom Oracle Driver(xa-datasource-class) in standalone.xml
pmm Jan 9, 2015 4:59 AM (in response to rhodan76)Which classloader does
org.jdbcdslog.XAConnectionLoggingProxy.wrap(XAConnectionLoggingProxy.java:10)
pass to Proxy.newProxyInstance?
-
14. Re: Linkage error wile using custom Oracle Driver(xa-datasource-class) in standalone.xml
rhodan76 Jan 9, 2015 5:20 AM (in response to pmm)Philippe Marschall schrieb:
Which classloader does
org.jdbcdslog.XAConnectionLoggingProxy.wrap(XAConnectionLoggingProxy.java:10)
pass to Proxy.newProxyInstance?
The classloader of another module ("com.oracle.ojdbc6"):
ModuleClassLoader for Module "com.oracle.ojdbc6:main" from local module loader @38f4f222 (finder: local module finder @5944b364 (roots: C:\wildfly-8.1.0.Final\modules,C:\wildfly-8.1.0.Final\modules\system\layers\base))
module definition:
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.0" name="com.oracle.ojdbc6"> <resources> <resource-root path="com.oracle.ojdbc6-11.2.0.jar"/> </resources> <dependencies> <module name="javax.api"/> <module name="javax.transaction.api"/> </dependencies> </module>