1 Reply Latest reply on Dec 14, 2016 5:26 AM by fuinhaazul

    Wildfly 10.1 - JAXB Classloader

    fuinhaazul

      Hi there.

       

      Im going crazy with wildfly 10.1 classloader. Maybe somebody has any hints?

       

      I want to put all jaxb generated classes on modules as well some utility classes that uses these classes.

       

      I was succeded on the task until i created C.JAR, a utility jar that uses B.JAR JAXB classes.

       

      My structure today is:

       

      EAR (DEPENDENCIES: COM.MODULE1 EXPORT)

            WAR

                TestClass1.java (for testing - see below)

       

       

      COM.MODULE1:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <module xmlns="urn:jboss:module:1.3" name="com.module1">
        <resources>
        ...
        
        <resource-root path="A.jar" />
        <resource-root path="B.jar" />
        <resource-root path="C.jar" />
        </resources>
      
      
        <dependencies>
        <module name="com.jaspersoft" export="true"/>
        <module name="com.jbpm" export="true"/>
        <module name="org.apache.log4j" export="true"/>
        <module name="com.google.guava" export="true" />
        <module name="com.sun.xml.bind" export="true" />
        <module name="org.slf4j" export="true" />
        <module name="javax.api" export="true" />
        <module name="javax.xml.bind.api" export="true" />
        <module name="org.postgresql" export="true" />
        <module name="oracle.jdbc" export="true" />
        <module name="javax.faces.api" export="true" />
        <module name="org.apache.commons.io" export="true" />
        <module name="org.apache.commons.logging" />
        <module name="org.apache.commons.collections" export="true"/>
        <module name="org.apache.commons.lang" export="true" />
        <module name="org.apache.commons.beanutils" export="true" />
        </dependencies>
      </module>
      

       

       

       

      TestClass1.java

       

        // ------ STEP 1
        //This class is inside C.JAR
        //and parses a XML using JAXBContext.newInstance(PACKAGE NAME)
        //where the classes specified on PACKAGE NAME is inside B.JAR
        DIOrganizer diOrg = new DIOrganizer(diEl);
        diOrg.organize(XML_STRING);
      
      
        // ------- STEP 2
        //PARSES DIRECTLY using classes from A.JAR
        JAXBContext ctx = JAXBContext.newInstance(ANOTHER PACKAGE NAME);
        Marshaller marshaller = ctx.createMarshaller();
      

       

       

       

      The error I get is on step 1:

      Caused by: javax.xml.bind.JAXBException: Provider com.sun.xml.internal.bind.v2.ContextFactory not found
       - with linked exception:
      [java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory from [Module "deployment.XCape.ear.XCapeWeb.war:main" from Service Module Loader]]
        at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:146)
      

       

      If I add on the manifest:  com.sun.xml.bind services export, then the error occurs on step 2 (pass the step 1), and the exception is:

       

      java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to javax.xml.bind.JAXBContext: javax.faces.FacesException: #{backing.actionSaveDiagram}: java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to javax.xml.bind.JAXBContext
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
        at javax.faces.component.UICommand.broadcast(UICommand.java:315)
      

       

       

      Any help? the idea is to avoid sendind large .ear files with classes that will never change again (JAXB Classes)

       

      Thanks