Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat: No modifications are allowed to a locked ParameterMap

Got sick of this annoying error:

java.lang.IllegalStateException: No modifications are allowed to a locked ParameterMap
at org.apache.catalina.util.ParameterMap.put(ParameterMap.java:164)
at org.springframework.data.rest.webmvc.RestRepositoryEntityController.getParametersForPostAction(RestRepositoryEntityController.java:182)
at org.springframework.data.rest.webmvc.RestRepositoryEntityController.performPostAction(RestRepositoryEntityController.java:158)
at org.springframework.data.rest.webmvc.RestRepositoryEntityController.performOneArgumentPostRepositoryAction(RestRepositoryEntityController.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:410)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:337)

I'm getting this after trying to access some rest resources. Everything works fine on production, so I suppose there are some tomcat problems on my local pc. Spend two hours trying to find answers but didn't succeed.

Did anyone occurred with same error? Need help!

like image 725
John Korch Avatar asked Dec 11 '22 13:12

John Korch


1 Answers

It might be because you are assigning request.getParameterMap() any of the variable. Instead of that try using

Map<String, String[]> map = new HashMap<>(request.getParameterMap());

which will only create a copy of it.

Sometimes this may solve your problem

like image 104
noyal_asok Avatar answered Feb 23 '23 14:02

noyal_asok