• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Caused by: java.lang.IllegalStateException: No modifications are allowed to a locked ParameterMap

 
srinivasarao govada
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

I have developed a web application. It's working fine with the Websphere. I have delpoyed the same application into the tomcat 6.0.14, the deployment was sucessful.
But i try to use some functionalities such as saving data after entering input to the page, it's throwing the following error message and the operation was failed.

Caused by: java.lang.IllegalStateException: No modifications are allowed to a locked ParameterMap
at org.apache.catalina.util.ParameterMap.put(ParameterMap.java:166)
at com.deere.u90.iaf.ejpm.utility.HttpServletRequestMapper.mapToBean(HttpServletRequestMapper.java:42)
... 25 more
Requesting you please let me know that what may be the mistake and provided solution.

Thanks,
Srinivas.

 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, you are not allowed to modify the ParameterMap - see javax.servlet.ServletRequest getParameterMap method - the map returned is immutable.

What I have done is create a new map that is a copy of the orginal ParameterMap and use that to store additional data.

Bill
 
srinivasarao govada
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Bill,

Thanks for your reply. I am able to run the same application successfully with the Web Sphere 6.1 server.

If i need to create a new map that is a copy of the orginal ParameterMap in Tomcat environment, then how can i do this. Please help me.

Thanks,

Srinivas.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18154
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
srinivasarao govada wrote:
Hi Bill,

Thanks for your reply. I am able to run the same application successfully with the Web Sphere 6.1 server.
.


That just means that WAS 6.1 isn't enforcing the J2EE standard. Just like writing into a WAR, for all intents and purposes, you're exploiting a bug in a particular implementation of a server. Because it's a standards violation, you can't expect to find that same loophole in other servers or even in other versions of the same server.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i need to create a new map that is a copy of the orginal ParameterMap in Tomcat environment, then how can i do this. Please help me.


Look at the JavaDocs for the API for the java.util.Map interface.

You can use the keySet method to obtain a collection of all of the key values as a Set.

Create a new Map object from one of the classes which implements Map - I typically use HashMap.

Iterate through the keySet - for each key, extract the value from the ParameterMap - the value is a String[] but just treat it as an object.
Store that value in the new Map using that key.

You now have a Map that contains all the original data but is not locked.

Bill
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18154
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless I'm mistaken, the code to replicate a map is already part of the Java collections API:

1. Construct a new Map (such as a HashMap)
2.. Use the putAll() method to copy the key/value pairs from the original map.

Regardless of how you do it, though, this is only a copy of the ParameterMap. The parameterMap in the HttpServletRequest object remains unchanged, as does the request object itself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic