I had a slightly similar problem using Oracle data sources with Oracle connection caching.
In this case, I had defined my connection settings via JNDI in context.xml. (therefore they were common for both web apps) Since the classes were loaded by Tomcat and not by my webapps, a datasource was being created by each webapp, but the cache names were having collisions. The first application was able to create the cache, but the second would fail because a cache instance with the same name already existed. I was able to avoid the problem by not giving a name to the cache, Oracle would create a random name for each and two instances of the cache would be created, one for each application. Could you have a similar issue with C3PO? I have never used it. On Sat, Sep 18, 2010 at 7:17 AM, Rahul Deb Mohan <ra...@zaloni.com> wrote: > Hello Everyone, > > I am using Hibernate to connect to my MySql Database using C3p0 connection > pooling mechanism from my web application which is deployed in Tomcat. > > Eventually, now I need to develop a child application, using the same > Database instance. > > So I have two application now : say Application A and Application B, and > both will be deployed in a Tomcat Server and both has to use the same > Database, let say my DB name is EmployeeDB. > > I defined Resource parameters separately for both of the application and > have done all the settings that are required for the connectivity. Now when > I deploy the applications, and try to run them, the first application ( it > may be Application A or Application B) loads up properly, but the second > application shows error as it could not connect to the Database. Whatever > application I load first, it successfully connect to the Database, but > second application fails to connect. > > I am guessing there must be some locking mechanism, provided by either > Hibernate or the Tomcat, which is preventing me to do so. > > Please help me to overcome this issue as that is my fundamental requirement > now. > > Thanks is advance. > > I am posting the stack trace hereby: > > [code]com.mchange.v2.cfg.BasicMultiPropertiesConfig: Properties object found > at resource path [system properties] contains a value that is not a String: > 25 > Skipping... > com.mchange.v2.cfg.BasicMultiPropertiesConfig: Properties object found at > resource path [system properties] contains a value that is not a String: 25 > Skipping... > 921 [http-8990-4] ERROR org.hibernate.connection.C3P0ConnectionProvider - > could not instantiate C3P0 connection pool > java.lang.NullPointerException > at java.util.Hashtable.put(Hashtable.java:394) > at > com.mchange.v2.c3p0.DataSources.pooledDataSource(DataSources.java:314) > at > org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:181) > at > org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137) > at > org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:79) > at > org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:448) > at > org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89) > at > org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101) > at > org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325) > at > com.duke.zaloni.studentdb.server.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:17) > at > com.duke.zaloni.studentdb.server.LoginServletImpl.doPost(LoginServletImpl.java:33) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) > at > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) > at > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) > at > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) > at java.lang.Thread.run(Thread.java:619) > Hibernate Error:::::Initial SessionFactory creation > failed.org.hibernate.HibernateException: Could not instantiate C3P0 > connection pool > org.hibernate.HibernateException: Could not instantiate C3P0 connection pool > at > org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:185) > at > org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137) > at > org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:79) > at > org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:448) > at > org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89) > at > org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101) > at > org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325) > at > com.duke.zaloni.studentdb.server.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:17) > at > com.duke.zaloni.studentdb.server.LoginServletImpl.doPost(LoginServletImpl.java:33) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) > at > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) > at > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) > at > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) > at java.lang.Thread.run(Thread.java:619) > Caused by: java.lang.NullPointerException > at java.util.Hashtable.put(Hashtable.java:394) > at > com.mchange.v2.c3p0.DataSources.pooledDataSource(DataSources.java:314) > at > org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:181) > ... 22 more > [/code] > > > Here is my Hibernate.Cfg.xml file: > > [code]<?xml version='1.0' encoding='utf-8'?> > <!DOCTYPE hibernate-configuration PUBLIC > "-//Hibernate/Hibernate Configuration DTD 3.0//EN" > "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> > > <hibernate-configuration> > > <session-factory name="java:hibernate/SessionFactory"> > > <property > name="hibernate.connection.datasource">java:comp/env/jdbc/EmployeeDB</property> > <property > name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property> > > <property name="hibernate.c3p0.acquire_increment">5</property> > <property name="hibernate.c3p0.idle_test_period">1800</property> > <!-- seconds --> > <property name="hibernate.c3p0.timeout">180</property> <!-- seconds > --> > <property name="hibernate.c3p0.max_size">100</property> > <property name="hibernate.c3p0.max_statements">500</property> > <property name="hibernate.c3p0.min_size">10</property> > > <property name="hibernate.c3p0.acquireRetryAttempts">30</property> > <property > name="hibernate.c3p0.testConnectionOnCheckout">true</property> > <property name="hibernate.c3p0.preferredTestQuery">SELECT > 1</property> > > <property > name="dialect">org.hibernate.dialect.MySQLDialect</property> > > <property name="current_session_context_class">thread</property> > > <property > name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> > > <property name="show_sql">false</property> > > <property name="connection.autocommit">false</property> > > <mapping resource="com/duke/zaloni/studentdb/data/user/User.hbm.xml" > /> > > </session-factory> > > </hibernate-configuration>[/code] > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org