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
  2. 0

    That happens when I'm producing more than one kind of resource for the same entrypoint (@Produces({"application/xml","application/json"})) Sample project https://github.com/natros/resteasy-wadl-test {noformat} HTTP ERROR 500 Problem accessing /wadl. Reason: Server Error Caused by: java.lang.IllegalArgumentException: RESTEASY003340: Failure parsing MediaType string: application/xml,application/json at org.jboss.resteasy.plugins.delegates.MediaTypeHeaderDelegate.parse(MediaTypeHeaderDelegate.java:137) at org.jboss.resteasy.plugins.delegates.MediaTypeHeaderDelegate.fromString(MediaTypeHeaderDelegate.java:20) at javax.ws.rs.core.MediaType.valueOf(MediaType.java:179) at org.jboss.resteasy.wadl.ResteasyWadlServletWriter.createResponse(ResteasyWadlServletWriter.java:129) at org.jboss.resteasy.wadl.ResteasyWadlServletWriter.processWadl(ResteasyWadlServletWriter.java:111) at org.jboss.resteasy.wadl.ResteasyWadlServletWriter.writeWadl(ResteasyWadlServletWriter.java:52) at org.jboss.resteasy.wadl.ResteasyWadlServlet.service(ResteasyWadlServlet.java:61) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:817) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119) at org.eclipse.jetty.server.Server.handle(Server.java:517) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:306) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95) at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572) at java.lang.Thread.run(Thread.java:745) {noformat}

    JBoss Issue Tracker | 1 year ago | Filipe Sousa
    java.lang.IllegalArgumentException: RESTEASY003340: Failure parsing MediaType string: application/json,application/yaml

    2 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