I am officially perplexed by this blocker.
I had upgraded Jersey from 2.4.1 to 2.5.1 because Jersey/Oracle fixed a package scanning bug that was affecting getting Swagger working. 2.4.1 was working relatively "okay" after lots of hacks to integrate with our Spring-based server (spring-jersey3 was not working at all.) Now since upgrading to 2.5.1 (and now, 2.6-SNAPSHOT), I receive the error below each time I make a request to anything matching the API URL pattern.
What I have done:
- Redeployed on a new, clean server (clean maven repository, clean tomcat, etc);
- Checked that the jar is the correct version (and even decompiled the "Value" class to ensure it was the one I see on GitHub that was updated ~2 months ago);
- Looked at all of the jars using tattletale to look for class conflicts;
- Upgraded to 2.6-SNAPSHOT (noted above), building the latest;
- Posted a bug (no response);
Help/work-arounds/debugging ideas much appreciated... don't even know what more I can do besides scrapping Swagger, a few days of work, and rolling back to 2.4.1
Feb 12, 2014 15:46:24 ERROR [TP-Processor6] [Catalina].[localhost].[/company
[Jersey REST Service] - Servlet.service() for servlet Jersey REST Service threw
exception java.lang.NoSuchMethodError:
org.glassfish.jersey.internal.util.collection.Values.lazy(Lorg/glassfish/jersey/internal/util
collection/Value;)Lorg/glassfish/jersey/internal/util/collection/Value;
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:372)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:335)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:218)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.company.videoapp.server.springframework.SessionFilter.doFilter(SessionFilter.java:44)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.company.videoapp.server.springframework.loader.ContextLoaderHttpInterceptor$LoaderState.filter(ContextLoaderHttpInterceptor.java:75)
at com.company.videoapp.server.springframework.loader.ContextLoaderHttpInterceptor$StartedState.filter(ContextLoaderHttpInterceptor.java:120)
at com.company.videoapp.server.springframework.loader.ContextLoaderHttpInterceptor.doFilter(ContextLoaderHttpInterceptor.java:62)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:311)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
at java.lang.Thread.run(Thread.java:662)
Update
I got rid of the ubiquitous 500
error, but I still get that exception. Here are some observations --
2.5.1 & 2.6-SNAPSHOT
Interfaces... inheritance... very buggy in 2.5.1+ (at least two regression bugs.)
My constant 500 errors were due to this, so after removing the interfaces I can at least hit a valid endpoint. Scenarios below:
Broken scenario #1 -- Implementing Resource Interface
@Path(MY_PATH)
@Produces(...)
@Consumes(...)
interface MyResource {
...
@GET myResourceMethod();
}
.
public class MyAwesomeResource implements MyResource {
...
}
Sending a request to the above resource results in a
404
exception, which in turn results in a500
for the client because of some unknown issue possibly related to the exception above.
Broken scenario #2 -- Making interface public
@Path(MY_PATH)
@Produces(...)
@Consumes(...)
public interface MyResource {
...
@GET myResourceMethod();
}
.
public class MyAwesomeResource implements MyResource {
...
}
Results in another
500
from an internal NoSuchMethodError exception (the one in the comment -- "Could not find a suitable constructor in MyResource.class") when issuing a request to the resource
The exception posted in the original question is masking real exceptions (404
becomes 500
... I have to remote debug to see the actual exception.)
Hope Jersey devs are paying attention to this. Not cool.
Based on informations provided in JERSEY-2394 your class-path contains these libraries:
You have 2 Jersey jars with different version than 2.5.1 -
jersey-media-multipart-2.1.jar
andjersey-container-servlet-core-2.1.jar
. The latter one causes the problem you have. Lines from the stacktrace correspond with the idea that 2.1 version of jersey servlet core is used instead of 2.5.1 (see WebComponent from 2.1). The solution would be to remove the old jars.