So I'm attempting to upgrade a Spring boot application to 2.1. I've got it running locally, but when deploying to Websphere 8.5.5.13, I'm getting a java linkage error. What I get from this is that this ConfigFileApplicationListener class has been loaded twice(one from gradle jars, one on server) and is conflicting? So my solution should be to exclude it from from gradle build? Only problem is I can't figure out what Spring dependency is pulling it in. Any suggestions?
R Caused by: java.lang.LinkageError: loading constraint violation
when overriding method "org/springframework/boot/context/config/
ConfigFileApplicationListener$DocumentFilterFactory.getDocumentFilter
(Lorg/springframework/boot/context/config/ConfigFileApplicationListener$Profile;)
Lorg/springframework/boot/context/config/ConfigFileApplicationListener$DocumentFilter;"
during creation of class "org/springframework/boot/context/config/ConfigFileApplicationListener
$Loader$$Lambda$762/000000002F6368A0": loader "java/lang/InternalAnonymousClassLoader#4b4313e6"
of class "org/springframework/boot/context/config/ConfigFileApplicationListener$Loader$$Lambda$762/000000002F6368A0"
and loader "com/ibm/ws/classloader/CompoundClassLoader#da9f4ecb" of class
"org/springframework/boot/context/config/ConfigFileApplicationListener$DocumentFilterFactory"
have different types for the method signature
The error was caused by a Websphere bug (https://issues.jboss.org/browse/RHDM-297). Upgrading to IBM JDK 8.0.5.10 fixes this issue.
Related
Im upgrading log4j from 1.x to 2.3. after setting up maven dependencies my project is builing and application is running fine.
But while builing, at test goal getting below mentioned error in variouse unit Test classes which are already there.
I could find a workaround by using #PowerMockIgnore. But worried of changing all the 100s of files which are already written.
ERROR StatusLogger Could not reconfigure JMX java.lang.LinkageError: loading constraint violation: loader "org/powermock/core/classloader/MockClassLoader#5fa95fa9" previously initiated loading for a different type with name "javax/management/MBeanServer" defined by loader "com/ibm/oti/vm/BootstrapClassLoader#7a5c7a5c".
#see Mockito + PowerMock LinkageError while mocking system class
Try adding this annotation to your Test class:
#PowerMockIgnore("javax.management.*")
Worked for me.
And worked for me as well
If you have many test classes and using powermock from version 1.7.0 you can specify a global config. See power mock configuration it comes with an example project where its use is demonstrated see example.
The configuration file should have:
powermock.global-ignore=javax.management.*
I am getting this error while trying to hit FullContact API server. I am using okhttp 2.7.5 and okhttp-urlconnection 2.7.5 and retrofit 1.9.0.
Caused by: java.lang.NoSuchMethodError: com.squareup.okhttp.internal.Internal.getHttpUrlChecked(Ljava/lang/String;)Lcom/squareup/okhttp/HttpUrl;
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.newHttpEngine(HttpURLConnectionImpl.java:339)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.initHttpEngine(HttpURLConnectionImpl.java:324)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:392)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:527)
at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
at com.fullcontact.api.libs.fullcontact4j.http.FCUrlClient.readResponse(FCUrlClient.java:148)
at com.fullcontact.api.libs.fullcontact4j.http.FCUrlClient.execute(FCUrlClient.java:91)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
... 7 more
This issue comes up only when you have incompatible versions of libraries /jars used for your code compilation than what you are using for runtime execution dependency.
Make sure you have the right version both places.
It could also be a case that you are compiling your source code by explicitly adding your library jars.
But at run time the server is loading the library class from a different version jar which is not having the required method.
Why do I get this error. I get it in my develpment tool when I run my code as a java application (IBM RSA\Eclipse) and in my isolated deployment environment.
I can run junits against the code and they are successful so I know that parsing the particular application context file is not a problem (web service application context). The same jre and maven dependencies are on the classpath for junit and running java application.
I know cxf uses java logger by default but adding this command doesn't help,
System.setProperty("org.apache.cxf.Logger", "org.apache.cxf.common.logging.Log4jLogger");
If I debug the code I see that the issue is raised when the application context files are parsed.
Caused by: org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.apache.cxf.jaxws.spring.NamespaceHandler] for namespace [http://cxf.apache.org/jaxws]: problem with handler class file or dependent class; nested exception is java.lang.NoClassDefFoundError: Could not initialize class java.util.logging.LogManager
The solution was to add this System property and provide the default file when running as a java app.
System.setProperty("java.util.logging.config.file", "/log/logging.properties");
http://www.javapractices.com/topic/TopicAction.do?Id=143
Now I have another problem but similar in nature so hopefully I can find a similar solution.
Caused by: java.lang.NoClassDefFoundError: Could not initialize class java.net.ProxySelector
I'm having hibernate3.jar and hibernate-core-4.2.0.CR1.jar in my classpath and I'm using Spring 3.1.3 version. Code got compiles sucessfully but while runtime I'm getting following error
2014-10-28 10:51:25,174 DEBUG [RMI TCP Connection(2)-10.126.30.203] -
Target method failed for RemoteInvocation: method name
'getPriceByKeys'; parameter types [java.util.List, java.util.Date]
java.lang.NoSuchMethodError:
org.hibernate.SessionFactory.openSession()Lorg/hibernate/Session;
I google it but not find any solution. Please note : My project needs hibernate3.jar but at the same time my project dependent on some other 3rd party jar which inturn using hibernet4.2.0 jar.
Any help Pls ??
You need to remove multiple hibernate JAR files from your classpath. Without doing this, your application may not work as you expect; which means you need to migrate the hibernate version of your application from 3 to 4.1.
Although Spring 3.1 uses Hibernate 3 JAR files, you can still migrate to Hibernate 4. Check out Spring blog gives a small tutorial to do so.
Migrating to Spring 3.1 and Hibernate 4.1
As part of the Core-Spring course, we have a lab application that we
use to show how to integrate Spring and JPA/Hibernate together. We
have just upgraded it to Spring 3.1 / Hibernate 4.1, and thought we
should share a few tips.
Just an update. The cause of problem is , I'm having two spring-context xml files in project (one of my project and one related to another module that I'm integrating). I'm loading context xmls from two different classes. So one of the DAO class loaded by one of spring-context xml not getting the hibernate Session.
Later on using import tag, I included 2nd spring application context file in 1st application context file and then loaded a Single application context file from the class. It solved the error.
Thanks,
While running the application I was getting the following errors.
java.lang.NoClassDefFoundError: Could not initialize class org.apache.axis2.description.AxisService
AxisService class is in axis2-kernel-1.6.2.jar file. Some of the classes from this jar are working fine without any issues, but some classes are throwing NoClassDefFoundError from this jar file at runtime. AxisService class is present in axis2-kernel-1.6.2.jar, even it throws error.
This is working fine in local machine. But error getting in Oracle r12 server.I have already set the class path for the jar file.
I am Using Java version is 1.6 and Apache axis2.1.6.2.
Had the same issue. I had included only jars that I needed to compile the application.
When I included everything from \axis2-1.6.2\lib\ folder, this exception were gone.
I had a similar problem using Tomcat and Axis2 and after a week finding out the error I realized there was a axis configuration problem. especifically my aplication can't instantiate the class which accedded to persistence layer. I include this parameter line:
<parameter name="ServiceTCCL">composite</parameter>
in services.xml file which is used by axis2 to work.
For more information see the comments in http://wso2.com/node/1131