Caused by: java.lang.NoSuchMethodError: com.squareup.okhttp.internal.Internal.getHttpUrlChecked - java

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.

Related

NoSuchMethodError in org.json.JSONObject after kubernetes upgrade from 1.21 to 1.23

I don't know if the kubernetes upgrade has anything to do with the problem, but it's the only change I know of between the time the application was working as expected and when it started throwing this exception.
I have some code in a Spring Boot app that adds a List<Object> to a JSONObject. The line looks like this:
jsonObject.put("some_name", someList);
This code hasn't been touched in a year, but suddenly started throwing this exception after a k8s upgrade from 1.21 to 1.23:
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: 'org.json.JSONObject org.json.JSONObject.put(java.lang.String, java.util.Collection)' at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1082)
[...]
Caused by: java.lang.NoSuchMethodError: 'org.json.JSONObject org.json.JSONObject.put(java.lang.String, java.util.Collection)' at com.example.service.MyClass.convertToJson(MyClass.java:109)
The k8s upgrade also included a change from Java 17.0.5+8 to Java 17.0.6+10, but everything runs as expected locally using both of those JDK versions.
I ran a mvn dependency tree -Dverbose and couldn't find anything weird there either. These were the only entries that had to do with json.
org.json:json:jar:20220320
org.springframework.boot:spring-boot-starter-json:jar:2.6.4
I'm out of ideas for what might be causing this issue, so any suggestions on what to look at next are welcome.
It could be that the version of org.json:json included in your project is out of date, and doesn't include the put(String, Collection) method you're trying to use. Try updating this dependency to a more recent version and seeing if that resolves the issue. It's also possible there are some other dependencies in your project which conflict with org.json:json or override it with an older version - check for any similarly named libraries (e.g., json-simple instead of org.json). You may also want to check the version of Spring Boot you're using, as this might be incompatible with the org.json library you're trying to use.

Java Springboot 2.1 java.lang.LinkageError

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.

Mule 3.7.3 and Jackson 2.9.0 issues-NoSuchMethodError

I am having lots of issues getting Mule to work with Jackson classes. The classes present in my final library only have the following files. To eliminate the possibility of maven pulling in other jackson libraries, I create a mule project without using maven and simply pull in the bare minimum libraries. However, it is failing with NoSuchMethodError for CSVMapper().reader(MyClass) etc. and later with
Caused by: java.lang.NoSuchMethodError:
com.fasterxml.jackson.databind.JsonMappingException.<init>
(Ljava/io/Closeable;Ljava/lang/String;)V
jackson-core-2.9.0.jar
jackson-databind-2.9.0.jar
jackson-annotations-2.9.0.jar
jackson-dataformat-csv-2.9.0.jar
I get NoSuchMethodError when I call methods that are definitely in the classpath. To make matters worse the program runs fine outside of Mule.
It turns out that the following module mule-core.3.7.3 has an older version of Jackson i.e. 2.4.3. Unfortunately what works with version 2.9.0 now fails with
Too many entries: expected at most 1 (value #1 (18 chars) "20170822211046.581")
How can solve this problem?
I solved it by using the Jackson libraries provided by Mule i.e. version 2.4.3 for converted JSON to Java objects. For the CSV conversion to Map I used apache commons-csv replacing Jackson's CSVMapper.

Getting Exception in thread "main" java.lang.VerifyError: class com.google.gwt.dev.HostedModeBase$ArgHandlerNoServerFlag

I am trying to upgrade my application from GWT 2.0 to 2.7.0 and getting below exception. I am using the below mentioned jars. What is the reason for this exception ? Is there any migration guide or document that i can refer for upgrading to 2.7 gwt version ?
Exception in thread "main" java.lang.VerifyError: class com.google.gwt.dev.HostedModeBase$ArgHandlerNoServerFlag overrides final method getPurpose.()Ljava/lang/String;
at java.lang.ClassLoader.defineClass1(Native Method)
Jars used :
gwt-user-2.7.0.jar
get-dev-2.7.0.jar
gwt-servlet-2.7.0.jar
gwt-dev-windows.jar
gwtext.jar
gwt-dev-windows.jar is an old dependency from pre-2.0 GWT (you should have already removed it when updating to 2.0 a while ago), and it conflicts here with the newer gwt-dev-2.7.0.jar.
BTW, unless you want to continue using "classic DevMode", you'll also need gwt-codeserver-2.7.0.jar.
Last, but not least, you'll likely have to update your GWT-Ext dependency as well.

WebSphere and Axis 1.4 - NoClassDefFoundError

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.

Categories