Announcement Announcement Module
Collapse
No announcement yet.
Content Negotiation NPE in Spring 3.2 and Tomcat 6.0.26 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Content Negotiation NPE in Spring 3.2 and Tomcat 6.0.26

    Has anyone run into this? I haven't found anything on the intertubes yet, and haven't run remote debugging (yet...)
    ----------------
    I've run into an issue where I've configured Spring MVC 3.2 with the following:

    Code:
      <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
        <property name="favorParameter" value="true" />
        <property name="favorPathExtension" value="true" />
        <property name="defaultContentType" value="application/json" />
        <property name="ignoreAcceptHeader" value="true" />
        <property name="useJaf" value="true" />
        <property name="mediaTypes">
          <value>
            json=application/json
            xml=application/xml
          </value>
        </property>
      </bean>
    But, I'm getting an NPE when deploying the war to Tomcat 6.0.20. (Works fine in Jetty). Also, I'm running in Java7.

    The issue appears to be how the Parameter based content negotiation is talking to Tomcat to get data off the request. I'm testing using rest-shell, so I know the requests are the same to both tomcat and jetty, and I'm doing a simple GET request. My expectation is that the request falls back to the defaultContentType configuration, but the NPE comes earlier.

    Here's the stack trace:
    Code:
    2012-12-31 13:19:38.190 [http-8080-1] ERROR c.r.b.s.e.CustomExceptionMapper - Returning exception to client:
    java.lang.NullPointerException: null
    	at java.util.Hashtable.hash(Hashtable.java:262) ~[na:1.7.0_06]
    	at java.util.Hashtable.get(Hashtable.java:459) ~[na:1.7.0_06]
    	at org.apache.tomcat.util.http.Parameters.getParameterValues(Parameters.java:194) ~[tomcat-coyote.jar:na]
    	at org.apache.tomcat.util.http.Parameters.getParameter(Parameters.java:239) ~[tomcat-coyote.jar:na]
    	at org.apache.catalina.connector.Request.getParameter(Request.java:1042) ~[catalina.jar:na]
    	at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:355) ~[catalina.jar:na]
    	at org.springframework.web.context.request.ServletWebRequest.getParameter(ServletWebRequest.java:113) ~[spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    	at org.springframework.web.accept.ParameterContentNegotiationStrategy.getMediaTypeKey(ParameterContentNegotiationStrategy.java:60) ~[spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    	at org.springframework.web.accept.AbstractMappingContentNegotiationStrategy.resolveMediaTypes(AbstractMappingContentNegotiationStrategy.java:46) ~[spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    	at org.springframework.web.accept.ContentNegotiationManager.resolveMediaTypes(ContentNegotiationManager.java:102) ~[spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    	at org.springframework.web.servlet.mvc.condition.ProducesRequestCondition.getAcceptedMediaTypes(ProducesRequestCondition.java:238) ~[spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    	at org.springframework.web.servlet.mvc.condition.ProducesRequestCondition.access$000(ProducesRequestCondition.java:47) ~[spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    	at org.springframework.web.servlet.mvc.condition.ProducesRequestCondition$ProduceMediaTypeExpression.matchMediaType(ProducesRequestCondition.java:305) ~[spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    	at org.springframework.web.servlet.mvc.condition.AbstractMediaTypeExpression.match(AbstractMediaTypeExpression.java:69) ~[spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    	at org.springframework.web.servlet.mvc.condition.ProducesRequestCondition.getMatchingCondition(ProducesRequestCondition.java:185) ~[spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    	at org.springframework.web.servlet.mvc.method.RequestMappingInfo.getMatchingCondition(RequestMappingInfo.java:175) ~[spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    	at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.getMatchingMapping(RequestMappingInfoHandlerMapping.java:68) ~[spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    	at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.getMatchingMapping(RequestMappingInfoHandlerMapping.java:50) ~[spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.addMatchingMappings(AbstractHandlerMethodMapping.java:278) ~[spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(AbstractHandlerMethodMapping.java:245) ~[spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:212) ~[spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:55) ~[spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    Last edited by mgirard; Dec 31st, 2012, 03:20 PM.

  • #2
    I have the same problem with tomcat 6.0.14 :-(

    Comment


    • #3
      created a jira bug: https://jira.springsource.org/browse/SPR-10139

      Comment

      Working...
      X