[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Unable to Connect to C3P0 Connection Pool with JPA under 4.0
jantzen
do-not-reply at jboss.com
Mon Nov 6 02:31:00 EST 2006
Hi All,
I'm attempting to connect to a PostgreSQL database via a database pool and seeing some odd behavior:
JBoss 4.0.5
c3p0-0.9.1-pre6.jar
PostgreSQL 8.1
It looks to me that the pool is starting correctly, as I see it in the logs
| 22:26:16,920 INFO [C3P0PooledDataSource] Bound C3P0 PooledDataSource to name 'java:EventDBPool'. Starting...
| 22:26:16,951 INFO [PoolBackedDataSource] Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource at 5d11c3f0[ ...
| 22:26:16,993 INFO [JmxKernelAbstraction] installing MBean: persistence.units:ear=DataTier.ear,jar=DataTier.jar,unitName=EventDBUnit with dependencies:
| 22:26:16,994 INFO [JmxKernelAbstraction] jboss.jca:name=EventDBPool,service=DataSourceBinding
|
However below I see:
| --- MBeans waiting for other MBeans ---
| ObjectName: persistence.units:ear=DataTier.ear,jar=DataTier.jar,unitName=EventDBUnit
| State: NOTYETINSTALLED
| I Depend On:
| jboss.jca:name=EventDBPool,service=DataSourceBinding
|
| --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
| ObjectName: jboss.jca:name=EventDBPool,service=DataSourceBinding
| State: NOTYETINSTALLED
| Depends On Me:
| persistence.units:ear=DataTier.ear,jar=DataTier.jar,unitName=EventDBUnit
|
Here's my c3p0-service.xml:
<?xml version="1.0" encoding="UTF-8"?>
| <!DOCTYPE server PUBLIC "-//JBoss//DTD MBean Service 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss-service_4_0.dtd">
| <server>
| <mbean code="com.mchange.v2.c3p0.mbean.C3P0PooledDataSource" name="jboss:service=EventDBPooledDS">
| <attribute name="JndiName">java:EventDBPool</attribute>
| <attribute name="JdbcUrl">jdbc:postgresql://localhost/EventDB</attribute>
| <attribute name="DriverClass">org.postgresql.Driver</attribute>
| <attribute name="User">myuser</attribute>
| <attribute name="Password">mypass</attribute>
| <attribute name="IdleConnectionTestPeriod">90</attribute>
| <attribute name="MaxPoolSize">15</attribute>
| <attribute name="MinPoolSize">5</attribute>
| <attribute name="TestConnectionOnCheckin">true</attribute>
|
| <depends>jboss:service=Naming</depends>
| </mbean>
| </server>
|
And my persistence.xml
| <?xml version="1.0" encoding="UTF-8"?>
| <persistence xmlns="http://java.sun.com/xml/ns/persistence"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| version="1.0">
| <persistence-unit name="EventDBUnit" transaction-type="JTA">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:EventDBPool</jta-data-source>
| <properties>
| <property name="hibernate.show_sql" value="true" />
| </properties>
| </persistence-unit>
|
Also, if I create an EntityManagerFactory from that persistence unit directly in my code, I'm able to use it. However, if I use dependency injection via @PersistenceContext it doesn't work.
My questions:
1) is there an error in my persistence.xml or c3p0-service.xml preventing startup or connection to the pool?
2) ought I to be using c3p0 still or JBoss's ManagedConnectionPool?
Thanks in advance,
David
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3983368#3983368
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3983368
More information about the jboss-user
mailing list