com.sun.jersey.api.container.ContainerException: Exception injecting parameters to Web resource method at com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider$EntityParamInInvoker.getParams(EntityParamDispatchProvider.java:103) at com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider$VoidOutInvoker._dispatch(EntityParamDispatchProvider.java:116) at com.sun.jersey.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:81)

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Some HTTP clients are sending empty bodies in PUTs. e. g. Microsoft's "WebDAV-Mini-Redirector" does this: It first sends a PUT with Content-Length=0 and an empty (zero bytes) body, and if that returns 200 OK it sends another PUT with "correct" concent-length and full body; seems to be some kind of safety or performance optimization. This is not a problem as long as you have a @PUT method that has no receiving argument for the body, or the receiving argument is not treated by Jersey's implied JAXB support. But if you have a @PUT method that has a parameter of a JAXB element type, then Jersey's implied JAXB support starts parsing the body (it ignores the Content-Length=0) header and stumbles over the zero-byte body: com.sun.jersey.api.container.ContainerException: Exception injecting parameters to Web resource method at com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider$EntityParamInInvoker.getParams(EntityParamDispatchProvider.java:103) at com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider$VoidOutInvoker._dispatch(EntityParamDispatchProvider.java:116) at com.sun.jersey.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:81) at com.sun.jersey.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:133) at com.sun.jersey.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111) at com.sun.jersey.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71) at com.sun.jersey.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111) at com.sun.jersey.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:64) at com.sun.jersey.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:669) at com.sun.jersey.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:631) at com.sun.jersey.impl.container.httpserver.HttpHandlerContainer.handle(HttpHandlerContainer.java:167) at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source) at sun.net.httpserver.AuthFilter.doFilter(Unknown Source) at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source) at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(Unknown Source) at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source) at sun.net.httpserver.ServerImpl$Exchange.run(Unknown Source) at sun.net.httpserver.ServerImpl$DefaultExecutor.execute(Unknown Source) at sun.net.httpserver.ServerImpl$Dispatcher.handle(Unknown Source) at sun.net.httpserver.ServerImpl$Dispatcher.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.IllegalArgumentException: java.io.IOException: Error marshalling out JAXB object of type "class mk.jpa.Article". at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:239) at com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider$EntityInjectable.getValue(EntityParamDispatchProvider.java:79) at com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider$EntityParamInInvoker.getParams(EntityParamDispatchProvider.java:97) ... 20 more Caused by: java.io.IOException: Error marshalling out JAXB object of type "class mk.jpa.Article". at com.sun.jersey.impl.provider.entity.XMLRootElementProvider.readFrom(XMLRootElementProvider.java:80) at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:237) ... 22 more Caused by: javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax.SAXParseException: Premature end of file.] at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unknown Source) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(Unknown Source) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(Unknown Source) at com.sun.jersey.impl.provider.entity.XMLRootElementProvider.readFrom(XMLRootElementProvider.java:78) ... 23 more Caused by: org.xml.sax.SAXParseException: Premature end of file. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) ... 28 more As a PUT with an empty body and Content-Length=0 is a valid HTTP request, Jersey should be stable enough not to throw this exception. Instead, the injected variable should just be set to null to indicate the missing body. It is up to the application to decide how to further deal with this CORRECT request.
    via by mkarg,
    • com.sun.jersey.api.container.ContainerException: Exception injecting parameters to Web resource method at com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider$EntityParamInInvoker.getParams(EntityParamDispatchProvider.java:103) at com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider$VoidOutInvoker._dispatch(EntityParamDispatchProvider.java:116) at com.sun.jersey.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:81) at com.sun.jersey.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:133)
    No Bugmate found.