java.lang.UnsupportedOperationException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Calls to VelocityEngineUtils.mergeTemplateIntoString using a Collections.singletonMap as the model fail with the following exception: java.lang.UnsupportedOperationException at java.util.AbstractMap.put(AbstractMap.java:186) at org.apache.velocity.VelocityContext.internalPut(VelocityContext.java:132) at org.apache.velocity.context.AbstractContext.put(AbstractContext.java:164) at org.apache.velocity.context.InternalContextAdapterImpl.put(InternalContextAdapterImpl.java:269) at org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:213) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336) at org.apache.velocity.Template.merge(Template.java:328) at org.apache.velocity.Template.merge(Template.java:235) at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:381) at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:345) at org.springframework.ui.velocity.VelocityEngineUtils.mergeTemplate(VelocityEngineUtils.java:58) at org.springframework.ui.velocity.VelocityEngineUtils.mergeTemplateIntoString(VelocityEngineUtils.java:122) ... Turns out that internally, Velocity tries to modify the map by calling methods that are not supported by the map implementation returned by Collections.singletonMap. I don't know if this should be considered a Spring issue, a Velocity issue, or a non-issue (but nothing in either Spring's or Velocity's docs warn against using immutable maps for the model). Possible fixes: - On Spring's side, create a new map containing the old map and pass it as the model, i.e. use "VelocityContext velocityContext = new VelocityContext(new HashMap(model));" in VelocityEngineUtils - Same thing, but on Velocity's side, when creating the VelocityContext - Leave to the user the responsibility to pass a mutable map, but mention it explicitly in the doc What do you think?
    via by Florent Robineau,
  • Calls to VelocityEngineUtils.mergeTemplateIntoString using a Collections.singletonMap as the model fail with the following exception: java.lang.UnsupportedOperationException at java.util.AbstractMap.put(AbstractMap.java:186) at org.apache.velocity.VelocityContext.internalPut(VelocityContext.java:132) at org.apache.velocity.context.AbstractContext.put(AbstractContext.java:164) at org.apache.velocity.context.InternalContextAdapterImpl.put(InternalContextAdapterImpl.java:269) at org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:213) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336) at org.apache.velocity.Template.merge(Template.java:328) at org.apache.velocity.Template.merge(Template.java:235) at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:381) at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:345) at org.springframework.ui.velocity.VelocityEngineUtils.mergeTemplate(VelocityEngineUtils.java:58) at org.springframework.ui.velocity.VelocityEngineUtils.mergeTemplateIntoString(VelocityEngineUtils.java:122) ... Turns out that internally, Velocity tries to modify the map by calling methods that are not supported by the map implementation returned by Collections.singletonMap. I don't know if this should be considered a Spring issue, a Velocity issue, or a non-issue (but nothing in either Spring's or Velocity's docs warn against using immutable maps for the model). Possible fixes: - On Spring's side, create a new map containing the old map and pass it as the model, i.e. use "VelocityContext velocityContext = new VelocityContext(new HashMap(model));" in VelocityEngineUtils - Same thing, but on Velocity's side, when creating the VelocityContext - Leave to the user the responsibility to pass a mutable map, but mention it explicitly in the doc What do you think?
    via by Florent Robineau,
  • Failed to retrieve Session from FacesContext
    via Stack Overflow by Stephan
    ,
  • EofException
    via by Unknown author,
    • java.lang.UnsupportedOperationException at java.util.AbstractMap.put(AbstractMap.java:186) at org.apache.velocity.VelocityContext.internalPut(VelocityContext.java:132) at org.apache.velocity.context.AbstractContext.put(AbstractContext.java:164) at org.apache.velocity.context.InternalContextAdapterImpl.put(InternalContextAdapterImpl.java:269) at org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:213) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336) at org.apache.velocity.Template.merge(Template.java:328) at org.apache.velocity.Template.merge(Template.java:235) at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:381) at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:345) at org.springframework.ui.velocity.VelocityEngineUtils.mergeTemplate(VelocityEngineUtils.java:58) at org.springframework.ui.velocity.VelocityEngineUtils.mergeTemplateIntoString(VelocityEngineUtils.java:122)

    Users with the same issue

    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,