javax.servlet.ServletException: java.lang.IllegalArgumentException: Failure parsing MediaType string: application/xhtml+xml application/pdf

JBoss Issue Tracker | Evgeny Denisov | 7 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    RestEasy throws java.lang.IllegalArgumentException when processing GET request with ACCEPT mediatype string: "application/xhtml+xml application/pdf": javax.servlet.ServletException: java.lang.IllegalArgumentException: Failure parsing MediaType string: application/xhtml+xml application/pdf at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:74) at org.jboss.seam.resteasy.ResteasyResourceAdapter.getResource(ResteasyResourceAdapter.java:121) at org.jboss.seam.servlet.SeamResourceServlet.service(SeamResourceServlet.java:80) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427) at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:875) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:560) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382) at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:549) at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:438) at org.apache.catalina.core.StandardHostValve.postInvoke(StandardHostValve.java:249) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:649) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288) at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647) at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579) at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831) at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341) at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263) at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214) at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380) at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265) at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106) Caused by: java.lang.IllegalArgumentException: Failure parsing MediaType string: application/xhtml+xml application/pdf at org.jboss.resteasy.plugins.delegates.MediaTypeHeaderDelegate.parse(MediaTypeHeaderDelegate.java:42) at org.jboss.resteasy.plugins.delegates.MediaTypeHeaderDelegate.fromString(MediaTypeHeaderDelegate.java:18) at javax.ws.rs.core.MediaType.valueOf(MediaType.java:226) at org.jboss.resteasy.util.MediaTypeHelper.parseHeader(MediaTypeHelper.java:204) at org.jboss.resteasy.plugins.server.servlet.ServletUtil.extractAccepts(ServletUtil.java:119) at org.jboss.resteasy.plugins.server.servlet.ServletUtil.extractHttpHeaders(ServletUtil.java:82) at org.jboss.seam.resteasy.ResteasyResourceAdapter$1.process(ResteasyResourceAdapter.java:127) at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:53) ... 31 more This error occures regularly when processing requests from some WEB-crawlers. It should be "HTTP Error 400 Bad request" instead.

    JBoss Issue Tracker | 7 years ago | Evgeny Denisov
    javax.servlet.ServletException: java.lang.IllegalArgumentException: Failure parsing MediaType string: application/xhtml+xml application/pdf

    1 unregistered visitors

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      Failure parsing MediaType string: application/xhtml+xml application/pdf

      at org.jboss.resteasy.plugins.delegates.MediaTypeHeaderDelegate.parse()
    2. RESTEasy JAX-RS Implementation
      MediaTypeHeaderDelegate.fromString
      1. org.jboss.resteasy.plugins.delegates.MediaTypeHeaderDelegate.parse(MediaTypeHeaderDelegate.java:42)
      2. org.jboss.resteasy.plugins.delegates.MediaTypeHeaderDelegate.fromString(MediaTypeHeaderDelegate.java:18)
      2 frames
    3. JavaEE 7
      MediaType.valueOf
      1. javax.ws.rs.core.MediaType.valueOf(MediaType.java:226)
      1 frame
    4. RESTEasy JAX-RS Implementation
      ServletUtil.extractHttpHeaders
      1. org.jboss.resteasy.util.MediaTypeHelper.parseHeader(MediaTypeHelper.java:204)
      2. org.jboss.resteasy.plugins.server.servlet.ServletUtil.extractAccepts(ServletUtil.java:119)
      3. org.jboss.resteasy.plugins.server.servlet.ServletUtil.extractHttpHeaders(ServletUtil.java:82)
      3 frames
    5. org.jboss.seam
      SeamResourceServlet.service
      1. org.jboss.seam.resteasy.ResteasyResourceAdapter$1.process(ResteasyResourceAdapter.java:127)
      2. org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:53)
      3. org.jboss.seam.resteasy.ResteasyResourceAdapter.getResource(ResteasyResourceAdapter.java:121)
      4. org.jboss.seam.servlet.SeamResourceServlet.service(SeamResourceServlet.java:80)
      4 frames
    6. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
      1 frame
    7. Glassfish Core
      ContainerBase.invoke
      1. org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
      2. org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:875)
      3. org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
      4. org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:560)
      5. org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
      6. org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
      7. org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:549)
      8. org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:438)
      9. org.apache.catalina.core.StandardHostValve.postInvoke(StandardHostValve.java:249)
      10. org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:649)
      11. org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
      12. org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
      13. org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
      14. org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
      15. org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
      16. org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
      17. org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
      18. org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
      18 frames
    8. org.apache.coyote
      CoyoteAdapter.service
      1. org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
      1 frame
    9. Glassfish Core
      DefaultReadTask.doTask
      1. com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647)
      2. com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579)
      3. com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
      4. com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
      5. com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
      6. com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
      6 frames
    10. Grizzly HTTP
      PortUnificationPipeline$PUTask.doTask
      1. com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
      1 frame
    11. Glassfish Core
      TaskBase.run
      1. com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
      1 frame
    12. Grizzly HTTP
      SSLWorkerThread.run
      1. com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
      1 frame