3 Replies Latest reply on Aug 27, 2007 5:27 AM by vickyk

    JCA Classloader issues

    pliljenberg1

      Java version: 1.5
      JBoss version: JBoss 4.2.0GA
      XFire version: 1.2.6

      I'm having trouble with JBoss and classloading (isolation?).
      I have an "architecture" like this:

      XFire Servlets for Webservices (packaged as WAR files, containing all JARs needed)
      JCA for integration with other systems (packaged as RAR files, containing all JARs needed)
      The WARs and RARs are then packaged in an EAR file which is deployed in JBoss (default).

      The Webservices use the JCA ConnectionFactory/Connection interfaces to access external systems.
      Here I encountered the first problem. The Webservices throws ClassCastException since the RAR file contains a JAR with the ConnectionFactory/Connection interfaces and the Webservice WAR contains the same.
      This seems to be a common problem with JCA(?) and the issue was resolved by removing the JAR from the WAR files, allowing JBoss to load it from the RAR file instead, which intuitively sounds like a bad design for Classloading?

      So now we have access to the JCA from the WAR files and it's seems just fine.
      Now we want integrate with an external system that is running Webservices, so we use XFire as a Client in a JCA connector.

      This results in a new ClassCastException when XFire tries to load its dependencies.
      XFire does Thread.currentThread().getContextClassLoader() to dynamically load classes, this returns the Webservice (our WAR) classloader, which is probably correct but all other classes in the context is loaded by the RAR classloader.

      java.lang.ClassCastException: org.codehaus.xfire.aegis.type.java5.DurationType
       at org.codehaus.xfire.aegis.type.DefaultTypeMappingRegistry.registerIfAvailable(DefaultTypeMappingRegistry.java:434)
      

      I'm getting the feeling that the JCA Connector architecture really sucks (or is it just with JBoss).
      JBoss does not allow me to package the interfaces in both the Connector RAR and the clients, which makes no sense at all - how is the JCA architecture supposed to work with distribution of interfaces?

      Googling for similar issues, JBoss classloading isolation seemed to be the solution to my problems.
      Tried to add jboss-app.xml to META-INF in the EAR file:
      <jboss-app>
       <loader-repository>com:example:loader=my-app.ear
       </loader-repository>
      </jboss-app>
      

      Using this I can't deploy my EAR file:
      java.lang.ClassNotFoundException: No ClassLoaders found for: integration.example.jca.ManagedConnectionFactoryImpl
       at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:212)
      


      Seems like it can't load the RAR file classes at all?

      * Is there a workaround for this?
      * How is classloading supposed to work with JCAs?