I am trying to generate an XSLX using Apache POI, but get this error when trying to run my TomCat application:
HTTP Status 500 - javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation: when resolving interface method
"org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument.copy()Lorg/apache/xmlbeans/XmlObject;"
the class loader (instance of org/apache/catalina/loader/WebappClassLoader)
of the current class,
org/apache/poi/POIXMLProperties,
and the class loader (instance of org/apache/catalina/loader/StandardClassLoader)
for resolved class, org/openxmlformats/schemas/officeDocument/x2006/extendedProperties/PropertiesDocument,
have different Class objects for the type ts.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument.copy()Lorg/apache/xmlbeans/XmlObject;
used in the signature
I am using POI 3.15. The POI JARs are stored in the common Tomcat7/lib folder. (poi-3.15.jar, poi-ooxml-3.15.jar, poi-ooxml-schemas-3.15.jar, xmlbeans-2.6.0.jar)
Can anyone help me explain what the conflict is here and how to resolve it?
In the WEB-INF lib I had put pretty much all relevant JAR files. It seems that xmlbeans (and possibly more) caused the conflict when they went along with the WAR afterwards.
But when cleaning up so I only had poi-3.15.jar and poi-ooxml-3.15.jar in the WEB-INF/lib, I got a situation where both the Eclise IDE and the TomCat runtime worked.
Related
What is the difference between class loading classes passed as part of PyFlink pipeline.classpath config and putting them into a $FLINK_HOME\lib directory?
When I want to use flink-sql-connector-kafka-*.jar it works fine just passing it using pipeline.classpath but when I want to use something that has some external dependencies like flink-avro-*.jar that needs avro-*.jar jars. It seems to load flink-avro-*.jar but it looks like it fails to load avro-*.jar and throws:
java.lang.NoClassDefFoundError: Could not initialize class org.apache.avro.SchemaBuilder
When I am dding avro-*.jar to $FLINK_HOME\lib it works just fine.
NoClassDefFoundError and ClassNotFoundException are different
java.lang.ClassNotFoundException This exception indicates that the
class was not found on the classpath. This indicates that we were
trying to load the class definition, and the class did not exist on
the classpath.
java.lang.NoClassDefFoundError This exception indicates that the JVM
looked in its internal class definition data structure for the
definition of a class and did not find it. This is different than
saying that it could not be loaded from the classpath. The point is,
a NoClassDefFoundError is not necessarily a classpath problem.
flink-sql-avro-*.jar is a shaded jar which will relocate the path of org.apache.flink:flink-avro org.apache.avro:avro
Judging from the NoClassDefFoundError, there may be a conflict between the avro version dependencies
I have a LinkageError in my EAR Project on Wildfly 10.1.
The project contains an ejb and a web subproject. Dependency Management by Maven. Gson Package is added in parent prom and in proms of both subprojects.
Can't figure out where the second gson class gets loaded. Any suggestions on how to solve this?
15:02:14,242 ERROR [io.undertow.request] (default task-2) UT005023:
Exception handling request to /Trigger-Server-web/event/quote:
java.lang.LinkageError: loader constraint violation: when resolving
interface method "de.company.triggerserver.ejb.EventProcessingLocal.processEvent(Ljava/lang/String;Lcom/google/gson/JsonObject;)Z" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, de/company/triggerserver/web/EventServlet, and the class loader (instance of org/jboss
/modules/ModuleClassLoader) for the method's defining class, de/company
/triggerserver/ejb/EventProcessingLocal, have different Class objects for the type com/google/gson/JsonObject used in the signature
This problem is caused by having a copy of the Gson jar in both the EAR/lib directory and the WEB-INF/lib directory of your WAR file.
Therefore the trick is to get rid of the one in the WAR file.
The simple solution is to mark it's dependency as <scope>provided</scope> in the web module's pom.xml file.
A more sophisticated approach is to make use of the maven-ear-plugin's ability to build EAR files with "skinny WARS" as described in Creating Skinny WARs. This essentially removes duplicate jar from your web module's WEB-INF/lib directory during the EAR assembly process.
You may find the second approach better because it's possible that you have multiple copies of other jars in your EAR file build, and you will be discovering these one at a time with the first approach.
exception loader constraint violation: when resolving method "org.apache.hadoop.io.IOUtils.cleanup(Lorg/apache/commons/logging/Log;[Ljava/io/Closeable;)V" the class loader (instance of weblogic/utils/classloaders/ChangeAwareClassLoader) of the current class, org/apache/hadoop/hdfs/FileInputStreamCache, and the class loader (instance of weblogic/utils/classloaders/GenericClassLoader) for resolved class, org/apache/hadoop/io/IOUtils, have different Class objects for the type org/apache/commons/logging/Log used in the signature
I get this when using the application, not when deploying the ear. If i understand this wright, i have two classloaders that have two different logging objects? how can i refer them both to one?
EDIT 1
After further investigation, I think this error is due to the fact we are using a common jars library and there is another version of commons there, making them conflict. Is there any way to specify weblogic to use a specific library and not packaging? I would like to investigate this further
You need to check the WEB-INF/lib directory of your WAR files to ensure that they do not contain jars that also exist in the EAR/lib directory.
Web apps will always use the WEB-INF/lib classes before looking for them in the EAR file. However, classes loaded from the EAR will only see the other classes in the EAR. If you have the same (or similar) jar file in both places this will lead to class loading issues such as you describe.
You will have to update your weblogic-application.xml to use the use the prefer-application-package to tell the web logic to use the jar from the web-inf/lib instead of the jar from web logic. refer to the link Weblogic 10.3.5 Overriding Spring Version
<weblogic-application>
<prefer-application-packages>
<package-name>org.apache.*</package-name>
<package-name>org.springframework.*</package-name>
</prefer-application-packages>
</weblogic-application>
in my application I have to call a webService using axis-1.4 libraries.
With axis-1.4.jar inside my application I get the following error:
Exception data: java.lang.NoClassDefFoundError: org.apache.axis.message.SOAPEnvelope (initialization failure)
This means (I think) that my jar conflicts with other libs in server (anyway I'm using Parent_Last class loading)
If I try to remove axis-1.4.jar from my ear, I get the following:
java.lang.ClassNotFoundException: org.apache.axis.soap.SOAPConstants
Does anyone knows which library is in conflict with axis-1.4.jar?
Thanks
You can easily find it yourself looking in RAD (if you have it) which JAR contains that classes. You can also try creating a shared library and third option: Extracting the classes you need from the library.
I'm new to webservices. I'm trying to call a service but I'm having the below error. Based on my initial google search seems this is a loader issue that can be caused by duplicate jars, but I cannot locate which one causes this. Any help is very much appreciated.
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) previously initiated loading for a different type with name "javax/xml/soap/SOAPMessage"
at org.apache.cxf.jaxws.support.JaxWsEndpointImpl.<init>(JaxWsEndpointImpl.java:126)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.createEndpoint(JaxWsServiceFactoryBean.java:208)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.createEndpoints(ReflectionServiceFactoryBean.java:366)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:297)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:178)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:100)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:102)
at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:115)
at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:437)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:316)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:303)
at javax.xml.ws.Service.getPort(Service.java:92)
What solved my problem is the duplicate saaj.jar in my projects.
LinkageError is JBoss is generally caused by your app packaging its own copies of certain libraries that JBoss considers restricted. These are usually things in the java.* and javax.* packages.
Try adding cxf-rt-frontend-jaxws and cxf-bundle-rs as dependencies and mark some exclusions -> jetty-server, gernomino-servlet.
Also check the beans.xml is expected to be under the classpath, instead of WEB-INF.