本文介绍了没有找到Hibernate 4 ConnectionProvider类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我刚刚在我的应用程序中将Hibernate更新为4.3.4(从3.X),这导致了一些问题。第一个是创建一个sessionFactory的新方法,我解决了。 下一个我没有发现的问题是,我现在得到一个ClassNotFoundException在org.hibernate.connection.ConnectionProvider 应该注意的是,我正在使用BoneCP(0.7.1)作为升级之前的连接池。 任何帮助将不胜感激。我很喜欢休眠(我正在将其实现为POC),我可能已经从这里的描述中省略了一些重要的细节。 我不需要它是最新的版本,所以我可以恢复,但最好和最好的是最好的:) 谢谢! Hibernate.cfg.xml代码段(更换了敏感信息): <冬眠-结构> < session-factory> < property name =hibernate.connection.driver_class> com.mysql.jdbc.Driver< / property> < property name =hibernate.connection.url> foo< / property> < property name =hibernate.connection.username> bob< / property> < property name =hibernate.default_schema> bar< / property> < property name =hibernate.dialect> package.path.MySQLCustomDialect< / property> <! - Bonecp连接池 - > < property name =hibernate.connection.provider_class> com.jolbox.bonecp.provider.BoneCPConnectionProvider< / property> < property name =bonecp.maxConnectionAgeInMinutes> 5< / property> < property name =bonecp.idleConnectionTestPeriodInMinutes> 0< / property> 等等... 堆栈跟踪: 线程中的异常Thread-110java.lang.NoClassDefFoundError:java.lang.ClassLoader.defineClass1 Native方法)在java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)在java.lang.ClassLoader.defineClass(ClassLoader.java:621)在java.security。 SecureClassLoader.defineClass(SecureClassLoader.java:141)在org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895)在org.apache.catalina.loader.WebappClassLoader.findClass( WebappClassLoader.java:1173)在org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)在org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java: 1559)在org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl $ AggregatedClassLoader.findC lass(ClassLoaderServiceImpl.java:222)在java.lang.ClassLoader.loadClass(ClassLoader.java:306)在java.lang.ClassLoader.loadClass(ClassLoader.java:247)在java.lang.Class.forName0(本机方法)在java.lang.Class.forName(Class.java:249)在org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl。 classForName(ClassLoaderServiceImpl.java:240)在org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:125)在org.hibernate.engine.jdbc.connections。 internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:194)在org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:120)在org.hibernate.engine。 jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:55)在org .html.bat .service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:197)在org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)在org.hibernate.engine.jdbc .internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)在org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)在org.hibernate.boot.registry .internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)在org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)在org.hibernate.service.intern al.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)在org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)在org.hibernate.cfg.Configuration.buildSessionFactory(配置。 (hibernateUtils.java:16)在foo.objects.building.BuildingHelper.getBuildingByID(BuildingHelper.java:225) at foo.objects.inventory.LocationInformation。< init>(LocationInformation.java:36) at foo.objects.computermanagementframework.peripheral.PeripheralHelper.readLocation(PeripheralHelper.java:154) at foo .objects.computermanagementframework.peripheral.PeripheralHelper.refresh(PeripheralHelper.java:556) at foo.server.initialization.InitializeServerThread.run(InitializeServerThread.java:298)在java.lang.Thread.run (Thread.java:695)导致:java.lang.ClassNotFoundException:org.hibernate.connection.ConnectionProvider 在org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)在org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)。 .. 36更多 解决方案 Hibernate不断更改包含 ConnectionProvider 基类。它从版本3更改为4,并再次使用第4.3节。 由于@ teresa-carrigan在此答案的评论中提到,您必须编译最新的 BoneCPConnectionProvider .java (目前支持Hibernate 4.3.1)并使用它。 或使用Hibernate版本4.2.12.Final,看看是否适用于BoneCP 0.8(如上述答案所述)。 I just updated Hibernate in my application to 4.3.4 (from 3.X), which caused some problems. The first was the new method of creating a sessionFactory, which I resolved.The next problem, which I'm finding nothing about, is that I am now getting a ClassNotFoundException on org.hibernate.connection.ConnectionProviderIt should be noted that I'm using BoneCP (0.7.1) for my connection pool, which was working before the upgrade.Any help would be appreciated. I'm pretty new to hibernate (I'm working on implementing it as a POC), and I may have left out some important details from my description here as such.I don't need it to be the newest version, so I can revert back, but it would be nice to have the latest and greatest :)Thanks!Hibernate.cfg.xml snippet (with sensitive info replaced):<hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">foo</property> <property name="hibernate.connection.username">bob</property> <property name="hibernate.default_schema">bar</property> <property name="hibernate.dialect">package.path.MySQLCustomDialect</property> <!-- Bonecp connection pool --> <property name="hibernate.connection.provider_class">com.jolbox.bonecp.provider.BoneCPConnectionProvider</property> <property name="bonecp.maxConnectionAgeInMinutes">5</property> <property name="bonecp.idleConnectionTestPeriodInMinutes">0</property> and so on ...Stack Trace:Exception in thread "Thread-110" java.lang.NoClassDefFoundError: org/hibernate/connection/ConnectionProvider at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:222) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:249) at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:240) at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:125) at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:194) at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:120) at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:55) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:83) at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:223) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:197) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178) at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843) at foo.utils.HibernateUtils.<clinit>(HibernateUtils.java:16) at foo.objects.building.BuildingHelper.getBuildingByID(BuildingHelper.java:225) at foo.objects.inventory.LocationInformation.<init>(LocationInformation.java:36) at foo.objects.computermanagementframework.peripheral.PeripheralHelper.readLocation(PeripheralHelper.java:154) at foo.objects.computermanagementframework.peripheral.PeripheralHelper.refresh(PeripheralHelper.java:556) at foo.server.initialization.InitializeServerThread.run(InitializeServerThread.java:298) at java.lang.Thread.run(Thread.java:695)Caused by: java.lang.ClassNotFoundException: org.hibernate.connection.ConnectionProvider at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) ... 36 more 解决方案 Hibernate keeps changing the package containing the ConnectionProvider base class. It changed from version 3 to 4 and has changed again with verson 4.3.As @teresa-carrigan mentions in a comment to this answer, you'll have to compile the latest BoneCPConnectionProvider.java (currently supporting Hibernate 4.3.1) and use that.Or use Hibernate version 4.2.12.Final and see if that works with BoneCP 0.8 (as explained in the aforementioned answer). 这篇关于没有找到Hibernate 4 ConnectionProvider类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-20 14:06