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.
Related
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>
QDeploying a service on JBOSS EAP 6.4 fetches an linking error while calling and ejb hosted on Jboss.I want to override the orb implementation but get the linkage error
Can someone help me with the steps to exclude this jboss rmi jar.
I tried excluding it in jboss deployment structure but in vain.
loader constraint violation in interface itable initialization: when resolving method
"com.ibm.rmi.io.ValueHandlerImpl.readValue(Lorg/omg/CORBA/portable/InputStream;ILjava/lang/Class;Ljava/lang/String;Lorg/omg/SendingContext/RunTime;)Ljava/io/Serializable;"
the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, com/ibm/rmi/io/ValueHandlerImpl,
and the class loader (instance of org/jboss/modules/ModuleClassLoader) for interface
javax/rmi/CORBA/ValueHandler have different Class objects for the type java/lang/Class;Ljava/lang/String;Lorg/omg/SendingContext/RunTime;)
Ljava/io/Serializable; used in the signature
I have maven dependency to import an external project jar. The jar is imported in my project by Maven and is present in my Libraries->Maven Dependencies.
I access a static method of a class present inside this Jar from one of my classes. When I do Maven build and run the project in Tomcat that is configured inside my Eclipse, it runs fine and the class and its method is accessible.
But when I deploy the war file build by Maven to external Tomcat server, I get
14-May-2017 14:40:31.631 SEVERE [http-nio-8080-exec-3] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [apple] in context with path [] threw exception [Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.apple.fruit.security.client.TokenManager] with root cause
java.lang.NoClassDefFoundError: Could not initialize class com.apple.fruit.security.client.TokenManager
I accessed that war file and found that the war file contains that jar.
What am I doing wrong?
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 having a problem in an EAR package which contains a server deployed persistence unit in an EJB mdule, and a web app in a WAR module
EAR
|--- persistence unit (EJB module)
|--- web app (WAR)
...
Everything compiles and the deploy (under WildFly 10 CR5) is performed successfully. The persistnce unit is correctly deployed and the schema is created (using Hibernate schema generation during development).
Though, when I try to persist one of the entities like that
MyEntitiy e = new MyEntitiy();
e.setId(UUID.randomUUID().toString());
e.setName("name");
entityService.save(e);
I get a runtime error which root cause is:
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String field x.y.z.MyEntity.id to x.y.z.MyEntity
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:58)
at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:36)
at java.lang.reflect.Field.get(Field.java:393)
at org.hibernate.property.access.spi.GetterFieldImpl.get(GetterFieldImpl.java:39)
Diving into the debugger, I tracked down to the method sun.reflect.UnsafeFieldAccessorImpl.ensureObj which perform a check via the method Class.isAssignableFrom between the classes
the class of the Field object (Field.getDeclaredClass())
the class of the entity to be persisted
This check returns false, due to the fact that the to classes have been loaded with different ClassLoaders (they are logically the same class).
How can I overcome this issue without changing the general layuot of the project (ie, keep the persistence unit as an EJB module to be shared across various modules)?
I believe, you might have included MyEntity class(or entities) in both ejb jar and war file and so they are getting loaded by both the class loaders. You may need to remove domain entities from war file and test it.
As per jboss docs, classes defined in ejb jar are available for classes in war file by default. And so they will loaded only once by ejb classloader only and will be used/available for classes in the war file as well.