I have created an app implementing REST services locally using:
Eclipse Indigo Jersey 2.4 Tomcat 7.0.47
When running locally using Eclipse, the services work
I got the same error message. For me the problem was, that I used @RequestMapping (a Spring annotation) instead of the @QueryParam (JAX-RS annotation) on a method argument due to a copy paste. The error message was not that informative, but that was the problem for me.
The issue in my case is that the shaded jar did not include the javassist
package that Jersey uses to do bytecode manipulation. When shading a jar, make sure to include org.javassist:*.
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.26.0-GA</version>
</dependency>
I solved this problem by adding this code into web.xml file
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
In my case, I had a Jersey POST resource for file uploads.
The resource specified the parameter:
@FormDataParam("file") InputStream file
and consumed MediaType.MULTIPART_FORM_DATA.
To fix the issue, I had to add the following to the Jersey REST configuration in my web.xml file:
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
</init-param>
In my case it was just a missing @PathParam("id")
for the 'int id' declaration.
Wrong code:
@POST
@Path("{id}/messages")
public Response returnMessages(int id, Message[] msgs) {
Corrected code:
@POST
@Path("{id}/messages")
public Response returnMessages(@PathParam("id") int id, Message[] msgs) {
Add
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>