Why would "java.lang.IllegalStateException: The resource configuration is not modifiable in this context." appear deploying Jersey app?

One possible cause is that you have two or more applicable mappings for that URL call.

For example:

@Path("/{myParam}")

And somewhere else:

@Path("/{differentParam}")

Now Jersey have no way of telling what method is actually supposed to be called and gives this error.


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>

I managed to 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

Environment: Netbeans 8.1, Apache Tomcat 8.0.12, JAX-RS 2.0 (Jersey 2.12)


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 :)


The above exception might be a consequence exception when Jersey cannot inject some user type into e.g. @QueryParam/@PathParam. E.g. you haven't registered your ParamConverterProvider. Look above in the logs, for the first exception trace.

I resolved my case with:

@Component public static class JerseyConfig extends ResourceConfig { public JerseyConfig() { this.register(LocalDateParamProvider.class); } }

(I use Spring.) When I inserted the above register() call, the exception has gone.