I can’t solve the following problem .. From what I’ve read about the solutions to this problem, I realized that there is a certain conflict between jars .. I can’t understand what kind of conflict .. I would be glad if someone corrected if I didn’t understand!

java.lang.NoSuchMethodError: com.sun.jersey.core.spi.component.ProviderServices.<init>(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.<init>(Client.java:172) at com.sun.jersey.api.client.Client.<init>(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); } 
  • at appl.test.ApplTest.main(ApplTest.java:25) well, it seems like everything goes from here. It would be nice to see the code. We look that there - probably something connected navreno with Client . We look from where the import of the conflict class is done. jersey-client-1.0.3.jar jersey-client.jar this the case of the same jarnik? - I. Smirnov
  • Smirnov I added a method with imports. - Maks.Burkov
  • Remove one of these jars and finally check! - Senior Pomidor
  • @ Maks.Burkov, I mentioned 2 jarnikas that seem to be the same, just one version isn’t affixed. Remove one of them (which is probably not a version) and check. - I. Smirnov
  • Tsovak Sahakyan .. relax, I realized .. - Maks.Burkov

1 answer 1

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

Apparently the problem is here. The contents of the jarns are the same, so the program cannot understand where to use the classes from. Therefore throws an exception java.lang.NoSuchMethodError

Remove jersey-client.jar and check.

  • After removing jersey-client.jar, I get an absolutely same error .. What could be wrong? - Maks.Burkov
  • A similar case .. stackoverflow.com/questions/19591811/ ... .. Perhaps the wrong version of the jar file .. I do not understand how to find out what kind of jar file ..? - Maks.Burkov
  • Smirnov. I also wanted to ask you. As a beginner, I cannot understand how to read this error log, which pops up, so that I can figure it out myself and leave the forum with questions. If there is any link to how to read the error log correctly, I will be glad if you can download it. - Maks.Burkov
  • @ Maks.Burkov, well, I found the truth in English. But it seems like a similar topic caught my eye. In general, everything is googled by the type of "how to read the stack trace" well, you can also specify the programming language) - I. Smirnov
  • @ Maks.Burkov, do you add jarniki with pens or through maven or the like? There is still an assumption that simply not all needed jarniki added. - I. Smirnov