Could not find MessageBodyWriter for response object of type: com.sun.jersey.api.json.JSONWithPaddin


I'm trying to use jsonp on my backbone application. In my webservice, I'm trying to use the Jersey library to use the JSONWithPadding response.

Problem is, looks like the "application/x-javascript" is not supported.

My code is :

@GET @Path("/issues/jsonp") @Produces("application/x-javascript") public JSONWithPadding getIssuesJsonp(@Context HttpServletRequest req, @PathParam("ppid") String qppid, @QueryParam("callback") String callback) { Principal principal = req.getUserPrincipal(); String username = principal.getName(); try { List<IssueDTO> list = service.getIssuesDTO(username, qppid); IssuesResult r = new IssuesResult(); r.setIssues(list); System.out.println("CALLBACK:" + callback); return new JSONWithPadding(r,callback); } catch (Exception e) { String message = "Internal Server Error"; LOG.error(message, e); Result r = new Result(PPStatusCode.INTERNAL_SERVER_ERROR, message); return new JSONWithPadding(noCache(500, r),callback); } }

And the result is:

<strong>Etat HTTP 500 - Could not find MessageBodyWriter for response object of type: com.sun.jersey.api.json.JSONWithPadding of media type: application/javascript</strong>

Can someone help me ?

Edit: the full stacktrace:


18:52:33,243 WARN [org.jboss.resteasy.core.SynchronousDispatcher] (http-- Failed executing GET pp/fn/issues/jsonp: org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: com.sun.jersey.api.json.JSONWithPadding of media type: application/x-javascript at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:216) [resteasy-jaxrs-2.3.2.Final.jar:] at org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:585) [resteasy-jaxrs-2.3.2.Final.jar:] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:506) [resteasy-jaxrs-2.3.2.Final.jar:] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [resteasy-jaxrs-2.3.2.Final.jar:] at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.2.Final.jar:] at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.2.Final.jar:] at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.2.Final.jar:] at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:489) [jbossweb-7.0.13.Final.jar:] at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final] at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:] at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_11]




Based on the stacktrace it looks like Resteasy provided in JBoss is unable to find JSONWithPaddingProvider from jersey-json.jar which you have (I suppose) bundled in your WAR. JSONWithPadding is Jersey specific class and if you want to use it you have 2 options:

<ul><li>add Jersey libs to your WAR (if you don't have them there already) and disable Resteasy in web.xml as described in <a href="https://stackoverflow.com/a/12185880/290799" rel="nofollow">Deploying a Jersey webapp on Jboss AS 7</a> to make sure your application uses Jersey as JAX-RS implementation</li> <li>add jersey-json.jar to the JBoss classpath so Resteasy is able to find MessageBodyWriter (JSONWithPaddingProvider) located in this jar</li> </ul>


RestEasy also has the JacksonJsonpInterceptor already - if you are using Guice with RestEasy, you can bind(JacksonJsonpInterceptor.class) in an appropriate module, otherwise you will should configure it as normal for RestEasy (see <a href="https://docs.jboss.org/resteasy/docs/1.1.GA/userguide/html/Interceptors.html" rel="nofollow">https://docs.jboss.org/resteasy/docs/1.1.GA/userguide/html/Interceptors.html</a> section 29.6):


they can be listed in the resteasy.providers context-param in web.xml or returned as a class or object in the Application.getClasses() or Appication.getSingletons() method.



  • Group array according to the same element they have using javascript
  • How to handle Service unavailable scenarios with Jersey REST
  • Pure JerseyTest without letting Spring messing with services
  • resteasy-cdi - getting “Duplicate context initialization parameter resteasy.injector.factory” error
  • Jersey REST api multiple resources
  • Hibernate reverse engineering - mapping a table to Java enum
  • BackgroundMediaPlayer set Uri source of Media library item
  • ResponseBuilder is not working when used with entity object
  • Is it possible to control programs with Javascript?
  • Cannot update firebase version [duplicate]
  • JsonMappingException: Can not deserialize instance of java.lang.Integer out of START_OBJECT token
  • How do I listen to all Seam contextual events with parameterized names?
  • help('modules') crashing? Not sure how to fix
  • JSF2.0 + Primefaces 3.0.1 + jquery 1.6.4 + p:commandLink + IE8 throws Unexpected call to method or p
  • jersey/tomcat Description The origin server did not find a current representation for the target res
  • rewrite uppercase url to lowercase url htaccess
  • Hibernate to update table schema
  • Jetty 9 HashLoginService
  • Blackberry - Custom EditField Cursor
  • Installing Apache MyFaces 2 on WildFly 8.2.0
  • azure media services - The request body is too large and exceeds the maximum permissible limit
  • How to attach a node.js readable stream to a Sendgrid email?
  • Play WS (2.2.1): post/put large request
  • Android full screen on only one activity?
  • Django: Count of Group Elements
  • ImageMagick, replace semi-transparent white with opaque white
  • Cannot connect to cassandra from Spark
  • Different response to non-authenticated users and AJAX calls
  • Fetching methods from BroadcastReceiver to update UI
  • Java applet as stand-alone Windows application?
  • Cross-Platform Protobuf Serialization
  • Symfony2: How to get request parameter
  • Hazelcast - OperationTimeoutException
  • Alternatives to the OPTIONAL fallback SPARQL pattern?
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • GridView Sorting works once only
  • RestKit - RKRequestDelegate does not exist
  • Revoking OAuth Access Token Results in 404 Not Found
  • WPF Applying a trigger on binding failure
  • Is it possible to post an object from jquery to bottle.py?