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:
Hibernate Docs
Jadasite forums
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(InjectionSettingsFacto开发者_如何学JAVAry.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)
|#]
Two things seem odd here:
1) the stacktrace for ClassNotFoundException does not mention the name of the class that was not found:
Caused by: java.lang.ClassNotFoundException:
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:
<property name="hibernate.connection.url"
value="jdbc:postgresql://dev-rdbms.example.com:5432/jada>
which would make for malformed XML.
3) When you say
Made a new jar file and deployed it to my glassfish v3.01 server.
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.
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)
Why do you have hibernate.connection.driver_class=org.postgresql.drivers
in the properties file? Shouldn't it be org.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:
67
68 public void init(String driver, String url, String user, String password) throws Exception {
69 this.driver = driver;
70 this.url = url;
71 this.user = user;
72 this.password = password;
73
74 HashMap<String, String> map = new HashMap<String, String>();
75 map.put(Environment.DRIVER, driver);
76 map.put(Environment.URL, url);
77 map.put(Environment.USER, user);
78 map.put(Environment.PASS, password);
79 factory = Persistence.createEntityManagerFactory("jadaSite", map);
80 }
Which is read as (in com/jada/system/Initializer.java
):
111 if (requireInstall) {
112 if (!installCompleted) {
113 log("Installation has not been done. Skipping custom initialization.");
114 log("Please proceed to installation and remmember to restart before continue.");
115 log("Awaiting installation....");
116 return;
117 }
118 try {
119 Properties installProperties = installer.getConfigProperties();
Which comes from (in com/jada/install/process/Installer.java
):
345 public Properties getConfigProperties() throws IOException {
346 String filename = servletLocation + Constants.CONFIG_PROPERTIES_FILENAME;
347 File file = new File(filename);
348 FileInputStream input = new FileInputStream(file);
349 Properties properties = new Properties();
350 properties.load(input);
351 return properties;
352 }
Which is read from the file (in com/jada/util/Constants.java
):
275 public static final String CONFIG_PROPERTIES_FILENAME = "WEB-INF/jada.properties";
精彩评论