valid mvc ejemplo conexiones spring hibernate jboss classloader c3p0

spring - mvc - hibernate-c3p0 no se ve por el cargador de clases del módulo hibernate



spring mvc ejemplo (2)

Desde http://www.mkyong.com/hibernate/hibernate-could-not-find-c3p0connectionprovider/ :

Es bastante antiguo, diría pre-AS 7, pero también puede aplicarse. Por supuesto, debe hacer coincidir la versión con el Hibernate incluido en AS.

Desde Hibernate v3.3 (si no se ha confundido), el "C3P0ConnectionProvider" se mueve a otro archivo jar "hibernate-c3p0.jar". Debe incluirlo para que Hibernate admita el grupo de conexiones c3p0.

Puede descargar el "hibernate-c3p0.jar" del repositorio público de JBoss.

<repositories> <repository> <id>JBoss repository</id> <url>http://repository.jboss.org/nexus/content/groups/public/</url> </repository> </repositories> <dependencies> <!-- Hibernate c3p0 connection pool --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-c3p0</artifactId> <version>3.6.3.Final</version> </dependency> </dependencies>

Tengo un problema realmente extraño con mi aplicación spring / hibernate / c3p0 / jboss. Cuando se inicia, el registro muestra

16: 42: 09,219 INFO [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (subproceso de servicio de MSC 1-4) HHH000130: creación de una instancia de proveedor de conexión explícita: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider

16: 42: 09,235 INFO [org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider] (subproceso de servicio MSC 1-4) HHH010002: C3P0 con el controlador: oracle.jdbc.OracleDriver en URL: jdbc: oracle: thin: @ ...

Un poco hacia abajo, sin embargo, cuando intenta crear el bean SessionFactory, veo

16: 42: 11,219 INFO [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (subproceso de servicio de MSC 1-2) HHH000130: creación de una instancia de proveedor de conexión explícita: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider

seguido de un espectacular rastro de pila que termina con

Causado por: java.lang.ClassNotFoundException: No se pudo cargar la clase solicitada: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider

hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property> <property name="hibernate.connection.password">...</property> <property name="hibernate.connection.url">jdbc:oracle:thin:...</property> <property name="hibernate.connection.username">...</property> <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</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> </session-factory> </hibernate-configuration>

contexto:

@Configuration @EnableTransactionManagement @ComponentScan("...") public class PersistenceContext { @Bean public SessionFactory sessionFactory() throws IOException { LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean(); sessionFactoryBean.setConfigLocation(new ClassPathResource("hibernate.cfg.xml")); sessionFactoryBean.afterPropertiesSet(); return sessionFactoryBean.getObject(); } @Bean public HibernateTransactionManager transactionManager() throws IOException { HibernateTransactionManager manager = new HibernateTransactionManager(sessionFactory()); return manager; } }

persistence.xml

<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="primary" transaction-type="JTA"> <properties> <property name="hibernate.ejb.cfgfile" value="hibernate.cfg.xml"/> </properties> </persistence-unit>

hibernate version: 4.0.1.Final spring: 3.2.3.RELEASE jboss: 7.1.1 c3p0: 0.9.1 (version listed as a dependency of hibernate-c3p0)

EDITAR el seguimiento de pila:

10:16:51,253 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/...]] (MSC service thread 1-7) Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ''scenarioController'' defined in "/C:/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final/bin/content/app.war/WEB-INF/classes/com/.../web/controllers/ScenarioController.class": Unsatisfied dependency expressed through constructor argument with index 0 of type [...dao.interfaces.ScenarioDao]: : Error creating bean with name ''scenarioDaoImpl'' defined in "/C:/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final/bin/content/app.war/WEB-INF/classes/com/.../dao/ScenarioDaoImpl.class": Unsatisfied dependency expressed through constructor argument with index 0 of type [org.hibernate.SessionFactory]: : Error creating bean with name ''sessionFactory'' defined in class app.web.config.PersistenceContext: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.hibernate.SessionFactory ...web.config.PersistenceContext.sessionFactory() throws java.io.IOException] threw exception; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ''sessionFactory'' defined in class ....web.config.PersistenceContext: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.hibernate.SessionFactory ....web.config.PersistenceContext.sessionFactory() throws java.io.IOException] threw exception; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ''scenarioDaoImpl'' defined in "/C:/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final/bin/content/....war/WEB-INF/classes/com/.../dao/ScenarioDaoImpl.class": Unsatisfied dependency expressed through constructor argument with index 0 of type [org.hibernate.SessionFactory]: : Error creating bean with name ''sessionFactory'' defined in class com.....web.config.PersistenceContext: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.hibernate.SessionFactory com.....web.config.PersistenceContext.sessionFactory() throws java.io.IOException] threw exception; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ''sessionFactory'' defined in class com.....config.PersistenceContext: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.hibernate.SessionFactory com.....web.config.PersistenceContext.sessionFactory() throws java.io.IOException] threw exception; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider] at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:730) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:196) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1045) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:949) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) [spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) [spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) [spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) [spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:] at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:] at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final] at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_12] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_12] at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_12] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ''scenarioDaoImpl'' defined in "/C:/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final/bin/content/....war/WEB-INF/classes/com/.../dao/ScenarioDaoImpl.class": Unsatisfied dependency expressed through constructor argument with index 0 of type [org.hibernate.SessionFactory]: : Error creating bean with name ''sessionFactory'' defined in class com.....web.config.PersistenceContext: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.hibernate.SessionFactory com.....web.config.PersistenceContext.sessionFactory() throws java.io.IOException] threw exception; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ''sessionFactory'' defined in class com.....web.config.PersistenceContext: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.hibernate.SessionFactory com.....web.config.PersistenceContext.sessionFactory() throws java.io.IOException] threw exception; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider] at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:730) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:196) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1045) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:949) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:910) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:853) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:768) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:795) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:723) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] ... 23 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ''sessionFactory'' defined in class com.....web.config.PersistenceContext: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.hibernate.SessionFactory com.....web.config.PersistenceContext.sessionFactory() throws java.io.IOException] threw exception; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:581) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1025) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:921) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:910) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:853) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:768) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:795) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:723) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] ... 37 more Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.hibernate.SessionFactory com.....web.config.PersistenceContext.sessionFactory() throws java.io.IOException] threw exception; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:181) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:570) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] ... 50 more Caused by: 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) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:150) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:234) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:91) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1735) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1775) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:247) [spring-orm-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:373) [spring-orm-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:358) [spring-orm-3.2.3.RELEASE.jar:3.2.3.RELEASE] at com.....web.config.PersistenceContext.sessionFactory(PersistenceContext.java:23) [classes:] at com.....web.config.PersistenceContext$$EnhancerByCGLIB$$407e55e5.CGLIB$sessionFactory$1(<generated>) [spring-core-3.2.3.RELEASE.jar:] at com.....web.config.PersistenceContext$$EnhancerByCGLIB$$407e55e5$$FastClassByCGLIB$$22f280c.invoke(<generated>) [spring-core-3.2.3.RELEASE.jar:] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) [spring-core-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:286) [spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE] at com.....web.config.PersistenceContext$$EnhancerByCGLIB$$407e55e5.sessionFactory(<generated>) [spring-core-3.2.3.RELEASE.jar:] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_12] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_12] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_12] at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_12] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:160) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] ... 51 more 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:190) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:112) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:54) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:69) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:177) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] ... 77 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) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:187) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] ... 81 more Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.java:99) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at java.lang.ClassLoader.loadClass(ClassLoader.java:307) [rt.jar:1.6.0_12] at java.lang.ClassLoader.loadClass(ClassLoader.java:252) [rt.jar:1.6.0_12] at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] ... 82 more

Puedo ver tanto hibernate-c3p0-4.0.1.Final.jar como c3p0-0.9.1.jar en el directorio de implementación, definitivamente están siendo incluidos. Incluso abrí hibernate-c3p0-4.0.1.Final.jar para asegurarme de que la clase realmente está ahí, y está exactamente donde debería estar.

He estado pisando esto en el depurador. La primera vez, la clase está siendo cargada con éxito por ModuleClassLoader para deployment.tdm-web-proof-of-concept.war: main. La segunda vez, ModuleClassLoader for org.hibernate: main está intentando y no lo encuentra. Estoy convencido de que este es un tipo de problema de configuración donde el cargador de clases del módulo de hibernación no puede ver esto. ¿Alguna idea de cómo puedo apuntar en la dirección correcta?


Hay un error en esta versión de org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory() . Supone incorrectamente que el método obsoleto en la clase de hibernación hereda cargará tanto el cargador de clases que lo cargó como el TCCL, que es un detalle de implementación. En cambio, este método solo usa el cargador de clases que lo cargó, el cargador de clases del módulo de hibernación. Este cargador de clases no tiene las clases de implementación en su ruta de clases, por lo que lanza la excepción ClassNotFoundException.

A partir de esto, podemos decir con seguridad que org.springframework.orm.hibernate4.LocalSessionFactoryBean en esta versión de Spring no se puede utilizar con esta versión de hibernate 4.