title: Unable to pass @FormParam to jersey server with jersey 1.x and spring 4
body: <p>I am getting <strong>java.lang.IllegalArgumentException: Error parsing media type 'application/json, application/x-www-form-urlencoded'</strong> when trying to pass  <strong>x-www-form-urlencoded</strong> to resource class </p>
  
  <p><strong>Stack Trace</strong></p>
  
  <pre><code>javax.ws.rs.WebApplicationException: java.lang.IllegalArgumentException: Error parsing media type 'application/json, application/x-www-form-urlencoded'
      at com.sun.jersey.server.impl.model.HttpHelper.clientError(HttpHelper.java:265)
      at com.sun.jersey.server.impl.model.HttpHelper.getContentType(HttpHelper.java:91)
      at com.sun.jersey.server.impl.model.HttpHelper.getContentType(HttpHelper.java:77)
      at com.sun.jersey.spi.container.ContainerRequest.getMediaType(ContainerRequest.java:646)
      at com.sun.jersey.spi.container.servlet.WebComponent.filterFormParameters(WebComponent.java:832)
      at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:407)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652)
      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:445)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
      at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:556)
      at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1044)
      at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:372)
      at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189)
      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:978)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
      at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
      at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
      at org.eclipse.jetty.server.Server.handle(Server.java:367)
      at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:486)
      at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937)
      at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998)
      at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)
      at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
      at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
      at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.lang.IllegalArgumentException: Error parsing media type 'application/json, application/x-www-form-urlencoded'
      at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.fromString(MediaTypeProvider.java:79)
      at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.fromString(MediaTypeProvider.java:53)
      at javax.ws.rs.core.MediaType.valueOf(MediaType.java:119)
      at com.sun.jersey.server.impl.model.HttpHelper.getContentType(HttpHelper.java:89)
      ... 32 more
  Caused by: java.text.ParseException: Expected separator ';' instead of ','
      at com.sun.jersey.core.header.reader.HttpHeaderReader.nextSeparator(HttpHeaderReader.java:117)
      at com.sun.jersey.core.header.reader.HttpHeaderReader.readParameters(HttpHeaderReader.java:239)
      at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.valueOf(MediaTypeProvider.java:97)
      at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.fromString(MediaTypeProvider.java:77)
      ... 35 more
  Caused by:
  
  java.lang.IllegalArgumentException: Error parsing media type 'application/json, application/x-www-form-urlencoded'
      at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.fromString(MediaTypeProvider.java:79)
      at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.fromString(MediaTypeProvider.java:53)
      at javax.ws.rs.core.MediaType.valueOf(MediaType.java:119)
      at com.sun.jersey.server.impl.model.HttpHelper.getContentType(HttpHelper.java:89)
      at com.sun.jersey.server.impl.model.HttpHelper.getContentType(HttpHelper.java:77)
      at com.sun.jersey.spi.container.ContainerRequest.getMediaType(ContainerRequest.java:646)
      at com.sun.jersey.spi.container.servlet.WebComponent.filterFormParameters(WebComponent.java:832)
      at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:407)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652)
      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:445)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
      at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:556)
      at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1044)
      at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:372)
      at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189)
      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:978)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
      at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
      at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
      at org.eclipse.jetty.server.Server.handle(Server.java:367)
      at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:486)
      at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937)
      at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998)
      at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)
      at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
      at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
      at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.text.ParseException: Expected separator ';' instead of ','
      at com.sun.jersey.core.header.reader.HttpHeaderReader.nextSeparator(HttpHeaderReader.java:117)
      at com.sun.jersey.core.header.reader.HttpHeaderReader.readParameters(HttpHeaderReader.java:239)
      at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.valueOf(MediaTypeProvider.java:97)
      at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.fromString(MediaTypeProvider.java:77)
      ... 35 more
  Caused by:
  
  java.text.ParseException: Expected separator ';' instead of ','
      at com.sun.jersey.core.header.reader.HttpHeaderReader.nextSeparator(HttpHeaderReader.java:117)
      at com.sun.jersey.core.header.reader.HttpHeaderReader.readParameters(HttpHeaderReader.java:239)
      at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.valueOf(MediaTypeProvider.java:97)
      at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.fromString(MediaTypeProvider.java:77)
      at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.fromString(MediaTypeProvider.java:53)
      at javax.ws.rs.core.MediaType.valueOf(MediaType.java:119)
      at com.sun.jersey.server.impl.model.HttpHelper.getContentType(HttpHelper.java:89)
      at com.sun.jersey.server.impl.model.HttpHelper.getContentType(HttpHelper.java:77)
      at com.sun.jersey.spi.container.ContainerRequest.getMediaType(ContainerRequest.java:646)
      at com.sun.jersey.spi.container.servlet.WebComponent.filterFormParameters(WebComponent.java:832)
      at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:407)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652)
      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:445)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
      at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:556)
      at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1044)
      at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:372)
      at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189)
      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:978)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
      at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
      at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
      at org.eclipse.jetty.server.Server.handle(Server.java:367)
      at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:486)
      at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937)
      at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998)
      at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)
      at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
      at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
      at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p><strong>JAVA Resource Class code:</strong> </p>
  
  <pre><code>@Path("/initiate")
    @POST
    @Consumes({MediaType.APPLICATION_FORM_URLENCODED})
    public void initiate(@FormParam("id") String transactionId) throws IOException {
      logger.info("transactionId : " + transactionId);
      // some logic
  
    }
  </code></pre>
  
  <p><strong>pom.xml dependencies:</strong></p>
  
  <pre><code>&lt;!-- Jersey dependencies --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
        &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
        &lt;version&gt;1.13&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
        &lt;artifactId&gt;jersey-bundle&lt;/artifactId&gt;
        &lt;version&gt;1.13&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
        &lt;artifactId&gt;jersey-json&lt;/artifactId&gt;
        &lt;version&gt;1.13&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
        &lt;artifactId&gt;jersey-client&lt;/artifactId&gt;
        &lt;version&gt;1.13&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Jersey spring --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.sun.jersey.contribs&lt;/groupId&gt;
        &lt;artifactId&gt;jersey-spring&lt;/artifactId&gt;
        &lt;version&gt;1.13&lt;/version&gt;
        &lt;exclusions&gt;
          &lt;exclusion&gt;
            &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
            &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
          &lt;/exclusion&gt;
          &lt;exclusion&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring&lt;/artifactId&gt;
          &lt;/exclusion&gt;
          &lt;exclusion&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
          &lt;/exclusion&gt;
          &lt;exclusion&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
          &lt;/exclusion&gt;
          &lt;exclusion&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;/exclusion&gt;
          &lt;exclusion&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;/exclusion&gt;
          &lt;exclusion&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
          &lt;/exclusion&gt;
        &lt;/exclusions&gt;
      &lt;/dependency&gt;
  
  
      &lt;!-- Spring framework dependencies --&gt;
  
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
        &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
        &lt;version&gt;4.2.1.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
        &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
        &lt;version&gt;4.2.1.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
        &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
        &lt;version&gt;4.2.1.RELEASE&lt;/version&gt;
        &lt;type&gt;jar&lt;/type&gt;
        &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>I did a lot of google search but am unable to find a similar question and I am new to spring and jersey. Please help.</p>