For a standalone Java application, we are seeing very rare errors where Strings containing valid XML content are causing JAXB to throw exceptions like:
javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException:
<Line 1, Column 129>: XML-20221: (Fatal Error) Invalid char in text.]
This is a very old Java application, that was written for an older version of Java, and we have an existing dependency:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>xdb-xmlparser</artifactId>
<version>10.2.0.3.0</version>
</dependency>
The error code is consistently XML-20221, though the cause can vary, eg:
XML-20221: (Fatal Error) Invalid char in text.
XML-20100: (Fatal Error) Expected '?>'.]
XML-20121: (Fatal Error) End tag does not match start tag 'TotalDepositReqd'.
The rest of the stack trace also varies, but typically looks like:
at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:415)
at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:284)
at oracle.xml.parser.v2.NonValidatingParser.parseEndTag(NonValidatingParser.java:1359)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1304)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:326)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:293)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:209)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:211)
Our Java version is:
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Server VM (build 14.2-b01, mixed mode)
Our current command line is:
java
-server
-Xmx2048m
-Xms2048m
-XX:MaxPermSize=128m
-XX:+UseConcMarkSweepGC
-Dsun.rmi.dgc.server.gcInterval=0x2932E00
-Dsun.rmi.dgc.client.gcInterval=3600000
-verbosegc
-Xloggc:/path/to/file
-gc.log
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-Djavax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl
-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
-Djava.endorsed.dirs=/path/to/endorsed
-Duser.country=GB
-Duser.language=en
-Dhttp.keepAlive=false foo.ListenerServer
Typically we see these in small bursts that span a couple of seconds, which suggests to me that some internal buffer has become corrupted? These exceptions become more common the longer the JVM is up for. A bounce of the JVM resolves the issue for several days.
I've seen similar problems (sporadic exceptions during unmarshalling) when a developer cached Unmarshaller
instance and shared it between different threads. According to the documentation the Unmarshaller
is not thread safe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With