I am trying to implement a Jax-RS(Jersey) which has a /upload end-point where user can upload images using Multipart. Project already has other parts implemented and working correctly, the problem occurs when I try to add Multipart feature.
I am using IntelliJ IDEA and Tomcat 8.5.xx to deploy my app.
My dependencies in pom.xml as follows;
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.25.1</version> <!-- 2.10.1 -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.25.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.25.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.42</version>
</dependency>
</dependencies>
And here is my web.xml part;
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value> org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
</init-param>
When I launch the WAR in Tomcat, it shows Internal Server Error 500 and in logs;
java.lang.IllegalStateException: The resource configuration is not modifiable in this context.
org.glassfish.jersey.server.ResourceConfig$ImmutableState.register(ResourceConfig.java:274)
org.glassfish.jersey.server.ResourceConfig$ImmutableState.register(ResourceConfig.java:221)
org.glassfish.jersey.server.ResourceConfig.register(ResourceConfig.java:453)
org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:387)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
I don't know what is the reason for the problem. From the name of the exception, I guess it is related with the MultipartFeature that is added by the web.xml. Yet, as I am not experienced enough and my searchs on google not resulted good, I need assistance from more experienced person.