You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by techy_bolek <te...@yahoo.com> on 2010/09/05 03:26:58 UTC

Class not found for third party jars bundled with my custom service engine

This class not found problem may be related to another problem I've described
here
http://servicemix.396122.n5.nabble.com/Service-Mix-3-3-1-unable-to-find-org-apache-servicemix-common-DefaultComponent-tp2802977.html.

I'm using Service Mix 3.3.1. I should mention that I used to have this
working with ServiceMix 3.1.1 incubating and now I'm trying to upgrade to
Service Mix 3.3.1.

My custom service engine has a few third party jar dependencies. I've
installed those jars in my local maven repo and specified the dependencies
in my pom.xml for example:

        <dependency>
            <groupId>org.mythirdparty.oracle</groupId>
            <artifactId>xmlparserv2</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
         

The service engine builds correctly. When I inspect the generated
installer.zip file I see that all third party jars are bundled in the lib
directory. Also here is my jbi.xml:

JBi xmlns="http://java.sun.com/xml/ns/jbi" version="1.0">
  <component type="binding-component"
component-class-loader-delegation="parent-first"
bootstrap-class-loader-delegation="parent-first">
    <shared-library version="2009.01">servicemix-shared</shared-library>
    <identification>
      <name>myAQ</name>
      <description>A custom project</description>
    </identification>
    <component-class-name>com.myAQ.MyComponent</component-class-name>
    <component-class-path>
      <path-element>lib/myAQ-1.0-SNAPSHOT</path-element>
      <path-element>lib/xmlparserv2-1.0-SNAPSHOT.jar</path-element>
      ......
    </component-class-path>
   
<bootstrap-class-name>org.apache.servicemix.common.DefaultBootstrap</bootstrap-class-name>
    <bootstrap-class-path>
      <path-element>lib/myAQ-1.0-SNAPSHOT.jar</path-element>
      <path-element>lib/xmlparserv2-1.0-SNAPSHOT.jar</path-element>
    </bootstrap-class-path>
  </component>
</jbi>




However upon deploy I see an error that a class from one of the bundled jars
cannot be found for example:
<loc-message>Could not deploy xbean service unit</loc-message>
</msg-loc-info>
</task-status-msg>
                        <exception-info>
                                <nesting-level>1</nesting-level>
                                <msg-loc-info>
                                        <loc-token/>
                                       
<loc-message>oracle/xml/parser/v2/XMLParseException</loc-message>
                                       
<stack-trace><![CDATA[java.lang.NoClassDefFoundError:
oracle/xml/parser/v2/XMLParseException

I see that the jar containing the class is present in the data subdirectory:
./data/smx/components/myAQ/version_1/lib/xmlparserv2-1.0-SNAPSHOT.jar


What am I missing? It seems like Service Mix 3.3.1 has some more
sophisticated and more strict rules for the effective runtime classpath
settings than 3.1.1?
Tom

-- 
View this message in context: http://servicemix.396122.n5.nabble.com/Class-not-found-for-third-party-jars-bundled-with-my-custom-service-engine-tp2803809p2803809.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Class not found for third party jars bundled with my custom service engine

Posted by techy_bolek <te...@yahoo.com>.
In case anybody's interested, downgraded to version 3.2.3 (was using 3.3.1)
and all we issues went away.
-- 
View this message in context: http://servicemix.396122.n5.nabble.com/Class-not-found-for-third-party-jars-bundled-with-my-custom-service-engine-tp2803809p2852074.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Class not found for third party jars bundled with my custom service engine

Posted by techy_bolek <te...@yahoo.com>.
Just to document my wrestling with this issue, I noticed the auto-generated
jbi.xml has parent-first for both bootstrap and component class loader
delegation.

<component type="service-engine"
component-class-loader-delegation="parent-first"
bootstrap-class-loader-delegation="parent-first">

When I changed it to 'self-first' I got a different error. Still not
resolution to either but gives me at least a little bit of food for thought.

<component type="service-engine"
component-class-loader-delegation="self-first"
bootstrap-class-loader-delegation="self-first">

-- 
View this message in context: http://servicemix.396122.n5.nabble.com/Class-not-found-for-third-party-jars-bundled-with-my-custom-service-engine-tp2803809p2851719.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Class not found for third party jars bundled with my custom service engine

Posted by techy_bolek <te...@yahoo.com>.
I sure did, not knowing much about the issue, that was one of the first
things I've tried...
Any other suggestions?
-- 
View this message in context: http://servicemix.396122.n5.nabble.com/Class-not-found-for-third-party-jars-bundled-with-my-custom-service-engine-tp2803809p2839809.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Class not found for third party jars bundled with my custom service engine

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Did you try to put the xmlparserv2.jar directly in the ServiceMix lib 
directory (in the system classloader) ?

Regards
JB

On 09/14/2010 05:17 PM, techy_bolek wrote:
>
> Anyone? It really seems like a classloader issue to me, read
> http://servicemix.apache.org/classloaders.html but still have not been able
> to get it to work. I'd really appreciate some help.
> Tom
>
>

Re: Class not found for third party jars bundled with my custom service engine

Posted by techy_bolek <te...@yahoo.com>.
Anyone? It really seems like a classloader issue to me, read
http://servicemix.apache.org/classloaders.html but still have not been able
to get it to work. I'd really appreciate some help.
Tom


-- 
View this message in context: http://servicemix.396122.n5.nabble.com/Class-not-found-for-third-party-jars-bundled-with-my-custom-service-engine-tp2803809p2839294.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Class not found for third party jars bundled with my custom service engine

Posted by techy_bolek <te...@yahoo.com>.
By now I have actually put xmlparserv2 in all places I could think of - SE
dependency, SU dependency and lib/optional. Like I said I can find the class
OK as long as I'm using the same classloader as is used for deploy. However,
when Oracle tries to load the class using java.net.URLClassLoader.
For all classes that are loaded by the normal loader specifying the
dependency in the service engine was enough.
Tom

-- 
View this message in context: http://servicemix.396122.n5.nabble.com/Class-not-found-for-third-party-jars-bundled-with-my-custom-service-engine-tp2803809p2834912.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Class not found for third party jars bundled with my custom service engine

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

You should have the xmlparserv2.jar (Oracle XML Parser) in the 
dependencies set of your SU or in the main ServiceMix classpath (in 
lib/optional for example).

Regards
JB

On 09/09/2010 11:26 PM, techy_bolek wrote:
>
> Ok I'm begining to suspect it's may something to do with the class loader.
> The error is thrown when I'm actually trying to create an Oracle AQ receiver
> with XML payload. The method probably tries to dynamically load the class
> using a different class loader that was used to set the classpath. Note the
> classoader name, java.net.URLClassLoader:
>
>
>          java.lang.ClassNotFoundException:
> oracle.xml.parser.v2.XMLParseException
>          at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>          at java.security.AccessController.doPrivileged(Native Method)
>          at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>          at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>          at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>          at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>
>
> aqs.createReceiver(queue, XMLType.getORADataFactory());<----- will throw
> this error
>
> When I try to manually instantiate XMLParseException directly from my code
> I'm not getting this problem:
>
> XMLParseException e = new XMLParseException("bolek", "bolek", "bolek", 1, 1,
> 1);<--- will not throw an error
>
>
> Now look at the classloader output when initializing the component's
> classpath. Note the classloader name is different,
> org.apache.xbean.classloader.JarFileClassLoader:
>
> Component class loader: [org.apache.xbean.classloader.JarFileClassLoader:
> name=Component ClassLoader
> urls=[file:/project/tapestry/3p_sandbox/apache-servicemix-3.
> 3.1/data/smx/components/AQBC-tapestry/version_1/lib/AQBC-tapestry-8.1.1.0.jar,
> file:/project/tapestry
> /3p_sandbox/apache-servicemix-3.3.1/data/smx/components/AQBC-tapestry/version_1/lib/jmscommon-1.0-SNA
> PSHOT.jar,
> file:/project/tapestry/3p_sandbox/apache-servicemix-3.3.1/data/smx/components/AQBC-tapestr
> y/version_1/lib/xmlparserv2-1.0-SNAPSHOT.jar,
> file:/project/tapestry/3p_sandbox/apache-servicemix-3.3
> .1/data/smx/components/AQBC-tapestry/version_1/lib/jta-1.0-SNAPSHOT.jar,
> file:/project/tapestry/3p_sa
> ndbox/apache-servicemix-3.3.1/data/smx/components/AQBC-tapestry/version_1/lib/aqapi-1.0-SNAPSHOT.jar,
> file:/project/tapestry/3p_sandbox/apache-servicemix-3.3.1/data/smx/components/AQBC-tapestry/version_
> 1/lib/classes12-1.0-SNAPSHOT.jar,
> file:/project/tapestry/3p_sandbox/apache-servicemix-3.3.1/data/smx/
> components/AQBC-tapestry/version_1/lib/jndi-1.0-SNAPSHOT.jar,
> file:/project/tapestry/3p_sandbox/apach
> e-servicemix-3.3.1/data/smx/components/AQBC-tapestry/version_1/lib/xdb-1.0-SNAPSHOT.jar]
> parents=[org .codehaus.classworlds.RealmClassLoader@da6bf4]]
>
>
>
> Thoughts? I feel like I'm on the right track with this because other than
> that all the classes from third party jars seem to be available.
>

Re: Class not found for third party jars bundled with my custom service engine

Posted by techy_bolek <te...@yahoo.com>.
Ok I'm begining to suspect it's may something to do with the class loader.
The error is thrown when I'm actually trying to create an Oracle AQ receiver
with XML payload. The method probably tries to dynamically load the class
using a different class loader that was used to set the classpath. Note the
classoader name, java.net.URLClassLoader:


        java.lang.ClassNotFoundException:
oracle.xml.parser.v2.XMLParseException
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)


aqs.createReceiver(queue, XMLType.getORADataFactory()); <----- will throw
this error

When I try to manually instantiate XMLParseException directly from my code
I'm not getting this problem:

XMLParseException e = new XMLParseException("bolek", "bolek", "bolek", 1, 1,
1); <--- will not throw an error


Now look at the classloader output when initializing the component's
classpath. Note the classloader name is different,
org.apache.xbean.classloader.JarFileClassLoader:

Component class loader: [org.apache.xbean.classloader.JarFileClassLoader:
name=Component ClassLoader
urls=[file:/project/tapestry/3p_sandbox/apache-servicemix-3.
3.1/data/smx/components/AQBC-tapestry/version_1/lib/AQBC-tapestry-8.1.1.0.jar,
file:/project/tapestry
/3p_sandbox/apache-servicemix-3.3.1/data/smx/components/AQBC-tapestry/version_1/lib/jmscommon-1.0-SNA
PSHOT.jar,
file:/project/tapestry/3p_sandbox/apache-servicemix-3.3.1/data/smx/components/AQBC-tapestr
y/version_1/lib/xmlparserv2-1.0-SNAPSHOT.jar,
file:/project/tapestry/3p_sandbox/apache-servicemix-3.3
.1/data/smx/components/AQBC-tapestry/version_1/lib/jta-1.0-SNAPSHOT.jar,
file:/project/tapestry/3p_sa
ndbox/apache-servicemix-3.3.1/data/smx/components/AQBC-tapestry/version_1/lib/aqapi-1.0-SNAPSHOT.jar, 
file:/project/tapestry/3p_sandbox/apache-servicemix-3.3.1/data/smx/components/AQBC-tapestry/version_
1/lib/classes12-1.0-SNAPSHOT.jar,
file:/project/tapestry/3p_sandbox/apache-servicemix-3.3.1/data/smx/
components/AQBC-tapestry/version_1/lib/jndi-1.0-SNAPSHOT.jar,
file:/project/tapestry/3p_sandbox/apach
e-servicemix-3.3.1/data/smx/components/AQBC-tapestry/version_1/lib/xdb-1.0-SNAPSHOT.jar]
parents=[org .codehaus.classworlds.RealmClassLoader@da6bf4]]



Thoughts? I feel like I'm on the right track with this because other than
that all the classes from third party jars seem to be available.

-- 
View this message in context: http://servicemix.396122.n5.nabble.com/Class-not-found-for-third-party-jars-bundled-with-my-custom-service-engine-tp2803809p2834186.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Class not found for third party jars bundled with my custom service engine

Posted by techy_bolek <te...@yahoo.com>.
I'm still stuck here. Any help would be appreciated. Thanks, Tom.
-- 
View this message in context: http://servicemix.396122.n5.nabble.com/Class-not-found-for-third-party-jars-bundled-with-my-custom-service-engine-tp2803809p2807841.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.