Home java java.lang.NoSuchMethodError

java.lang.NoSuchMethodError

Author

Date

Category

I can’t solve the following problem ..
From what I read about the solutions to this problem, I realized that there is a certain conflict between jars .. I can not understand which one is in conflict ..
I would be glad if someone fixes it if I don’t understand it!

java.lang.NoSuchMethodError: com.sun.jersey.core.spi.component.ProviderServices. & lt; init & gt; (Lcom / sun / jersey / core / spi / factory / InjectableProviderFactory; Lcom / sun / jersey / core / spi / component / ProviderFactory; Ljava / util / Set; Ljava / util / Set;) V
at com.sun.jersey.api.client.Client. & lt; init & gt; (Client.java:172)
at com.sun.jersey.api.client.Client. & lt; init & gt; (Client.java:139)
at com.sun.jersey.api.client.Client.create (Client.java:416)
at appl.test.ApplTest.main (ApplTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (Unknown Source)
at java.lang.reflect.Method.invoke (Unknown Source)
at org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall (FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run (ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively (FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate (InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf (ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild (BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild (BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner $ 3.run (ParentRunner.java:290)
at org.junit.runners.ParentRunner $ 1.schedule (ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren (ParentRunner.java:288)
at org.junit.runners.ParentRunner.access $ 000 (ParentRunner.java:58)
at org.junit.runners.ParentRunner $ 2.evaluate (ParentRunner.java:268)
at org.junit.runners.ParentRunner.run (ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run (TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (RemoteTestRunner.java:192)

Here are my Jars from Web Content ..

hamcrest-all-1.3.jar
jahk2-api-2.4.0-b34.jar
hk2-locator-2.4.0-b34.jar
hk2-utils-2.4.0-b34.jar
jackson-annotations-2.3.2.jar
jackson-core-2.3.2.jar
jackson-databind-2.3.2.jar
jackson-jaxrs-base-2.3.2.jar
jackson-jaxrs-json-provider-2.3.2.jar
jackson-module-jaxb-annotations-2.3.2.jar
javax.inject-2.4.0-b34.jar
javax.ws.rs-api-2.0.1.jar
jersey-client-1.0.3.jar
jersey-client.jar
jersey-common.jar
jersey-container-servlet-core.jar
jersey-container-servlet.jar
jersey-core-1.8.jar
jersey-entity-filtering-2.17.jar
jersey-guava-2.22.2.jar
jersey-media-jaxb.jar
jersey-media-json-jackson-2.17.jar
jersey-server.jar
junit-4.12.jar
validation-api-1.1.0.Final.jar

main method:

import org.junit.Test;
   import com.sun.jersey.api.client.Client;
   import com.sun.jersey.api.client.WebResource;
   import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
   import service.Service;
public class ApplTest {
private static final String URL = "http: // localhost: 8080 / rest / calculations";
private static final String INT_R = "/ integerCalculation";
private static final String DOUBLE_R = "/ fractionalValues";
int integer = 12;
double d = 4.5;
     @Test
     public void main () {
   ClientConfig config = new DefaultClientConfig ();
   Client client = Client.create (config);
   WebResource resource = client.resource (URL);
   WebResource one = resource.path (INT_R + integer);
   WebResource two = resource.path (DOUBLE_R + d);
   new Service (). IntegerValueService (one);
}

Answer 1, authority 100%

jersey-client-1.0.3.jar
jersey-client.jar

By all appearances, the problem is here.
the contents of the jarniks are the same, so the program cannot figure out where to use the classes. Therefore, it throws an exception java.lang.NoSuchMethodError

Remove jersey-client.jar and check.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions