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
Not sure if this is still a problem for you but I have recently come across the same issue. However, after digging further into my code I discovered that this error was being thrown because of the following method signature: public void parseData(@FormParam("data") Collection data)
Once I had tracked the error to this line, I did some googleing and discovered that using the @FormParam with Collection<> does not work.
The solution is to use List<> instead: public void parseData(@FormParam("data") List data)
Hopefully this will be helpful to anyone finding this post in the future as the error message is really not very useful!
Posting very late for anyone that stumbles across this problem. I had the exact same problem - worked locally in eclipse, but when I tried to deploy outside of Eclipse, it crashed and burned with the same stack trace in the question. The problem was due to double deployment of our webapps due to improper naming of the war files we were deploying.
When autoDeploy is set to true, tomcat expects a VERY specific naming convention of .war files that is related to the context path. For example, the context path “/foo/bar” must have a corresponding .war file named “foo#bar.war”. Additionally, a context path mapped to “/” or “” expects a war file called ROOT.war.
The complete naming rules can be found here: http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Naming
Fixing the names of the war files solved the problem.
I also want to note that, eventually, eclipse also choked on the issue for me. Occasionally, doing a clean of the project and trying to re-run will fix the problem, but not every time, and I'm not sure why it fixes it. I'm still trying to find a complete solution. Solving the problem for eclipse is a bit harder because (as far as I know) I can't specify the name of the directory where eclipse publishes the project. For example, a project in eclipse named "foo" whose context root is "bar/baz" will be published in a directory named "foo" rather than "bar#baz" and tomcat/Jersey does not seem to like that.
I hope this helps save someone the 12+ hours it took me and my team to debug this problem the night before a demo :)
I managed cause the same error, and this was due to two situations 1) The definition of paths within the resources ws MUST NOT start from a "/xyz" just be "xyz" to ResourceConfig @ApplicationPath ("/")
2) also occurs due to the dependence of any API (jar) in the .war project or tomcat/lib
3) It also occurs when there is ambiguity in the resource path (duplicates same name) is presented in the following log: "WARNING: A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by @Consumes and @Produces annotations at Java methods public javax.ws.rs.core.Response"
Netbeans 8.1, Apache Tomcat 8.0.12, JAX-RS 2.0 (jersey 2.12)
Try to undeploy the ROOT.war in the localhost:8080/manager e redeploy your WAR with this name (ROOT.war), then try again.
That worked for me.
I've experienced the same error message. I posted about it in my blog (spanish).
Reading the above answers and adding up my own experience I can tell that if you see this exception thrown it actually is an initialization problem. Look at syntax changes or code that is executed during initialization. Check your container logs (like catalina.out on Tomcat).
Another possible reason for getting that exception is if you try passing in a form parameter using @FormParam with an HTTP Get (@GET). It should complain since you cannot pass data in the form body with an HTTP Get. An example of code that would throw this exception is...
@GET
@Path("test-get")
@Consumes( MediaType.APPLICATION_FORM_URLENCODED )
public String testGet(@FormParam("name1") String name1) {