Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-8417

Issue with loading JAXB library in JBOSS 4.3.0 with JDK6

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • No Release
    • JBossAS-4.2.1.GA
    • ClassLoading
    • None

      I am having ClassCastException when instantiating JAXBContext within my web application.

      javax.xml.bind.JAXBException: ClassCastException: attempting to cast jar:file:/C:/Documentum/jboss4.3.0/server/DctmServer_MethodServer/deploy/dfs.ear/APP-INF/lib/jaxb-api.jar!/javax/xml/bind/JAXBContext.class to jar:file:/C:/Documentum/jboss4.3.0/jdk/jre/lib/rt.jar!/javax/xml/bind/JAXBContext.class. Please make sure that you are specifying the proper ClassLoader.
      javax.xml.bind.ContextFinder.handleClassCastException(ContextFinder.java:96)
      javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:205)
      javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
      javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
      javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
      HelloWorldServlet.marshallCode(HelloWorldServlet.java:62)
      HelloWorldServlet.doGet(HelloWorldServlet.java:43)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

      Here is the line of code where the problem occurs:
      JAXBContext dataContext = JAXBContext.newInstance(MySimpleSouceData.class);

      Basically my web application (WAR) is deployed as part of an .EAR file with jaxb-api.jar and jaxb-impl.jar included in the .ear's APP-INF/lib. The web application does not have any of the JAXB libraries included in the .war file.

      The jboss-app.xml has been set to as follows:

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-app>
      <loader-repository>
      com.emc.documentum.fs:loader=emc-dfs.ear
      <loader-repository-config>
      java2ParentDelegation=false
      </loader-repository-config>
      </loader-repository>
      <library-directory>
      APP-INF/lib
      </library-directory>
      </jboss-app>

      I do not understand why the JAXBContext class instance from rt.jar (loaded by bootstrap/system classloader) is reference here when the configuration explicitly state to use the web application instance first (i.e. java2ParentDelegation=false).

      When I remove the jboss-app.xml file, the ClassCastException goes away. It seems the JAXBContext class is loaded by:

      org.jboss.mx.loading.UnifiedClassLoader3@2a2cc

      { url=file:/C:/Documentum/jboss4.3.0/server/DctmServer_MethodServer/deploy/jbossws.sar/ ,addedOrder=12}

      Is this a JBoss classloading bug?

      What actually happens when jboss-app.xml is not provided? What is the default behaviour? And how is it that ClassCastException does not happen here??

              starksm64 Scott Stark (Inactive)
              peklee_jira Pek Lee Seow (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated: