You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by "vincent.z" <vi...@steria.com> on 2013/03/03 11:48:59 UTC

Karaf - Hibernate/c3p0 Issue - ClassLoadingException

Hello,

Once again, a ClassLoadingException issue on Karaf bundles; but with c3p0
this time.
I've read all posts about ClassLoadingException and JDBC drivers but I have
not found a solution for my problem

I use Karaf 2.2.6 and I have a Persistance bundle (bundle 1079) for loading
a hibernate.cfg.xml, creating a HibernateSession singleton with a c3p0
connection pool.

*hibernate.cfg.xml*
/<hibernate-configuration>
	<session-factory>
		<property
name="hibernate.connection.url">jdbc:postgresql://localhost:5432/db</property>
		<property name="hibernate.connection.username">user</property>
		<property name="hibernate.connection.password">pass</property>
		*<property
name="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property>*	
		<property name="hibernate.c3p0.min_size">5</property>
		<property name="hibernate.c3p0.max_size">20</property>
		<property name="hibernate.c3p0.timeout">300</property>
		<property name="hibernate.c3p0.max_statements">50</property>
		<property name="hibernate.c3p0.idle_test_period">3000</property>
		<property
name="hibernate.connection.driver_class">org.postgresql.Driver</property>
		<property name="hibernate.default_schema">public</property>
		<property
name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
		<property name="current_session_context_class">thread</property>
		<property
name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
		<property
name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
		<property name="javax.persistence.validation.mode">none</property>
		<property name="show_sql">false</property>
		<mapping class="com.proj.article.Article" />
[...]
	</session-factory>
</hibernate-configuration>/

I've deployed Hibernate bundles from com.springsource and c3p0 bundle too.

karaf@trun> list
START LEVEL 100 , List Threshold: 50
   ID   State         Blueprint      Spring    Level  Name
[...]
[ 547] [Active     ] [            ] [       ] [   80] Javassist Java
Programming Assistant (3.15.0.GA)
[ 548] [Active     ] [            ] [       ] [   80] ANTLR (2.7.7)
[ 549] [Active     ] [            ] [       ] [   80] FasterXML ClassMate
(0.5.4)
[ 550] [Active     ] [            ] [       ] [   80] Java Bean Validation
API (1.0.0.GA)
[ 551] [Active     ] [            ] [       ] [   80] JBoss Jandex
(1.0.3.Final)
[ 552] [Active     ] [            ] [       ] [   80] Apache ANT (1.8.1)
[ 553] [Active     ] [            ] [       ] [   80] Apache Commons
Collections (3.2.1)
[ 554] [Active     ] [            ] [       ] [   80] JBoss Hibernate
Object-Relational Mapper (4.1.0.Final)
                                       Fragments: 555
[ 555] [Resolved   ] [            ] [       ] [   80] JBoss Hibernate Entity
Manager (4.1.0.Final)
                                       Hosts: 554
[ 556] [Active     ] [            ] [       ] [   80] Java Persistence API
(2.0.0)
[ 557] [Active     ] [            ] [       ] [   80] JBoss Hibernate Common
Annotations (4.1.0.Final)
[ 558] [Active     ] [            ] [       ] [   80] JBoss Logging 3
(3.1.0.GA)
[ 995] [Active     ] [            ] [       ] [   50] Apache ServiceMix ::
Bundles :: commons-httpclient (3.1.0.7)
[ 996] [Active     ] [            ] [       ] [   50] Commons Codec (1.4)
[ 997] [Active     ] [            ] [       ] [   50] camel-http (2.9.2)
[ 998] [Active     ] [            ] [       ] [   50] camel-jetty (2.9.2)
[1042] [Active     ] [            ] [       ] [   80] c3p0 Connection Pool
(0.9.1)
[1076] [Active     ] [            ] [       ] [   82] :COMM: Communs
(0.0.1.SNAPSHOT)
[1079] [Active     ] [            ] [Failed ] [   91] :PROJ: Persistance
(0.0.1.SNAPSHOT)

The HibernateSession java class is in the Common bundle (1076) which imports
Hibernate dependencies and C3P0 dependency. The bundle exports the
HibernateSession java package

karaf@trun> packages:exports 1076
    ID Packages                                
  1076 com.proj.communs.csv; version="0.0.1.SNAPSHOT"
  1076 com.proj.communs.exceptions; version="0.0.1.SNAPSHOT"
  1076 com.proj.communs.utils; version="0.0.1.SNAPSHOT"
  1076 com.proj.communs.xml; version="0.0.1.SNAPSHOT"
*  1076 com.proj.communs.persistance; version="0.0.1.SNAPSHOT"*
  1076 com.proj.communs.enums; version="0.0.1.SNAPSHOT"
  1076 com.proj.communs.ressources; version="0.0.1.SNAPSHOT"
karaf@trun> packages:imports 1076
OSGi System Bundle (0): javax.xml.validation; version="0.0.0"
OSGi System Bundle (0): org.xml.sax; version="0.0.0"
OPS4J Pax Logging - API (3): org.slf4j; version="1.6.4"
OPS4J Pax Logging - API (3): org.slf4j; version="1.6.1"
OPS4J Pax Logging - API (3): org.slf4j; version="1.5.11"
OPS4J Pax Logging - API (3): org.slf4j; version="1.4.3"
Spring Core (81): org.springframework.core.io; version="3.0.7.RELEASE"
Spring Beans (84): org.springframework.beans.factory.config;
version="3.0.7.RELEASE"
Spring Context (86): org.springframework.context; version="3.0.7.RELEASE"
Spring Context (86): org.springframework.jmx.export.annotation;
version="3.0.7.RELEASE"
Apache ServiceMix :: Specs :: JAXB API 2.2 (97): javax.xml.bind.annotation;
version="2.2.1"
Apache ServiceMix :: Specs :: JAXB API 2.2 (97): javax.xml.bind;
version="2.2.1"
Apache ServiceMix :: Specs :: JAXWS API 2.2 (98): javax.xml.ws;
version="2.2.0"
JBoss Hibernate Object-Relational Mapper (554): org.hibernate;
version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554): org.hibernate.cfg;
version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554): org.hibernate.criterion;
version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554): org.hibernate.exception;
version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554):
org.hibernate.internal.util.config; version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554): org.hibernate.metadata;
version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554):
org.hibernate.persister.entity; version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554): org.hibernate.proxy;
version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554): org.hibernate.service;
version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554):
org.hibernate.service.jdbc.connections.internal; version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554): org.hibernate.transform;
version="4.1.0.Final"
Java Persistence API (556): javax.persistence; version="2.0.0"
JBoss Hibernate Common Annotations (557): org.hibernate.annotations.common;
version="4.1.0.Final"
JBoss Hibernate Common Annotations (557):
org.hibernate.annotations.common.annotationfactory; version="4.1.0.Final"
JBoss Hibernate Common Annotations (557):
org.hibernate.annotations.common.reflection; version="4.1.0.Final"
JBoss Hibernate Common Annotations (557):
org.hibernate.annotations.common.reflection.java; version="4.1.0.Final"
JBoss Hibernate Common Annotations (557):
org.hibernate.annotations.common.reflection.java.generics;
version="4.1.0.Final"
JBoss Hibernate Common Annotations (557):
org.hibernate.annotations.common.util; version="4.1.0.Final"
JBoss Hibernate Common Annotations (557):
org.hibernate.annotations.common.util.impl; version="4.1.0.Final"
Javassist Java Programming Assistant (547): javassist.util.proxy;
version="3.15.0.GA"
Apache CXF API (109): org.apache.cxf.endpoint; version="2.6.0"
Apache CXF API (109): org.apache.cxf.phase; version="2.6.0"
Apache CXF API (109): org.apache.cxf.message; version="2.6.0"
Apache CXF API (109): org.apache.cxf.binding; version="2.6.0"
Apache CXF API (109): org.apache.cxf.ws.addressing; version="2.6.0"
Apache CXF API (109): org.apache.cxf.transport; version="2.6.0"
Apache CXF API (109): org.apache.cxf.interceptor; version="2.6.0"
*c3p0 Connection Pool (1042): com.mchange.v2.c3p0; version="0.9.1"*
Apache CXF Runtime SOAP Binding (115): org.apache.cxf.binding.soap;
version="2.6.0"
Apache ServiceMix :: Bundles :: dom4j (177): org.dom4j; version="1.6.1"


The DAO and HibernateSession singletons are created in the Persistance
bundle (1079) by Spring.
This bundle also imports Hibernate and c3p0 dependencies

karaf@trun> packages:imports 1079
OPS4J Pax Logging - API (3): org.slf4j; version="1.6.4"
OPS4J Pax Logging - API (3): org.slf4j; version="1.6.1"
OPS4J Pax Logging - API (3): org.slf4j; version="1.5.11"
OPS4J Pax Logging - API (3): org.slf4j; version="1.4.3"
Spring Core (81): org.springframework.core.io.support;
version="3.0.7.RELEASE"
Spring Beans (84): org.springframework.beans; version="3.0.7.RELEASE"
[...]
Spring Context (86): org.springframework.context; version="3.0.7.RELEASE"
[...]
JBoss Hibernate Object-Relational Mapper (554): org.hibernate.cfg;
version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554):
org.hibernate.engine.jdbc.internal; version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554): org.hibernate.proxy;
version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554):
org.hibernate.service.classloading.internal; version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554):
org.hibernate.service.internal; version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554):
org.hibernate.service.jdbc.connections.internal; version="4.1.0.Final"
JBoss Hibernate Object-Relational Mapper (554): org.hibernate.type;
version="4.1.0.Final"
Java Persistence API (556): javax.persistence; version="2.0.0"
JBoss Hibernate Common Annotations (557): org.hibernate.annotations.common;
version="4.1.0.Final"
JBoss Hibernate Common Annotations (557):
org.hibernate.annotations.common.annotationfactory; version="4.1.0.Final"
JBoss Hibernate Common Annotations (557):
org.hibernate.annotations.common.reflection; version="4.1.0.Final"
JBoss Hibernate Common Annotations (557):
org.hibernate.annotations.common.reflection.java; version="4.1.0.Final"
JBoss Hibernate Common Annotations (557):
org.hibernate.annotations.common.reflection.java.generics;
version="4.1.0.Final"
JBoss Hibernate Common Annotations (557):
org.hibernate.annotations.common.util; version="4.1.0.Final"
JBoss Hibernate Common Annotations (557):
org.hibernate.annotations.common.util.impl; version="4.1.0.Final"
Javassist Java Programming Assistant (547): javassist.util.proxy;
version="3.15.0.GA"
Apache CXF API (109): org.apache.cxf.headers; version="2.6.0"
[...]
Apache CXF Runtime Core (110): org.apache.cxf.bus.managers; version="2.6.0"
[...]
*c3p0 Connection Pool (1042): com.mchange.v2.c3p0; version="0.9.1"*
Apache CXF Runtime HTTP Transport (117): META-INF.cxf.osgi; version="2.6.0"
[...]
Apache CXF Runtime JAX-RS Frontend (123): org.apache.cxf.jaxrs.utils;
version="2.6.0"
[...]
camel-core (160): org.apache.camel.spi; version="2.9.2"
camel-core (160): org.apache.camel; version="2.9.2"
Apache CXF Runtime JAX-WS Frontend (119): org.apache.cxf.jaxws.spring;
version="2.6.0"
[...]
*:PROJ: Communs (1076): com.proj.communs.persistance;
version="0.0.1.SNAPSHOT"
*


But the bundle failed to start because of a ClassLoadingException. 

11:19:55,541 | INFO  | ExtenderThread-2 | uns.persistance.HibernateSession 
143 | 1076 - com.proj.communs.communs - 0.0.1.SNAPSHOT | SessionFactory Init
11:19:55,644 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger       
68 |  -  -  | HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
11:19:55,651 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger       
68 |  -  -  | HHH000412: Hibernate Core {4.1.0.Final}
11:19:55,795 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger       
68 |  -  -  | HHH000206: hibernate.properties not found
11:19:55,797 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger       
68 |  -  -  | HHH000021: Bytecode provider name : javassist
11:19:55,816 | INFO  | ExtenderThread-2 | uns.persistance.HibernateSession 
175 | 1076 - com.proj.communs.communs - 0.0.1.SNAPSHOT | Hibernate
Configuration from /mapping/hibernate.cfg.xml
11:19:55,817 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger       
68 |  -  -  | HHH000043: Configuring from resource:
/mapping/hibernate.cfg.xml
11:19:55,817 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger       
68 |  -  -  | HHH000040: Configuration resource: /mapping/hibernate.cfg.xml

11:19:55,963 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger       
68 |  -  -  | HHH000041: Configured SessionFactory: null
11:19:56,408 | WARN  | ExtenderThread-2 | org.jboss.logging.JDKLogger       
68 |  -  -  | HHH000038: Composite-id class does not override equals():
com.proj.sgic.om.parametrage.fonctionnel.JoinedValTypologieId
11:19:56,408 | WARN  | ExtenderThread-2 | org.jboss.logging.JDKLogger       
68 |  -  -  | HHH000039: Composite-id class does not override hashCode():
com.proj.sgic.om.parametrage.fonctionnel.JoinedValTypologieId
11:19:56,416 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger       
68 |  -  -  | HHH000130: Instantiating explicit connection provider:
org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider
11:19:56,417 | ERROR | ExtenderThread-2 | uns.persistance.HibernateSession 
193 | 1076 - com.proj.communs.communs - 0.0.1.SNAPSHOT | %%%% Failed to
create SessionFactory %%%%
org.hibernate.service.spi.ServiceException: Unable to create requested
service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]
        at
org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:187)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:150)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2273)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2269)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1738)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
com.proj.communs.persistance.HibernateSession.buildSessionFactory(HibernateSession.java:190)[1076:com.proj.communs.communs:0.0.1.SNAPSHOT]
        at
com.proj.communs.persistance.HibernateSession.initSessionFactory(HibernateSession.java:144)[1076:com.proj.communs.communs:0.0.1.SNAPSHOT]
        at
com.proj.communs.persistance.BaseDAOHibernate.initSessionFactoryHibernate(BaseDAOHibernate.java:62)[1076:com.proj.communs.communs:0.0.1.SNAPSHOT]
        at
com.proj.communs.persistance.BaseDAOHibernate.<init>(BaseDAOHibernate.java:33)[1076:com.proj.communs.communs:0.0.1.SNAPSHOT]
        at
com.proj.communs.persistance.AbstractListeFiltreeDAO.<init>(AbstractListeFiltreeDAO.java:40)[1076:com.proj.communs.communs:0.0.1.SNAPSHOT]
        at
com.proj.sgic.persistance.dao.impl.SGIC_ParametrageFonctionnelDAOImpl.<init>(SGIC_ParametrageFonctionnelDAOImpl.java:64)[1079:com.proj.sgic.sgic_persistance:0.0.1.SNAPSHOT]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)[:1.6.0_25]
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)[:1.6.0_25]
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)[:1.6.0_25]
        at
java.lang.reflect.Constructor.newInstance(Constructor.java:513)[:1.6.0_25]
        at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)[84:org.springframework.beans:3.0.7.RELEASE]
        at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74)[84:org.springframework.beans:3.0.7.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:957)[84:org.springframework.beans:3.0.7.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:910)[84:org.springframework.beans:3.0.7.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:484)[84:org.springframework.beans:3.0.7.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)[84:org.springframework.beans:3.0.7.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)[84:org.springframework.beans:3.0.7.RELEASE]
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)[84:org.springframework.beans:3.0.7.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)[84:org.springframework.beans:3.0.7.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)[84:org.springframework.beans:3.0.7.RELEASE]
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)[84:org.springframework.beans:3.0.7.RELEASE]
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)[86:org.springframework.context:3.0.7.RELEASE]
        at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)[90:org.springframework.osgi.core:1.2.1]
        at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)[90:org.springframework.osgi.core:1.2.1]
        at
org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[90:org.springframework.osgi.core:1.2.1]
        at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)[90:org.springframework.osgi.core:1.2.1]
        at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)[91:org.springframework.osgi.extender:1.2.1]
        at java.lang.Thread.run(Thread.java:662)[:1.6.0_25]
Caused by: org.hibernate.HibernateException: Could not instantiate
connection provider
[org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider]
        at
org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:192)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:114)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:54)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:69)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:177)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        ... 39 more
Caused by: org.hibernate.service.classloading.spi.ClassLoadingException:
Unable to load class
[org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider]
        at
org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141)[554:com.springsource.org.hibernate.core:4.1.0.Final]
        at
org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:189)[554:com.springsource.org.hibernate.core:4.1.0.Final]
:


I've understood Hibernate (bundle 554) cannot load the
C3P0ConnectionProvider, and I think it's a classloader issue, but I don't
know how to solve this.
Is there a different way to load my Hibernate config or to load the c3p0
connection pool ? How can I declare an import dependency on Hibernate bundle
to load C3P0ConnectionProvider ?

Thanks for you help,
Vincent



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-Hibernate-c3p0-Issue-ClassLoadingException-tp4027985.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf - Hibernate/c3p0 Issue - ClassLoadingException

Posted by Charles Moulliard <ch...@gmail.com>.
Hi Vincent,

Have you tried last release of Hibernate (> 4.2.3) as project has been
improved to support 'OSGI'.

https://github.com/hibernate/hibernate-orm/wiki/Proposal--OSGi
https://hibernate.atlassian.net/browse/HHH-7527

Regards,



On Sun, Mar 3, 2013 at 11:48 AM, vincent.z <vi...@steria.com>wrote:

> Hello,
>
> Once again, a ClassLoadingException issue on Karaf bundles; but with c3p0
> this time.
> I've read all posts about ClassLoadingException and JDBC drivers but I have
> not found a solution for my problem
>
> I use Karaf 2.2.6 and I have a Persistance bundle (bundle 1079) for loading
> a hibernate.cfg.xml, creating a HibernateSession singleton with a c3p0
> connection pool.
>
> *hibernate.cfg.xml*
> /<hibernate-configuration>
>         <session-factory>
>                 <property
>
> name="hibernate.connection.url">jdbc:postgresql://localhost:5432/db</property>
>                 <property
> name="hibernate.connection.username">user</property>
>                 <property
> name="hibernate.connection.password">pass</property>
>                 *<property
>
> name="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property>*
>                 <property name="hibernate.c3p0.min_size">5</property>
>                 <property name="hibernate.c3p0.max_size">20</property>
>                 <property name="hibernate.c3p0.timeout">300</property>
>                 <property
> name="hibernate.c3p0.max_statements">50</property>
>                 <property
> name="hibernate.c3p0.idle_test_period">3000</property>
>                 <property
> name="hibernate.connection.driver_class">org.postgresql.Driver</property>
>                 <property name="hibernate.default_schema">public</property>
>                 <property
> name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
>                 <property
> name="current_session_context_class">thread</property>
>                 <property
> name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
>                 <property
>
> name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
>                 <property
> name="javax.persistence.validation.mode">none</property>
>                 <property name="show_sql">false</property>
>                 <mapping class="com.proj.article.Article" />
> [...]
>         </session-factory>
> </hibernate-configuration>/
>
> I've deployed Hibernate bundles from com.springsource and c3p0 bundle too.
>
> karaf@trun> list
> START LEVEL 100 , List Threshold: 50
>    ID   State         Blueprint      Spring    Level  Name
> [...]
> [ 547] [Active     ] [            ] [       ] [   80] Javassist Java
> Programming Assistant (3.15.0.GA)
> [ 548] [Active     ] [            ] [       ] [   80] ANTLR (2.7.7)
> [ 549] [Active     ] [            ] [       ] [   80] FasterXML ClassMate
> (0.5.4)
> [ 550] [Active     ] [            ] [       ] [   80] Java Bean Validation
> API (1.0.0.GA)
> [ 551] [Active     ] [            ] [       ] [   80] JBoss Jandex
> (1.0.3.Final)
> [ 552] [Active     ] [            ] [       ] [   80] Apache ANT (1.8.1)
> [ 553] [Active     ] [            ] [       ] [   80] Apache Commons
> Collections (3.2.1)
> [ 554] [Active     ] [            ] [       ] [   80] JBoss Hibernate
> Object-Relational Mapper (4.1.0.Final)
>                                        Fragments: 555
> [ 555] [Resolved   ] [            ] [       ] [   80] JBoss Hibernate
> Entity
> Manager (4.1.0.Final)
>                                        Hosts: 554
> [ 556] [Active     ] [            ] [       ] [   80] Java Persistence API
> (2.0.0)
> [ 557] [Active     ] [            ] [       ] [   80] JBoss Hibernate
> Common
> Annotations (4.1.0.Final)
> [ 558] [Active     ] [            ] [       ] [   80] JBoss Logging 3
> (3.1.0.GA)
> [ 995] [Active     ] [            ] [       ] [   50] Apache ServiceMix ::
> Bundles :: commons-httpclient (3.1.0.7)
> [ 996] [Active     ] [            ] [       ] [   50] Commons Codec (1.4)
> [ 997] [Active     ] [            ] [       ] [   50] camel-http (2.9.2)
> [ 998] [Active     ] [            ] [       ] [   50] camel-jetty (2.9.2)
> [1042] [Active     ] [            ] [       ] [   80] c3p0 Connection Pool
> (0.9.1)
> [1076] [Active     ] [            ] [       ] [   82] :COMM: Communs
> (0.0.1.SNAPSHOT)
> [1079] [Active     ] [            ] [Failed ] [   91] :PROJ: Persistance
> (0.0.1.SNAPSHOT)
>
> The HibernateSession java class is in the Common bundle (1076) which
> imports
> Hibernate dependencies and C3P0 dependency. The bundle exports the
> HibernateSession java package
>
> karaf@trun> packages:exports 1076
>     ID Packages
>   1076 com.proj.communs.csv; version="0.0.1.SNAPSHOT"
>   1076 com.proj.communs.exceptions; version="0.0.1.SNAPSHOT"
>   1076 com.proj.communs.utils; version="0.0.1.SNAPSHOT"
>   1076 com.proj.communs.xml; version="0.0.1.SNAPSHOT"
> *  1076 com.proj.communs.persistance; version="0.0.1.SNAPSHOT"*
>   1076 com.proj.communs.enums; version="0.0.1.SNAPSHOT"
>   1076 com.proj.communs.ressources; version="0.0.1.SNAPSHOT"
> karaf@trun> packages:imports 1076
> OSGi System Bundle (0): javax.xml.validation; version="0.0.0"
> OSGi System Bundle (0): org.xml.sax; version="0.0.0"
> OPS4J Pax Logging - API (3): org.slf4j; version="1.6.4"
> OPS4J Pax Logging - API (3): org.slf4j; version="1.6.1"
> OPS4J Pax Logging - API (3): org.slf4j; version="1.5.11"
> OPS4J Pax Logging - API (3): org.slf4j; version="1.4.3"
> Spring Core (81): org.springframework.core.io; version="3.0.7.RELEASE"
> Spring Beans (84): org.springframework.beans.factory.config;
> version="3.0.7.RELEASE"
> Spring Context (86): org.springframework.context; version="3.0.7.RELEASE"
> Spring Context (86): org.springframework.jmx.export.annotation;
> version="3.0.7.RELEASE"
> Apache ServiceMix :: Specs :: JAXB API 2.2 (97): javax.xml.bind.annotation;
> version="2.2.1"
> Apache ServiceMix :: Specs :: JAXB API 2.2 (97): javax.xml.bind;
> version="2.2.1"
> Apache ServiceMix :: Specs :: JAXWS API 2.2 (98): javax.xml.ws;
> version="2.2.0"
> JBoss Hibernate Object-Relational Mapper (554): org.hibernate;
> version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554): org.hibernate.cfg;
> version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554): org.hibernate.criterion;
> version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554): org.hibernate.exception;
> version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554):
> org.hibernate.internal.util.config; version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554): org.hibernate.metadata;
> version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554):
> org.hibernate.persister.entity; version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554): org.hibernate.proxy;
> version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554): org.hibernate.service;
> version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554):
> org.hibernate.service.jdbc.connections.internal; version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554): org.hibernate.transform;
> version="4.1.0.Final"
> Java Persistence API (556): javax.persistence; version="2.0.0"
> JBoss Hibernate Common Annotations (557): org.hibernate.annotations.common;
> version="4.1.0.Final"
> JBoss Hibernate Common Annotations (557):
> org.hibernate.annotations.common.annotationfactory; version="4.1.0.Final"
> JBoss Hibernate Common Annotations (557):
> org.hibernate.annotations.common.reflection; version="4.1.0.Final"
> JBoss Hibernate Common Annotations (557):
> org.hibernate.annotations.common.reflection.java; version="4.1.0.Final"
> JBoss Hibernate Common Annotations (557):
> org.hibernate.annotations.common.reflection.java.generics;
> version="4.1.0.Final"
> JBoss Hibernate Common Annotations (557):
> org.hibernate.annotations.common.util; version="4.1.0.Final"
> JBoss Hibernate Common Annotations (557):
> org.hibernate.annotations.common.util.impl; version="4.1.0.Final"
> Javassist Java Programming Assistant (547): javassist.util.proxy;
> version="3.15.0.GA"
> Apache CXF API (109): org.apache.cxf.endpoint; version="2.6.0"
> Apache CXF API (109): org.apache.cxf.phase; version="2.6.0"
> Apache CXF API (109): org.apache.cxf.message; version="2.6.0"
> Apache CXF API (109): org.apache.cxf.binding; version="2.6.0"
> Apache CXF API (109): org.apache.cxf.ws.addressing; version="2.6.0"
> Apache CXF API (109): org.apache.cxf.transport; version="2.6.0"
> Apache CXF API (109): org.apache.cxf.interceptor; version="2.6.0"
> *c3p0 Connection Pool (1042): com.mchange.v2.c3p0; version="0.9.1"*
> Apache CXF Runtime SOAP Binding (115): org.apache.cxf.binding.soap;
> version="2.6.0"
> Apache ServiceMix :: Bundles :: dom4j (177): org.dom4j; version="1.6.1"
>
>
> The DAO and HibernateSession singletons are created in the Persistance
> bundle (1079) by Spring.
> This bundle also imports Hibernate and c3p0 dependencies
>
> karaf@trun> packages:imports 1079
> OPS4J Pax Logging - API (3): org.slf4j; version="1.6.4"
> OPS4J Pax Logging - API (3): org.slf4j; version="1.6.1"
> OPS4J Pax Logging - API (3): org.slf4j; version="1.5.11"
> OPS4J Pax Logging - API (3): org.slf4j; version="1.4.3"
> Spring Core (81): org.springframework.core.io.support;
> version="3.0.7.RELEASE"
> Spring Beans (84): org.springframework.beans; version="3.0.7.RELEASE"
> [...]
> Spring Context (86): org.springframework.context; version="3.0.7.RELEASE"
> [...]
> JBoss Hibernate Object-Relational Mapper (554): org.hibernate.cfg;
> version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554):
> org.hibernate.engine.jdbc.internal; version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554): org.hibernate.proxy;
> version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554):
> org.hibernate.service.classloading.internal; version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554):
> org.hibernate.service.internal; version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554):
> org.hibernate.service.jdbc.connections.internal; version="4.1.0.Final"
> JBoss Hibernate Object-Relational Mapper (554): org.hibernate.type;
> version="4.1.0.Final"
> Java Persistence API (556): javax.persistence; version="2.0.0"
> JBoss Hibernate Common Annotations (557): org.hibernate.annotations.common;
> version="4.1.0.Final"
> JBoss Hibernate Common Annotations (557):
> org.hibernate.annotations.common.annotationfactory; version="4.1.0.Final"
> JBoss Hibernate Common Annotations (557):
> org.hibernate.annotations.common.reflection; version="4.1.0.Final"
> JBoss Hibernate Common Annotations (557):
> org.hibernate.annotations.common.reflection.java; version="4.1.0.Final"
> JBoss Hibernate Common Annotations (557):
> org.hibernate.annotations.common.reflection.java.generics;
> version="4.1.0.Final"
> JBoss Hibernate Common Annotations (557):
> org.hibernate.annotations.common.util; version="4.1.0.Final"
> JBoss Hibernate Common Annotations (557):
> org.hibernate.annotations.common.util.impl; version="4.1.0.Final"
> Javassist Java Programming Assistant (547): javassist.util.proxy;
> version="3.15.0.GA"
> Apache CXF API (109): org.apache.cxf.headers; version="2.6.0"
> [...]
> Apache CXF Runtime Core (110): org.apache.cxf.bus.managers; version="2.6.0"
> [...]
> *c3p0 Connection Pool (1042): com.mchange.v2.c3p0; version="0.9.1"*
> Apache CXF Runtime HTTP Transport (117): META-INF.cxf.osgi; version="2.6.0"
> [...]
> Apache CXF Runtime JAX-RS Frontend (123): org.apache.cxf.jaxrs.utils;
> version="2.6.0"
> [...]
> camel-core (160): org.apache.camel.spi; version="2.9.2"
> camel-core (160): org.apache.camel; version="2.9.2"
> Apache CXF Runtime JAX-WS Frontend (119): org.apache.cxf.jaxws.spring;
> version="2.6.0"
> [...]
> *:PROJ: Communs (1076): com.proj.communs.persistance;
> version="0.0.1.SNAPSHOT"
> *
>
>
> But the bundle failed to start because of a ClassLoadingException.
>
> 11:19:55,541 | INFO  | ExtenderThread-2 | uns.persistance.HibernateSession
> 143 | 1076 - com.proj.communs.communs - 0.0.1.SNAPSHOT | SessionFactory
> Init
> 11:19:55,644 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger
> 68 |  -  -  | HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
> 11:19:55,651 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger
> 68 |  -  -  | HHH000412: Hibernate Core {4.1.0.Final}
> 11:19:55,795 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger
> 68 |  -  -  | HHH000206: hibernate.properties not found
> 11:19:55,797 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger
> 68 |  -  -  | HHH000021: Bytecode provider name : javassist
> 11:19:55,816 | INFO  | ExtenderThread-2 | uns.persistance.HibernateSession
> 175 | 1076 - com.proj.communs.communs - 0.0.1.SNAPSHOT | Hibernate
> Configuration from /mapping/hibernate.cfg.xml
> 11:19:55,817 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger
> 68 |  -  -  | HHH000043: Configuring from resource:
> /mapping/hibernate.cfg.xml
> 11:19:55,817 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger
> 68 |  -  -  | HHH000040: Configuration resource: /mapping/hibernate.cfg.xml
>
> 11:19:55,963 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger
> 68 |  -  -  | HHH000041: Configured SessionFactory: null
> 11:19:56,408 | WARN  | ExtenderThread-2 | org.jboss.logging.JDKLogger
> 68 |  -  -  | HHH000038: Composite-id class does not override equals():
> com.proj.sgic.om.parametrage.fonctionnel.JoinedValTypologieId
> 11:19:56,408 | WARN  | ExtenderThread-2 | org.jboss.logging.JDKLogger
> 68 |  -  -  | HHH000039: Composite-id class does not override hashCode():
> com.proj.sgic.om.parametrage.fonctionnel.JoinedValTypologieId
> 11:19:56,416 | INFO  | ExtenderThread-2 | org.jboss.logging.JDKLogger
> 68 |  -  -  | HHH000130: Instantiating explicit connection provider:
> org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider
> 11:19:56,417 | ERROR | ExtenderThread-2 | uns.persistance.HibernateSession
> 193 | 1076 - com.proj.communs.communs - 0.0.1.SNAPSHOT | %%%% Failed to
> create SessionFactory %%%%
> org.hibernate.service.spi.ServiceException: Unable to create requested
> service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]
>         at
>
> org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:187)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:150)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2273)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2269)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1738)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> com.proj.communs.persistance.HibernateSession.buildSessionFactory(HibernateSession.java:190)[1076:com.proj.communs.communs:0.0.1.SNAPSHOT]
>         at
>
> com.proj.communs.persistance.HibernateSession.initSessionFactory(HibernateSession.java:144)[1076:com.proj.communs.communs:0.0.1.SNAPSHOT]
>         at
>
> com.proj.communs.persistance.BaseDAOHibernate.initSessionFactoryHibernate(BaseDAOHibernate.java:62)[1076:com.proj.communs.communs:0.0.1.SNAPSHOT]
>         at
>
> com.proj.communs.persistance.BaseDAOHibernate.<init>(BaseDAOHibernate.java:33)[1076:com.proj.communs.communs:0.0.1.SNAPSHOT]
>         at
>
> com.proj.communs.persistance.AbstractListeFiltreeDAO.<init>(AbstractListeFiltreeDAO.java:40)[1076:com.proj.communs.communs:0.0.1.SNAPSHOT]
>         at
>
> com.proj.sgic.persistance.dao.impl.SGIC_ParametrageFonctionnelDAOImpl.<init>(SGIC_ParametrageFonctionnelDAOImpl.java:64)[1079:com.proj.sgic.sgic_persistance:0.0.1.SNAPSHOT]
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)[:1.6.0_25]
>         at
>
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)[:1.6.0_25]
>         at
>
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)[:1.6.0_25]
>         at
> java.lang.reflect.Constructor.newInstance(Constructor.java:513)[:1.6.0_25]
>         at
>
> org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)[84:org.springframework.beans:3.0.7.RELEASE]
>         at
>
> org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74)[84:org.springframework.beans:3.0.7.RELEASE]
>         at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:957)[84:org.springframework.beans:3.0.7.RELEASE]
>         at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:910)[84:org.springframework.beans:3.0.7.RELEASE]
>         at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:484)[84:org.springframework.beans:3.0.7.RELEASE]
>         at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)[84:org.springframework.beans:3.0.7.RELEASE]
>         at
>
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)[84:org.springframework.beans:3.0.7.RELEASE]
>         at
>
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)[84:org.springframework.beans:3.0.7.RELEASE]
>         at
>
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)[84:org.springframework.beans:3.0.7.RELEASE]
>         at
>
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)[84:org.springframework.beans:3.0.7.RELEASE]
>         at
>
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)[84:org.springframework.beans:3.0.7.RELEASE]
>         at
>
> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)[86:org.springframework.context:3.0.7.RELEASE]
>         at
>
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)[90:org.springframework.osgi.core:1.2.1]
>         at
>
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)[90:org.springframework.osgi.core:1.2.1]
>         at
>
> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[90:org.springframework.osgi.core:1.2.1]
>         at
>
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)[90:org.springframework.osgi.core:1.2.1]
>         at
>
> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)[91:org.springframework.osgi.extender:1.2.1]
>         at java.lang.Thread.run(Thread.java:662)[:1.6.0_25]
> Caused by: org.hibernate.HibernateException: Could not instantiate
> connection provider
> [org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider]
>         at
>
> org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:192)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:114)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:54)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:69)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:177)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         ... 39 more
> Caused by: org.hibernate.service.classloading.spi.ClassLoadingException:
> Unable to load class
> [org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider]
>         at
>
> org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141)[554:com.springsource.org.hibernate.core:4.1.0.Final]
>         at
>
> org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:189)[554:com.springsource.org.hibernate.core:4.1.0.Final]
> :
>
>
> I've understood Hibernate (bundle 554) cannot load the
> C3P0ConnectionProvider, and I think it's a classloader issue, but I don't
> know how to solve this.
> Is there a different way to load my Hibernate config or to load the c3p0
> connection pool ? How can I declare an import dependency on Hibernate
> bundle
> to load C3P0ConnectionProvider ?
>
> Thanks for you help,
> Vincent
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/Karaf-Hibernate-c3p0-Issue-ClassLoadingException-tp4027985.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

RE: Karaf - Hibernate/c3p0 Issue - ClassLoadingException

Posted by "vincent.z" <vi...@steria.com>.
Hi Tanvi,

Yes, I've found a solution to my problem, but it was a long time ago and I'm not on this project anymore, so I'm trying to remember the solution.

I hope this is the way to solve your problem : I had to upgrade Spring to version 3.14, and Hibernate to version 4.10 and modify the configuration of my bundle.

You have to uninstall version 3.07  of Spring before installing version 3.14. Be careful, it's not easy and some bundles are system bundle.

After that and before installing the persistence bundle, you have to install these features :

                <!-- Librairies -->
                <feature name="image-libs-hibernate" version="4.1.0">
                               <bundle start-level='80'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j/1.6.1_5</bundle>
                               <bundle start-level='80'>mvn:org.jboss.javassist/com.springsource.javassist/3.15.0.GA</bundle>
                               <bundle start-level='80'>mvn:org.antlr/com.springsource.antlr/2.7.7</bundle>
                               <bundle start-level='80'>mvn:com.fasterxml/com.springsource.com.fasterxml.classmate/0.5.4</bundle>
                               <bundle start-level='80'>mvn:javax.validation/com.springsource.javax.validation/1.0.0.GA</bundle>
                               <bundle start-level='80'>mvn:org.jboss/com.springsource.org.jboss.jandex/1.0.3.Final</bundle>
                               <bundle start-level='80'>mvn:org.apache.ant/com.springsource.org.apache.tools.ant/1.8.1</bundle>
                               <bundle start-level='80'>mvn:org.apache.commons/com.springsource.org.apache.commons.collections/3.2.1</bundle>
                               <bundle start-level='80'>mvn:org.hibernate/com.springsource.org.hibernate.core/4.1.0.Final</bundle>
                               <bundle start-level='80'>mvn:org.hibernate/com.springsource.org.hibernate.ejb/4.1.0.Final</bundle>
                               <bundle start-level='80'>mvn:javax.persistence/com.springsource.javax.persistence/2.0.0</bundle>
                               <bundle start-level='80'>mvn:org.hibernate.common/com.springsource.org.hibernate.annotations.common/4.1.0.Final</bundle>
                               <bundle start-level='80'>mvn:org.jboss.logging/jboss-logging/3.1.0.GA</bundle>
                               <bundle start-level='80'>mvn:com.mchange.c3p0/com.springsource.com.mchange.v2.c3p0/0.9.1.2</bundle>
                               <bundle start-level='80'>mvn:org.aspectj/com.springsource.org.aspectj.weaver/1.6.8.RELEASE</bundle>
                </feature>
                <feature>
                               <feature version="3.1.4.RELEASE">spring</feature>
                               <feature version="3.1.4.RELEASE">spring-jms</feature>
                               <feature version="3.1.4.RELEASE">spring-web</feature>
                               <feature version="3.1.4.RELEASE">spring-tx</feature>
                               <feature version="3.1.4.RELEASE">spring-orm</feature>
                </feature>






My configuration on the persistence bundle was :

On pom.xml, the bundle imports these packages :

-          org.hibernate.proxy,

-          org.postgresql.*,

-          org.springframework.orm.hibernate4,

-          com.mchange.v2.c3p0,


And dependencies are :

                               <!-- Postgres Database driver -->
                               <dependency>
                                               <groupId>postgresql</groupId>
                                               <artifactId>postgresql</artifactId>
<version>8.4-702.jdbc4</version>
                               </dependency>
                               <!-- Hibernate Annotations for mapping -->
                               <dependency>
                                               <groupId>org.hibernate</groupId>
                                               <artifactId>hibernate-core</artifactId>
<version>4.1.0.Final</version>
                               </dependency>
                               <dependency>
                                               <groupId>org.hibernate.common</groupId>
                                               <artifactId>hibernate-commons-annotations</artifactId>
<version>4.1.0.Final</version>
                               </dependency>
                               <dependency>
                                               <groupId>javassist</groupId>
                                               <artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
                               </dependency>
                               <!-- C3P0 pour le pool de connexion vers la BDD -->
                               <dependency>
                                               <groupId>org.hibernate</groupId>
                                               <artifactId>hibernate-c3p0</artifactId>
<version>4.1.0.Final</version>
                               </dependency>
                               <dependency>
                                               <groupId>c3p0</groupId>
                                               <artifactId>c3p0</artifactId>
                                               <version>0.9.1</version>
                               </dependency>
                               <dependency>
                                               <groupId>joda-time</groupId>
                                               <artifactId>joda-time</artifactId>
                                               <version>2.1</version>
                               </dependency>
                               <dependency>
                                               <groupId>org.springframework</groupId>
                                               <artifactId>spring-orm</artifactId>
                                               <version>3.1.4.RELEASE</version>
                               </dependency>
                </dependencies>


And these beans are defined on bundle-context.xml :

                <!-Datasource -->
                <bean id="c3p0dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
                               destroy-method="close">
                               <property name="driverClass" value="org.postgresql.Driver" />
                               <property name="jdbcUrl" value="${hibernate.connection.url}" />
                               <property name="user" value="${hibernate.connection.username}" />
                               <property name="password" value="${hibernate.connection.password}" />
                               <property name="acquireIncrement" value="1"></property>
                               <property name="minPoolSize" value="15"></property>
                               <property name="maxPoolSize" value="50"></property>
                               <property name="acquireRetryAttempts" value="10"></property>
                               <property name="preferredTestQuery" value="SELECT 1"></property>
                               <property name="testConnectionOnCheckin" value="true"></property>
                               <property name="testConnectionOnCheckout" value="false"></property>
                               <property name="maxIdleTime" value="50"></property>
                               <property name="idleConnectionTestPeriod" value="30"></property>
                </bean>

                <bean id="sessionFactoryBean"
                               class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
                               <property name="dataSource" ref="c3p0dataSource" />
                               <property name="packagesToScan">
                                               <list>
                                                               <value>fr. image.commons </value>
                                                               <value>fr.image. om</value>
                                               </list>
                               </property>
                               <property name="hibernateProperties">
                                               <props>
                                                               <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
                                                               <prop key="hibernate.hbm2ddl.auto">update</prop>
                                                               <prop key="hibernate.connection.release_mode">on_close</prop>
                                                               <prop key="hibernate.default_schema">public</prop>
                                                               <prop key="hibernate.current_session_context_class">org.hibernate.context.internal.ThreadLocalSessionContext</prop>
                                                               <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
                                                               <prop key="javax.persistence.validation.mode">none</prop>
                                                               <prop key="show_sql">false</prop>
                                               </props>
                               </property>
                </bean>




I hope it will help you,

Vincent Zwingmann
Technical Architect
vincent.zwingmann@steria.fr<ma...@steria.fr>
www.steria.fr<http://www.steria.fr/>

De : tanvi.purandare@gmail.com [via Karaf] [mailto:ml-node+s922171n4029866h21@n3.nabble.com]
Envoyé : lundi 7 octobre 2013 21:27
À : Vincent ZWINGMANN
Objet : Re: Karaf - Hibernate/c3p0 Issue - ClassLoadingException

Hi,

Were you able to figure out the solution?
I am facing similar issue of c3p0 connection creation in Karaf. Its giving me error like
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1" java.lang.NoClassDefFoundError: org/ietf/jgss/GSSCredential

Please let me know if you could find the solution for the problem.

Thanks,
Tanvi
________________________________
If you reply to this email, your message will be added to the discussion below:
http://karaf.922171.n3.nabble.com/Karaf-Hibernate-c3p0-Issue-ClassLoadingException-tp4027985p4029866.html
To unsubscribe from Karaf - Hibernate/c3p0 Issue - ClassLoadingException, click here<http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4027985&code=dmluY2VudC56d2luZ21hbm5Ac3RlcmlhLmNvbXw0MDI3OTg1fDMwODQ1OTc5Mw==>.
NAML<http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
This email and any attachments may contain confidential information and intellectual property (including copyright material). It is only for the use of the addressee(s) in accordance with any instructions contained within it. If you are not the addressee, you are prohibited from copying, forwarding, disclosing, saving or otherwise using it in any way. If you receive this email in error, please immediately advise the sender and delete it. Steria may monitor the content of emails within its network to ensure compliance with its policies and procedures. Emails are susceptible to alteration and their integrity (including origin) cannot be assured. Steria shall not be liable for any modification to a message, or for messages falsely sent.




--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-Hibernate-c3p0-Issue-ClassLoadingException-tp4027985p4029867.html
Sent from the Karaf - User mailing list archive at Nabble.com.