2 Replies Latest reply on Aug 25, 2011 8:34 PM by njiang

    Are these class loader issues

    rogelio_sevilla1

      Hello everyone:

       

      I have been getting a problem when i try to deploy certain bundles into Fuse ESB 4.4. Currently, I'm trying to use the unmarshall method from the Unmarshall class within the Castor plugin version 1.1 (http://www.castor.org/  , there are newer versions but i'm dealing with an old project) ,  my code look like this:

       

       

      Unmarshaller.unmarshal(MyProcessingConfig.class, reader);

       

       

      I have transformed and deployed the castor 1.1 jar file into a bundle using the bnd tool. The problem is that the previous line is throwing the next  exception on the karaf console:

       

       

      java.lang.RuntimeException: Could not instantiate parser org.apache.xerces.parsers.SAXParser: java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser not found by castor-1.1

           at org.exolab.castor.util.LocalConfiguration.getParser(LocalConfiguration.java:342)

           at org.exolab.castor.util.LocalConfiguration.getParser(LocalConfiguration.java:273)

           at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:711)

           at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:596)

           at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:817)

           at com.mycompany.MyProcessingConfig.unmarshal(MyProcessingConfig.java:306)

       

       

      This is telling me that the SaxParser class doesn't exist,however, when i run the command  packages:exports | grep org.apache.xerces.parsers

       

      I get the next output:

       

      146 org.apache.xerces.parsers; version=2.9.1

       

      Where bundle 146 comes with Fuse and shows as:

       

      apache ServiceMix Bundles: xercesImpl-2.9.1 (2.9.1.3)

       

       

      Also, just to make sure my castor bundle is importing the right bundles, i executed the command

       

      osgi:headers 187

       

      Where 187 is the id of my castor bundle and among the imports i can see the next output

       

       

             com.sun.org.apache.xml.internal.serialize;resolution:=optional,

           javax.naming;resolution:=optional,

           javax.naming.directory;resolution:=optional,

           javax.naming.spi;resolution:=optional,

           javax.sql;resolution:=optional,

           javax.swing;resolution:=optional,

           javax.swing.table;resolution:=optional,

           javax.transaction;resolution:=optional,

           javax.transaction.xa;resolution:=optional,

           javax.xml.parsers;resolution:=optional,

           net.sf.cglib.proxy;resolution:=optional,

              net.sf.ehcache;resolution:=optional,

           netscape.ldap;resolution:=optional,

           org.apache.commons.logging;resolution:=optional,

           org.apache.oro.text.regex;resolution:=optional,

           org.apache.regexp;resolution:=optional,

              org.apache.xerces.utils.regex;resolution:=optional,

           org.apache.xml.serialize;resolution:=optional,

              org.postgresql;resolution:=optional,

           org.w3c.dom;resolution:=optional,

           org.xml.sax;resolution:=optional,

           org.xml.sax.helpers;resolution:=optional,

              weblogic.apache.xml.serialize;resolution:=optional

       

       

      The bold lines appear in red in my karaf console,I think this means that those are not found, however, the javax.xml.parsers line appears in white. I have checked the xercesImpl  jar inside the  fuse's endorsed folder and the SaxParser class does exists.

       

       

      To be honest, I've found this error a couple of times but a still don't fully understand its nature. Any help with any of these issues would be highly appreciated:

       

       

      1.- Any advice on fixing the previous problem??

       

       

      2.-Sorry if this one is too basic; how can I tell between a fuse ESB class loader problem and an error that i introduced in my bundle dependencies

       

       

       

      Thanks a lot in advance, this has been my most common problem and any help on finding the right solution would be highly appreciated.

        • 1. Re: Are these class loader issues
          rogelio_sevilla1

          Sorry, i think i've been answering my own questions lately :P  sorry about that. I have explicitely added the import of the xerces package on the castor's manifest file and everything works fine now. 

           

          Just a question though... why does the  * operator on the import  section of the maven bundle plugin is not enough for the bundle to detect all the required packages???

          • 2. Re: Are these class loader issues
            njiang

            maven bundle plugin (or bnd tool) just check the class imports package, maybe there are some castor files don't import the xerces package explicitly.

             

            Willem