When deploying a war, no issues are there. At run-time, facing java.lang.LinkageError exception.
Details of exception:
Failed to define class javax.wsdl.extensions.soap12.SOAP12HeaderFault in Module
"abc.war:main" from Service Module Loader: java.lang.LinkageError: loader
constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader)
previously initiated loading for a different type with name
"javax/wsdl/extensions/soap12/SOAP12HeaderFault"
How can I check which jars are conflicting and in which class loader?
Stack : Jboss 6, Java 7
A WAR deployment is considered to be a single module in JBOSS 6.
Classes in the WEB-INF/lib directory are treated the same as classes
in WEB-INF/classes directory. All classes packaged in the war will be
loaded with the same class loader.
So problem in WAR packet. You can see all dependency witth mvn dependency:tree command in WAR. If have two or more different version, you should delete one of them.
If there is no conflict in package, probably jboss loaded different your SOAP12HeaderFault version. You can exclude related dependency with jboss-deployment-structure.xml.
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="javax.wsdl" />
</exclusions>
</deployment>
Related
I'm trying to make a sign operation with a XML file. In this process, I use the xmlSec 1.5 library. If I run the code in a local test the process finishes successfully.
However, if I deploy the code in a war in a Jboss 7.1, my dependency with xmlSec 1.5 is override by Jboss by its module dependency "xmlsec-2.0.8.redhat-1", and the sign process fails.
For client's petition, I can exclude the xmlsec Jboss module, but I cannot use it to sign.
So, the problem is: how could I specify a given library version to be used only in a part of the code?.
In this case, the path of both dependencies are the same: org.apache.santuario, so, I cannot use it in order to specify the library.
I'm trying to use a provider for signing, but, again, Jboss override my xmlsec-1.5 security provider for its xmlsec-2.0.8 security provider. There exists some way to instanciate a provider and adds it to the set of java providers in order to replace the Jboss one?
You can exclude the JBoss provided dependency using jboss-deployment-structure.xml file which you need to place under the WEB-INF directory of your war. You have to specify the exclusion dependencies something like below.
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="$LIBRARY_OR_MODULE_YOU_WANT_TO_EXCLUDE"/>
</exclusions>
</deployment>
e.g. <module name="org.apache.santuario.xmlsec"/>
When starting my managed server I see the following ClassCastException related to log4j in my WebLogic 12c managed server out file. I have commons-logging-1.1.1.jar and log4j-1.2.17.jar bundled in my WAR's lib directory and no other version of those libraries there. I also pasted the managed server log file error generated in in processing a request. Should I be using the log4j and commons logging that comes with WebLogic 12c? I see these in the modules directory: com.bea.core.apache.commons.logging_1.1.2.jar and com.bea.core.apache.log4j_1.2.0.0_1-2-15.jar. I haven't had a problem with log4j and WebLogic before.
out file:
jadomain.lang.ClassCastException: org.apache.log4j.RollingFileAppender cannot be cast to org.apache.log4j.Appender
at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.jadomain:248)
at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.jadomain:176)
at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.jadomain:191)
at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.jadomain:523)
at org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.jadomain:436)
at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.jadomain:1004)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.jadomain:872)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.jadomain:778)
at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.jadomain:906)
at com.domain.d.app.restwrapper.ContextListener.contextInitialized(ContextListener.jadomain:37)
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.jadomain:66
log file:
]] Root cause of ServletException.
jadomain.lang.LinkageError: loader constraint violation: when resolving method "org.apache.log4j.LogMF.entering(Lorg/apache/log4j/Logger;Ljadomain/lang/String;Ljadomain/lang/String;)V" the class loader (instance of weblogic/utils/classloaders/ChangeAwareClassLoader) of the current class, com/domain/d/app/restwrapper/appResource, and the class loader (instance of weblogic/utils/classloaders/GenericClassLoader) for resolved class, org/apache/log4j/LogMF, have different Class objects for the type /lang/String;)V used in the signature
at com.domain.d.app.restwrapper.appResource.addQuery(appResource.jadomain:244)
at com.domain.d.app.restwrapper.appResource.addQuery(appResource.jadomain:224)
at com.domain.d.app.restwrapper.appResource$Proxy$_$$_WeldClientProxy.addQuery(appResource$Proxy$_$$_WeldClientProxy.jadomain)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jadomain:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jadomain:43)
You have a conflict between tow versions of log4j. One is loaded from the server's classpath and the other one from your web application's classpath.
To resolve it you can setup your web application to use only the one from your application. Update your weblogic.xml file and add the following tag :
<prefer-web-inf-classes>true</prefer-web-inf-classes>
I'm running the following class loading issue with JBOSS.
My JBOSS's module.xml:
<module xmlns="urn:jboss:module:1.0" name="com.example">
<resources>
...
<resource-root path="spring-amqp-1.4.6.RELEASE.jar"/>
...
</resources>
</module>
When org.springframework.amqp.support.converter.DefaultJackson2JavaTypeMapper:getClassIdType(String classId) is called
MessageConversionException: failed to resolve class name... is thrown by
ClassUtils.forName(classId, getClass()
.getClassLoader())
Debugging getClass().getClassLoader() returns ModuleClassLoader for Module "com.example:main".
So it seems the issue is the class I'm deserializing is not in module com.example (defined in module.xml) so it throws that exception
Myjboss-deployment-structure.xml has com.example as a dependency:
<dependencies>
<module name="com.example">
<imports>
<include path="META-INF**"/>
</imports>
</module>
</dependencies>
I can fix this problem if I remove spring-amqp-1.4.6.RELEASE.jar from module.xml and add spring-amqp to my build.gradle. Problem is module.xml is shared across my org and I can't change that.
So how can I fix this? Appreciate any help.
A stacktrace (and some more code) to reproduce would be nice. I am not familiar with amqp.
In https://github.com/spring-projects/spring-amqp/blob/master/spring-amqp/src/main/java/org/springframework/amqp/support/converter/DefaultJackson2JavaTypeMapper.java at line 56, ClassUtils.forName(classId, getClass().getClassLoader()) gets called, but can't find the class.
In JBoss, module classloaders are seperated from application classloaders. In your application, you can access all classes from the module, but the module can't access your WAR or JAR classes.
So, this is exception is thrown, because your module, tries to load a class from your application, which is not visible in the module classloader. But if you add the amqp-jar to your application, it works, because they share the same classloader.
If you want/need amqp in a module, you need to create a module with your application common-classes and add it to your module as a dependency. But also note, you can't add the common.jar to the application.jar anymore to avoid classCastExceptions.
I don't know, how amqp is used, but probably, you need to create multiple modules to use it with different common.jars.
For more information about jboss classloading, i can refer you to:
http://www.mastertheboss.com/jboss-server/jboss-as-7/discover-jboss-as-7-modularity
https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6/html/Development_Guide/chap-Class_Loading_and_Modules.html
I am trying to deploy an ear application on wildfly 9 that tries to connect to MQ and to a JCA resource adapter.
Structure of my ear file
myApp.ear
|--lib/
|----Spring.jar (Multiple jars for different modules needed)
|----META-INF/
|--myAppEJB.jar (EJB project)
|--myAppWeb.war
|--jboss-deployment-structure.xml
The JCA resource adapter (myCompConnector.rar) is packaged as a rar and deployed with an ra.xml inside it. myCompConnector uses two jars supportingjar1.jar and supportingjar2.jar and are packaged inside the rar file.
Structure of my MyCompConnector.rar:
MyCompConnector.rar
|--META-INF
|--supportingjar1.jar
|--supportingjar2.jar
|--MyCompConnector.jar
my application also uses the classes that are in myCompConnector but is compiled with myCompConnector.jar. I make the build using maven 3 and I do not package the myCompConnector.jar or any depending jars.
If i deploy it says that NoClassDefFoundError for a class in supportingjar1.jar, So i add ONLY the supporting jars by putting in the lib of the ear myApp.ear (making the war a skinny war as well supporting jars are only used in the EJB project's pom file not in WAR)
Then If i deploy it on wildfly it says NoClassDefFoundError MyCompConnectorInspector.java and ClassNotFoundError MyCompConnectorInspector.java. MyCompConnectorInspector is a class in the MyCompConnector.jar which is also present in MyCompConnector.rar.
Caused by: java.lang.NoClassDefFoundError: Lcom/myComp/MyCompConnector/MyCompConnectorInspector ;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2317)
at java.lang.Class.getDeclaredFields(Class.java:1762)
at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57)
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)
... 10 more
Caused by: java.lang.ClassNotFoundException: com.mycomp.MyCompConnector.MyCompConnectorInspector from [Module "deployment.myApp-1.3.ear.myAppEJB-1.3.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:130)
... 15 more
So I add MyCompConnector.jar as well in the lib folder of the ear file
(So now my MyCompConnector.rar is loaded and MyCompConnector.jar is loaded from the lib folder in the ear file)
If i deploy now it says ClassCastException: com.comp.MyCompConnector.MyCompConnectorInspector.java cannot be cast to com.comp.MyCompConnector.MyCompConnectorInspector.java
which is true as it is loaded from two sides. Now i cannot remove the rar resource adapter so if i remove the jar file from the lib of the ear it says the above mentioned error: NoClassDefFoundError MyCompConnectorInspector.java and ClassNotFoundError MyCompConnectorInspector.java.
So now i am in a fix. If i add the jar to remove the NoClassDefFoundError it will give me classcast exception.
In the event of the class cast exception I see that MyCompConnectorInspector is loaded from the RAR's MyCompConnector.jar (when i do -verbose=class) but when i remove the jar file from the myApp/lib/ then i do not see MyCompConnectorInspector being loaded from the RAR's MyCompConnector.jar.
my jboss-deployment-structure in the ear file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="MyCompConnector.rar" />
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.jms.api"/>
<!--<module name="com.compConnector.supportingjar1"/>
<module name="com.compConnector.supportingjar2"/> -->
</dependencies>
</deployment>
</jboss-deployment-structure>
How can I make the rar deployment seen as something that my ear file should refer to as a library as well as all he dependent libraries included in the RAR.
one more question: when i deploy a RAR, is it technically a module. (Modules are a new concept for me from Jboss 5 or websphere which i have worked with before)
One funny thing that I have seen, If i use
<module name="deployment.MyCompConnector.rar" />
that I have seen in some expamples in any Resource Adapter definition it does not load at all. if i remove the deployment. then it creates the jndi name for it and binds it. I dont know if it is related tough.
Any help will be appreciated. I am new to Wildfly so I am still learning its tricks.
Thanks.
P.S : I even tried to do
<global-modules>
<module name="deployment.MyCompConnector.rar" />
</global-modules>
but it only gave me Failed to load module: deployment.MyCompConnector.rar:main
Then ModuleNotFoundException : deployment.MyCompConnector.rar:main
i deployed the rar through the console and not through creating a module in the modules folder and then added a connection definition in the resourceAdppaters in the standalone-full.xml . this is the same I deployed the wmq.jmsra.rar file and then made the connection definition.
It seems there is an issue in Wildfly when a resource adapter is being referenced from within a jar (in modules) or from a jar inside an ear. In a war it works fine.
I may be mistaken when i assume there is an issue in WF9. but i made it to work. I had this issue in case of an ear as well as a jar.
in case of ear I simply converted the ear into a war and pluggged my EJBs into the War's WEB-INF/lib folder as a jar. and it worked without any issues.
Hopefully it will help some one who has a RAR resource adapter and is using the resource adapter'sconnection classes as library inside the EJBs of an ear project.
I'm deploying an ear to JBoss and when I start the server I get this exception thrown:
Caused by: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "ch.qos.logback.classic.LoggerContext.getLogger(Ljava/lang/String;)Lorg/slf4j/Logger;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, ch/qos/logback/classic/LoggerContext, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for interface org/slf4j/ILoggerFactory have different Class objects for the type ;)Lorg/slf4j/Logger; used in the signature
I have an EAR project and in the deployment assembly I include logback-classic/logback-core/ and slf4j-api. When I do this, the three jars automatically get placed in the EAR Libraries folder in the build paths of 2 other ejb projects (which are both packaged as jars and referenced in the deployment assembly of the EAR)
not sure why this is happening.. Also, when I dont put the jars in the deployment assembly of the EAR, I link them in the build path of the 2 ejb projects directly, but when I deploy the ear JBoss throws noClassFound exception on slf4j/Logger..
any ideas?
Fixed this issue.. I had to edit my jboss-deployment-structure.xml and add the main deployment with exclusions in addition to the sub-deployments that I had.