1 Reply Latest reply on Oct 13, 2014 12:45 PM by j l

    JBoss Gotcha with JAXB and Stax 1.0.1

    Jon Kranes Newbie

      I recently solved a problem that I had when porting a working web application from Tomcat 6 to JBoss AS 5.1.0,GA


      The observed symptom was that the application, deployed on Jboss, throws com.sun.xml.bind.v2.runtime.IllegalAnnotationsExceptions, with the message "javax.xml.namespace.QName does not have a no-arg default constructor".  The exception is thrown when calling




      After much hair-pulling I finally traced the problem to the inclusion of the Stax-api 1.0.1 jar in my application.  This jar was included as an indirect dependency from Apache XMLBeans 2.4.0.  The problem was solved by excluding the Stax dependency in my maven pom.xml file.  The root cause of the problem is presumably related to the fact that the Stax 1.0.1 jar file includes a version of javax.xml.namespace.QName, which is also included in the 1.6 JRE.  Apparently this version of QName does not play nice with JAXB.


      Note that this problem did not appear when deploying the exact same .war file in either Tomcat 6.18 or in GlassFish 2.1.1 running under the same 1.6.0_17 JDK that I was running for JBoss AS.  So presumably there is some difference in the JBoss classloader that caused it to load the QName class from the Stax API jar while the other servers loaded it from the JRE rt.jar.