I\'m trying to run a jersey client and facing this issue.
WS Class:
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
im
In my case I was not pulling in the jersey-core jar as a runtime dependency. Once i added it seemed to work fine.
For followers, these (with mockito in this instance, but kind of generic):
java.lang.NoClassDefFoundError: com/sun/jersey/spi/inject/Errors$Closure
java.lang.NoClassDefFoundError: com/sun/jersey/core/header/LinkHeaders
meant "you have a dependency on jersey-core 1.0.2 and also dependency on jersey-client 1.11" (need to match core with client versions more closely). Unfortunately "server" and "client" both use the "core" so in the end they practically all have to precisely match up :|
Generally you would get this problem when your code compiled against jersey-bundle-1.8.jar and jsr311-api-0.9.jar. But here I can see you are using jsr311-api-1.1.1.jar
. Then next problem would be older jar file would have been loaded by the application/web server. For eg: GlassFish 3.1 one comes with Jersy 1.5( which may take precedence over your libraries).
Ideally you would need to check version of JSR-311 library is loaded (0.9 version of the jsr311-api jar is obsolete) in the server. And you should compile against jersey-bundle-1.8.jar, and run with jersey-bundle-1.8.jar and jsr311-api-1.1.1.jar