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)

Java.net JIRA | mkarg | 8 years ago
  1. 0

    [Issue 154] New - PUT with empty body throws exception - mkarg - net.java.dev.jersey.issues - MarkMail

    markmail.org | 5 months ago
    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)
  2. 0

    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.

    Java.net JIRA | 8 years ago | mkarg
    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)
  3. 0

    JAXB xml tag in file starting with number, possible?

    Stack Overflow | 3 years ago | braincell
    org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    InputStream Exception While parsing

    Stack Overflow | 4 years ago | BKK
    org.xml.sax.SAXParseException: Premature end of file.]
  6. 0

    JAXB null element Premature End of File using UTF-16BE

    Stack Overflow | 3 years ago | filosofisto
    org.xml.sax.SAXParseException: Premature end of file.]

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. 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()
    2. Java RT
      AbstractUnmarshallerImpl.unmarshal
      1. javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(Unknown Source)
      2. javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(Unknown Source)
      2 frames