You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Aditya <ad...@gmail.com> on 2010/07/08 08:51:07 UTC

Service-mix classLoader Issues when combined with shared library.

Hey Guys,

I am bit confused with Service-mix class-loaders in 4.2. Although I read
this http://servicemix.apache.org/classloaders.html

here's what I am doing:

We are using shared library and referring the shared library in  Service
Units as below. 

In my xbean.xml of my SU.
<classpath>
	<library>eqcache</library>
</classpath>

eqcache is installed as shared library.

Now my rest of the settings in xbean.xml for Hibernate SessionFactory are as
below.

<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<!-- <property name="dataSource" ref="dartDataSource"/> -->

		<property name="hibernateProperties">
			<props>
				<prop
key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
				<prop
key="hibernate.connection.url">jdbc:mysql://192.168.5.511234/lic_training_20023423110
				</prop>
				<prop key="hibernate.connection.username">ssasdas</prop>
				<prop key="hibernate.connection.password">asdasds</prop>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect
				</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
				<prop key="hibernate.use_outer_join">true</prop>

				<prop key="hibernate.statement_cache.size">2000</prop>
				<prop key="hibernate.max_fetch_depth">5</prop>
				<prop key="hibernate.jdbc.batch_size">0</prop>
				<prop key="hibernate.connection.autocommit">false</prop>
				<!--
					Set the release mode to auto, so that the DB connections are
					released as soon as the transaction is complete.
				-->
				<prop key="hibernate.connection.release_mode">auto</prop>
			</props>
		</property>

		<property name="lobHandler" ref="defaultLobHandler" />
	</bean>

In the above properties when I deploy my SU notice the driver class in bold.
I get the error 

java.sql.SQLException: No suitable driver found for
jdbc:mysql://192.168.5.51/lic_training_200110

I tried Changing a few things and I came to know Classloader is unable to
load driver class and it searches for driver class in eqcache which is my
shared library and if I add driver dependency in my shared library
everything works not sure why though??


-- 
View this message in context: http://servicemix.396122.n5.nabble.com/Service-mix-classLoader-Issues-when-combined-with-shared-library-tp1044933p1044933.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Service-mix classLoader Issues when combined with shared library.

Posted by Freeman Fang <fr...@gmail.com>.
On 2010-7-9, at 下午6:19, Aditya wrote:

>
> Hey Freeman,
>
> Thanks for the reply but I am a bit confused now.
>
> I am facing the exact same Problem in 3.4 fuse. Just want to make  
> sure while
> setting the classpath to shared library are we setting the actual  
> class path
> to the shared library or we are just including the shared library in  
> the
> class path.
>
The classloader will search classes in that sharedlib, so I guess  
that's more similar as  "we are just including the shared library in the
class path" from your words.


> Cause currently what is happening his my class loader searches  
> everything in
> shared library.

If you put your driver lib as another items of <classpath>...</ 
classpath>, I believe the classloader will also search classes from it.

Freeman
>
> Thanks,
> Aditya
> -- 
> View this message in context: http://servicemix.396122.n5.nabble.com/Service-mix-classLoader-Issues-when-combined-with-shared-library-tp1044933p1045420.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.


-- 
Freeman Fang

------------------------
Open Source SOA: http://fusesource.com
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org


Re: Service-mix classLoader Issues when combined with shared library.

Posted by Aditya <ad...@gmail.com>.
Hey Freeman,

Thanks for the reply but I am a bit confused now.

I am facing the exact same Problem in 3.4 fuse. Just want to make sure while
setting the classpath to shared library are we setting the actual class path
to the shared library or we are just including the shared library in the
class path.

Cause currently what is happening his my class loader searches everything in
shared library.

Thanks,
Aditya
-- 
View this message in context: http://servicemix.396122.n5.nabble.com/Service-mix-classLoader-Issues-when-combined-with-shared-library-tp1044933p1045420.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Service-mix classLoader Issues when combined with shared library.

Posted by Freeman Fang <fr...@gmail.com>.
Ok, did you see the "New in Servicemix 4.2.0" part from [1],  from  
this way, you can refer mysql driver bundle in your SU.
In GSGi world generally you must specify which outside package is  
available for your own bundle, and the classloader used for your own  
bundle won't search all classes in OSGi evnironment.

[1]http://servicemix.apache.org/classloaders.html

Freeman
On 2010-7-8, at 下午3:04, Aditya wrote:

>
> Hey freeman,
>
> Sorry I didn't gave the complete INFO:
>
> I am shipping my old services(JBI Service Assemblies that worked in  
> 3.3) in
> 4.2 so yeah they include no Import as I am not deploying them as OSGI
> bundles rather I am deploying them as old zips of 3.3.
>
> Thanks,
> Aditya
> -- 
> View this message in context: http://servicemix.396122.n5.nabble.com/Service-mix-classLoader-Issues-when-combined-with-shared-library-tp1044933p1044937.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.


-- 
Freeman Fang

------------------------
Open Source SOA: http://fusesource.com
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org


Re: Service-mix classLoader Issues when combined with shared library.

Posted by Aditya <ad...@gmail.com>.
Hey freeman,

Sorry I didn't gave the complete INFO:

I am shipping my old services(JBI Service Assemblies that worked in 3.3) in
4.2 so yeah they include no Import as I am not deploying them as OSGI
bundles rather I am deploying them as old zips of 3.3.

Thanks,
Aditya
-- 
View this message in context: http://servicemix.396122.n5.nabble.com/Service-mix-classLoader-Issues-when-combined-with-shared-library-tp1044933p1044937.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Service-mix classLoader Issues when combined with shared library.

Posted by Freeman Fang <fr...@gmail.com>.
On 2010-7-8, at 下午2:51, Aditya wrote:

>
> Hey Guys,
>
> I am bit confused with Service-mix class-loaders in 4.2. Although I  
> read
> this http://servicemix.apache.org/classloaders.html
>
> here's what I am doing:
>
> We are using shared library and referring the shared library in   
> Service
> Units as below.
>
> In my xbean.xml of my SU.
> <classpath>
> 	<library>eqcache</library>
> </classpath>
>
> eqcache is installed as shared library.
>
> Now my rest of the settings in xbean.xml for Hibernate  
> SessionFactory are as
> below.
>
> <bean id="sessionFactory"
> 		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
> 		<!-- <property name="dataSource" ref="dartDataSource"/> -->
>
> 		<property name="hibernateProperties">
> 			<props>
> 				<prop
> key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
> 				<prop
> key="hibernate.connection.url">jdbc:mysql://192.168.5.511234/ 
> lic_training_20023423110
> 				</prop>
> 				<prop key="hibernate.connection.username">ssasdas</prop>
> 				<prop key="hibernate.connection.password">asdasds</prop>
> 				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect
> 				</prop>
> 				<prop key="hibernate.show_sql">true</prop>
> 				<prop key="hibernate.bytecode.use_reflection_optimizer">true</ 
> prop>
> 				<prop key="hibernate.use_outer_join">true</prop>
>
> 				<prop key="hibernate.statement_cache.size">2000</prop>
> 				<prop key="hibernate.max_fetch_depth">5</prop>
> 				<prop key="hibernate.jdbc.batch_size">0</prop>
> 				<prop key="hibernate.connection.autocommit">false</prop>
> 				<!--
> 					Set the release mode to auto, so that the DB connections are
> 					released as soon as the transaction is complete.
> 				-->
> 				<prop key="hibernate.connection.release_mode">auto</prop>
> 			</props>
> 		</property>
>
> 		<property name="lobHandler" ref="defaultLobHandler" />
> 	</bean>
>
> In the above properties when I deploy my SU notice the driver class  
> in bold.
> I get the error
>
> java.sql.SQLException: No suitable driver found for
> jdbc:mysql://192.168.5.51/lic_training_200110

Hi,

A quick question, did your su bundle import-package com.mysql.jdbc?

Freeman
>
> I tried Changing a few things and I came to know Classloader is  
> unable to
> load driver class and it searches for driver class in eqcache which  
> is my
> shared library and if I add driver dependency in my shared library
> everything works not sure why though??
>
>
> -- 
> View this message in context: http://servicemix.396122.n5.nabble.com/Service-mix-classLoader-Issues-when-combined-with-shared-library-tp1044933p1044933.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.


-- 
Freeman Fang

------------------------
Open Source SOA: http://fusesource.com
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org