Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

javax.xml.bind.UnmarshalException when trying to update Falcon entity

avatar
Rising Star

Hi,

we are using org.apache.falcon.client.FalconClient API to update Falcon process from java:

falconClient.update( EntityType.PROCESS.name(), <some-id>, <file-name>,true,doAs);

where the local <file-name> is created like this:

...
Marshaller marshaller = entityType.getMarshaller();
final File createTempFile = File.createTempFile(entityType.name().toLowerCase() + "_" + id, ".xml");
LOGGER.debug("Generated entity: {}", entity.toString());
marshaller.marshal(entity, createTempFile);
return createTempFile.getPath();

and sometimes the update fails with this error:

javax.xml.bind.UnmarshalException:
[org.xml.sax.SAXParseException; Premature end of file.]
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:335)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:523)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:220)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:189)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:157)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:204)
at org.apache.falcon.entity.parser.EntityParser.parse(EntityParser.java:94)
... 61 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.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)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:216)
... 65 more 

most of the updates pass, this error happens only sometimes, so I believe the file is created correctly on the client side and the error is caused possibly by some performance issue or race condition.

Have you seen this behavior?

Thanks,

Pavel

1 ACCEPTED SOLUTION

avatar

@Pavel Benes

Exception "javax.xml.bind.UnmarshalException: [org.xml.sax.SAXParseException; Premature end of file." can occur for various reasons. Its xml parser exception. Please ensure the entity xml generated correctly.

Quick google search will point you to various reasons why "Premature end of file" exception can occur. Can you attach the entity xml generated when this exception occurs?!

Thanks!

View solution in original post

3 REPLIES 3

avatar

@Pavel Benes

Exception "javax.xml.bind.UnmarshalException: [org.xml.sax.SAXParseException; Premature end of file." can occur for various reasons. Its xml parser exception. Please ensure the entity xml generated correctly.

Quick google search will point you to various reasons why "Premature end of file" exception can occur. Can you attach the entity xml generated when this exception occurs?!

Thanks!

avatar
Rising Star

Hi @Sowmya Ramesh,

thanks for your reply. You had definitely more luck with google since I could not find anything useful related to this exception and Falcon in particular.

I do not have the xml for failed request yet (logging added and waiting for the issue to happen again), but in general it looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <feed name="test-2-ALL-RELATIONSHIP" xmlns="uri:falcon:feed:0.1"> <frequency>days(1)</frequency> <clusters> <cluster name="dev-cluster" type="source"> <validity start="2016-03-14T00:00Z" end="2016-03-29T00:00Z"/> <retention limit="months(12)" action="delete"/> </cluster> </clusters> <table uri="catalog:test_2:ALL_RELATIONSHIP#mg_version=${YEAR}-${MONTH}-${DAY}-${HOUR}-${MINUTE}"/> <ACL owner="user@domain.COM"/> <schema location="/none" provider="none"/> <properties> <property name="queueName" value="mglauncher"/> </properties> </feed>

however I doubt that the error is caused by incorrect xml since it is generated automatically and the same operation is usually successful and fails only sometimes.

There is a code in org.apache.falcon.resource.AbstractEntityManager.deserializeEntity() method that does some logging when parsing fails:

if (LOG.isDebugEnabled() && xmlStream.markSupported()) { 
 try {
    xmlStream.reset();
    String xmlData = getAsString(xmlStream);
    LOG.debug("XML DUMP for ({}): {}", entityType, xmlData, e); 
  } catch (IOException ignore) {
     // ignore   
  }            
}

but I could not find anything like ""XML DUMP for" in our Falcon log. Is this fragment in log4j.xml Falcon conf file

   <logger name="org.apache.falcon" additivity="false">
       <level value="debug"/>
       <appender-ref ref="FILE"/>
   </logger>

enough to get this messages into log? I am not familiar with implementation so I am not sure whether the stream supports marking or not.

Regards and thanks for any input,

Pavel

avatar
Contributor

@Pavel Benes The error usually occurs because of the malformed xml. It would be helpful if you share the xml for the failed request when you have it. In the future, we'll log the input xml to ease the debug of similar errors.