使用 C3P0 和 Postgresql 的 Hibernate 连接
我正在尝试使用 postgresql 和 glassfish 启动并运行应用程序(jadasite)。应用程序设计者推荐tomcat和mysql。我不能真正使用 tomcat 和 mysql 这个应用程序 atm。该应用程序使用 JPA,因此 postgresql 应该没有问题。设计者确实提到 postgresql/许多其他数据库应该可以工作。
所以这就是我所做的使用以下两个页面作为参考:
jada.properties
log4j.directory=/tmp
hibernate.connection.password=password
working.directory=/tmp
encryption.key=fVOew3eAhr+hdZ9eQLeEtw\=\=
hibernate.connection.url=jdbc\:postgresql:dev-rdbms.example.com:5432/jada"/>
hibernate.connection.driver_class=org.postgresql.drivers
persistence.xml(parital)
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
<property name="hibernate.connection.username" value="jada"/>
<property name="hibernate.connection.password" value="password"/>
<property name="hibernate.connection.url" value="jdbc:postgresql://dev-rdbms.example.com:5432/jada>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.current_session_context_class" value="thread"/>
<property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"/
制作一个 postgresql 兼容的数据库转储,加载所有数据并创建具有适当权限和访问权限的适当用户。(通过服务器 glassfish 上的 psql 进行测试)
所以在进行更改后,我将最新的 postgresql jdbc 4 驱动程序放入应用程序 WEB-INF/lib 目录中。制作了一个新的 war 文件并将其部署到我的 glassfish v3.01 服务器上。
我收到以下错误。在我看来,C3P0 找不到 JDBC 驱动程序(位于 apps WEB-INF/lib 目录以及 glassfish 域 lib 目录中)
[#|2011-04-28T11:34:58.508-0500|SEVERE|glassfish3 .0.1|
javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=11;_ThreadName=FelixStartLevel;|WebModule[/jada]JadaSite: Unable to initialize JPA connection
javax.persistence.PersistenceException: [PersistenceUnit: jadaSite] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:78)
at com.jada.jpa.connection.JpaConnection.init(JpaConnection.java:79)
at com.jada.system.Initializer.init(Initializer.java:162)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1428)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1230)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5007)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5280)
at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:928)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:912)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1947)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1619)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:236)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:362)
at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:185)
at com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:174)
at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:87)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:84)
at com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:77)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:236)
at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:128)
at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:457)
at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:401)
at org.jvnet.hk2.osgiadapter.HK2Main.start(HK2Main.java:125)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:915)
at org.jvnet.hk2.osgimain.Main.start(Main.java:140)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1077)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.hibernate.HibernateException: JDBC Driver class not found:
at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:123)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)
at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2119)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2115)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1339)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
... 45 more
Caused by: java.lang.ClassNotFoundException:
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:118)
... 53 more
|#]
有谁发现我的连接参数有什么问题,或者知道 C3P0 如何缺少这些驱动程序?
编辑
我确实看到了一些问题,看起来像是由 C3P0 找不到驱动程序引起的,所以我也尝试将 C3P0 jar 放入 glassfish 库中,但仍然遇到相同的错误。这是下面评论中的错误,以更好的方式和更多信息。
[#|2011-04-28T12:37:49.964-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:49,964 INFO [FelixStartLevel] (JCLLoggerAdapter.java:265) - Mapping collection: com.jada.jpa.entity.ShippingType.shippingMethodRegionTypes -> shipping_method_region_type
|#]
[#|2011-04-28T12:37:50.009-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:50,008 INFO [FelixStartLevel] (JCLLoggerAdapter.java:265) - Hibernate Validator not found: ignoring
|#]
[#|2011-04-28T12:37:50.405-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:50,404 INFO [FelixStartLevel] (JCLLoggerAdapter.java:286) - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
|#]
[#|2011-04-28T12:37:50.491-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:50,490 INFO [FelixStartLevel] (JCLLoggerAdapter.java:265) - Initializing connection provider: org.hibernate.connection.C3P0ConnectionProvider
|#]
[#|2011-04-28T12:37:50.504-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:50,504 INFO [FelixStartLevel] (JCLLoggerAdapter.java:265) - C3P0 using driver: at URL:
|#]
[#|2011-04-28T12:37:50.506-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:50,505 INFO [FelixStartLevel] (JCLLoggerAdapter.java:265) - Connection properties: {user=, password=****, autocommit=true, release_mode=auto}
|#]
[#|2011-04-28T12:37:50.507-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:50,506 INFO [FelixStartLevel] (JCLLoggerAdapter.java:265) - autocommit mode: true
|#]
[#|2011-04-28T12:37:50.543-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:50,531 ERROR [FelixStartLevel] (JCLLoggerAdapter.java:535) - JDBC Driver class not found:
java.lang.ClassNotFoundException:
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:118)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)
at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2119)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2115)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1339)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:78)
at com.jada.jpa.connection.JpaConnection.init(JpaConnection.java:79)
at com.jada.system.Initializer.init(Initializer.java:162)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1428)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1230)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5007)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5280)
at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:928)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:912)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1947)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1619)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:236)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:362)
at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:185)
at com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:174)
at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:87)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:84)
at com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:77)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:236)
at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:128)
at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:457)
at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:401)
at org.jvnet.hk2.osgiadapter.HK2Main.start(HK2Main.java:125)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:915)
at org.jvnet.hk2.osgimain.Main.start(Main.java:140)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1077)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
at java.lang.Thread.run(Thread.java:619)
|#]
I am trying to get an application(jadasite) up and running using postgresql and glassfish. The app designers recommend tomcat and mysql. I can not really use tomcat and mysql for this app atm. The application uses JPA so postgresql should be no problem. The designers do mention that postgresql/many other db's should work.
So here is what I have done Using the following two pages as a reference:
jada.properties
log4j.directory=/tmp
hibernate.connection.password=password
working.directory=/tmp
encryption.key=fVOew3eAhr+hdZ9eQLeEtw\=\=
hibernate.connection.url=jdbc\:postgresql:dev-rdbms.example.com:5432/jada"/>
hibernate.connection.driver_class=org.postgresql.drivers
persistence.xml(parital)
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
<property name="hibernate.connection.username" value="jada"/>
<property name="hibernate.connection.password" value="password"/>
<property name="hibernate.connection.url" value="jdbc:postgresql://dev-rdbms.example.com:5432/jada>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.current_session_context_class" value="thread"/>
<property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"/
I then used mysql2psql to make a postgresql compatible db dump, loaded all data and created appropriate users with appropriate permissions and acces.(tested via psql from server glassfish runs on as well)
So after making the changes I put the lastest postgresql jdbc 4 driver into the applications WEB-INF/lib directory. Made a new war file and deployed it to my glassfish v3.01 server.
I get the following errors. Which appear to me to say C3P0 can not find the JDBC drivers(located in apps WEB-INF/lib directory and also in the glassfish domains lib directory)
[#|2011-04-28T11:34:58.508-0500|SEVERE|glassfish3.0.1|
javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=11;_ThreadName=FelixStartLevel;|WebModule[/jada]JadaSite: Unable to initialize JPA connection
javax.persistence.PersistenceException: [PersistenceUnit: jadaSite] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:78)
at com.jada.jpa.connection.JpaConnection.init(JpaConnection.java:79)
at com.jada.system.Initializer.init(Initializer.java:162)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1428)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1230)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5007)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5280)
at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:928)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:912)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1947)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1619)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:236)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:362)
at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:185)
at com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:174)
at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:87)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:84)
at com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:77)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:236)
at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:128)
at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:457)
at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:401)
at org.jvnet.hk2.osgiadapter.HK2Main.start(HK2Main.java:125)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:915)
at org.jvnet.hk2.osgimain.Main.start(Main.java:140)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1077)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.hibernate.HibernateException: JDBC Driver class not found:
at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:123)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)
at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2119)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2115)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1339)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
... 45 more
Caused by: java.lang.ClassNotFoundException:
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:118)
... 53 more
|#]
Does anyone see anything wrong with my connection paramaters or have any idea how C3P0 could be missing these drivers?
Edit
I did see some issues that looked like they were caused by C3P0 not finding the drivers so I did try throwing the C3P0 jar into the glassfish lib as well but still got the same errors. Here is the error from the comment below in a little nicer fasion and more info.
[#|2011-04-28T12:37:49.964-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:49,964 INFO [FelixStartLevel] (JCLLoggerAdapter.java:265) - Mapping collection: com.jada.jpa.entity.ShippingType.shippingMethodRegionTypes -> shipping_method_region_type
|#]
[#|2011-04-28T12:37:50.009-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:50,008 INFO [FelixStartLevel] (JCLLoggerAdapter.java:265) - Hibernate Validator not found: ignoring
|#]
[#|2011-04-28T12:37:50.405-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:50,404 INFO [FelixStartLevel] (JCLLoggerAdapter.java:286) - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
|#]
[#|2011-04-28T12:37:50.491-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:50,490 INFO [FelixStartLevel] (JCLLoggerAdapter.java:265) - Initializing connection provider: org.hibernate.connection.C3P0ConnectionProvider
|#]
[#|2011-04-28T12:37:50.504-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:50,504 INFO [FelixStartLevel] (JCLLoggerAdapter.java:265) - C3P0 using driver: at URL:
|#]
[#|2011-04-28T12:37:50.506-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:50,505 INFO [FelixStartLevel] (JCLLoggerAdapter.java:265) - Connection properties: {user=, password=****, autocommit=true, release_mode=auto}
|#]
[#|2011-04-28T12:37:50.507-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:50,506 INFO [FelixStartLevel] (JCLLoggerAdapter.java:265) - autocommit mode: true
|#]
[#|2011-04-28T12:37:50.543-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|2011-04-28 12:37:50,531 ERROR [FelixStartLevel] (JCLLoggerAdapter.java:535) - JDBC Driver class not found:
java.lang.ClassNotFoundException:
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:118)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)
at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2119)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2115)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1339)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:78)
at com.jada.jpa.connection.JpaConnection.init(JpaConnection.java:79)
at com.jada.system.Initializer.init(Initializer.java:162)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1428)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1230)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5007)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5280)
at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:928)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:912)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1947)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1619)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:236)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:362)
at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:185)
at com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:174)
at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:87)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:84)
at com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:77)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:236)
at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:128)
at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:457)
at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:401)
at org.jvnet.hk2.osgiadapter.HK2Main.start(HK2Main.java:125)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:915)
at org.jvnet.hk2.osgimain.Main.start(Main.java:140)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1077)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
at java.lang.Thread.run(Thread.java:619)
|#]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里有两件事看起来很奇怪:
1)ClassNotFoundException 的堆栈跟踪没有提到未找到的类的名称:
这似乎意味着它正在尝试加载一个没有名称的类,否则您会期望看到无法找到的类的名称。
2) 不确定这是否只是复制和粘贴错误,但在上面的配置片段中,您缺少此行的结束引号:
这会导致 XML 格式错误。
3)当你说
你的意思是说你创建了一个新的“war”文件,而不是“jar”?您需要确保 postgres jdbc jar 最终位于 glassfish 的类路径上。
Two things seem odd here:
1) the stacktrace for ClassNotFoundException does not mention the name of the class that was not found:
This would seem to imply that it is trying to load a class with no name, otherwise you would expect to see the name of the class that could not be found.
2) Not sure if it's just a copy and paste mistake, but in the snippet of your configuration above, you are missing the end-quote on this line:
which would make for malformed XML.
3) When you say
Do you mean to say you made a new "war" file, not "jar"? You need to make sure that the postgres jdbc jar is on glassfish's classpath ultimately.
让我们试试这个:
您正确使用 EJB(JPA 意味着 EJB)吗?那么,您至少有一个 EAR、一个 JAR 以及可能的一个 WAR,对吧?您知道,JAR 无法访问 WAR 文件。如果您的 postgresql jdbc 4 驱动程序位于 WAR/WEB-INF/lib 上,您的 JAR(需要它)将无法访问。
尝试将您的库放入 EAR 库中(为此查找 glassfish 文档,但也类似于 EAR/WEB-INF/lib )或将其放在服务器库中(类似于 GLASSFISH_DIR/lib/classes )
Let try this:
You use EJBs right (JPA means EJB)? So, you have at least one EAR, one JAR and possible one WAR, right? You know, JARs cannot access WARs files. If your postgresql jdbc 4 driver is on WAR/WEB-INF/lib your JARs (which need it) cannot access.
Try put your lib in a EAR lib (look for glassfish doc for that, but is something like EAR/WEB-INF/lib too) or put it on server libraries (something like GLASSFISH_DIR/lib/classes)
为什么属性文件中有
hibernate.connection.driver_class=org.postgresql.drivers
?难道不应该是 org.postgresql.Driver 吗?编辑:
啊!看起来 Jadasite 使用属性文件来加载驱动程序类。
来自 com/jada/jpa/connection/JpaConnection.java 类:
它被读作(在 com/jada/system/Initializer.java 中):
它来自(在
com/jada/install/process/Installer.java
):从文件中读取(在
com/jada/util/Constants.java
中):Why do you have
hibernate.connection.driver_class=org.postgresql.drivers
in the properties file? Shouldn't it beorg.postgresql.Driver
instead?Edit:
Ah! Looks like Jadasite uses the properties file to load the driver class.
From
com/jada/jpa/connection/JpaConnection.java
class:Which is read as (in
com/jada/system/Initializer.java
):Which comes from (in
com/jada/install/process/Installer.java
):Which is read from the file (in
com/jada/util/Constants.java
):