-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: c3po integregation with hibernate causes exception
PostPosted: Wed Jun 27, 2007 4:03 pm 
Newbie

Joined: Wed Jun 27, 2007 3:32 pm
Posts: 3
I'm having a problem with enabling c3po connection pooling with hibernate. I'm using hibernate 3.2.1.sp1 and c3po-0.9.1.jar. My context is a junit 3.8.1 test suite running inside of MyEclipse 5.1 w/ jdk 1.5. My db is oracle 8.1.

My junit test works fine. Until I attempt to specify a simple c3po connection pool inside my hibernate.cfg.xml file. If I add that, I get the following exception:
Code:
.
.
.
2266 [main] DEBUG org.hibernate.cfg.Configuration  - resolving reference to class: com.objectresourcegroup.hibernate.Courtplan
2369 [main] INFO  org.hibernate.connection.C3P0ConnectionProvider  - C3P0 using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@smaug:1521:cprs2
2369 [main] INFO  org.hibernate.connection.C3P0ConnectionProvider  - Connection properties: {user=cprs2, password=****}
2369 [main] INFO  org.hibernate.connection.C3P0ConnectionProvider  - autocommit mode: false
2393 [main] INFO  com.mchange.v2.log.MLog  - MLog clients using log4j logging.
E
Time: 2.452
There was 1 error:
1) junit.framework.TestSuite@823918java.lang.NoClassDefFoundError: org/jboss/mx/util/PropertyAccess
        at javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:202)
        at javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:153)
        at javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:147)
        at sun.management.ManagementFactory.createPlatformMBeanServer(ManagementFactory.java:264)
        at java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:512)
        at com.mchange.v2.c3p0.management.ActiveManagementCoordinator.<init>(ActiveManagementCoordinator.java:42)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at java.lang.Class.newInstance0(Class.java:350)
        at java.lang.Class.newInstance(Class.java:303)
        at com.mchange.v2.c3p0.C3P0Registry.<clinit>(C3P0Registry.java:134)
        at com.mchange.v2.c3p0.impl.DriverManagerDataSourceBase.<init>(DriverManagerDataSourceBase.java:206)
        at com.mchange.v2.c3p0.DriverManagerDataSource.<init>(DriverManagerDataSource.java:60)
        at com.mchange.v2.c3p0.DriverManagerDataSource.<init>(DriverManagerDataSource.java:56)
        at com.mchange.v2.c3p0.DataSources.unpooledDataSource(DataSources.java:152)
        at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:154)
        at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
        at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
        at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414)
        at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
        at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
        at com.org.hibernate.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:60)
        at com.org.hibernate.HibernateSessionFactory.getSession(HibernateSessionFactory.java:43)
        at com.org.hibernate.junit.HibernateTestSuiteSetup.setUp(HibernateTestSuiteSetup.java:31)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:18)
        at junit.extensions.TestSetup.run(TestSetup.java:23)
        at com.objectresourcegroup.hibernate.junit.CountyHibernateTest.main(CountyHibernateTest.java:36)


I have no idea why I'm getting an exception on a jboss/jmx PropertyAccess class not found. I'm not using boss at all. I tried to add the jboss-jmx.jar file to my classpath, but that did not fix the problem either.

Any ideas?

Here's my config file:
Code:
<hibernate-configuration>

        <session-factory>
                <property name="hibernate.connection.username">cprs2</property>
                <property name="hibernate.connection.url"> jdbc:oracle:thin:@smaug:1521:cprs2 </property>
                <property name="hibernate.dialect"> org.hibernate.dialect.OracleDialect </property>
                <property name="hibernate.connection.password">****</property>
                <property name="hibernate.connection.driver_class"> oracle.jdbc.driver.OracleDriver </property>

<!--             configuration pool via c3p0 -->
                <property name="hibernate.c3p0.min_size">10</property>
                <property name="hibernate.c3p0.max_size">100</property>
                <property name="hibernate.c3p0.max_statements">0</property>
                <property name="hibernate.c3p0.timeout">100</property>
                <property name="hibernate.c3p0.idle_test_period">100</property>

                <!-- hibernate mapping files -->
                <mapping resource="com/org/hibernate/Courtplan.hbm.xml" />
        </session-factory>
</hibernate-configuration>
/>


Top
 Profile  
 
 Post subject: disable c3p0 jmx management
PostPosted: Wed Jun 27, 2007 4:46 pm 
Newbie

Joined: Wed Jun 27, 2007 3:32 pm
Posts: 3
Well, you search and search for hours and don't find an answer. So, you post to the forum. Then... you find a solution. So, perhaps this will help some other poor soul:

Apparently c3p0 will attempt to make JMX management available if JMX libraries are available in your environment. In JDK 1.5 they are there. For whatever reason, this was breaking during my junit tests.

No matter, since I don't use JMX here anyway. The solution is to tell c3p0 not to register mbeans w/ the JMX environment. To do this you can set a system property or create a c3p0.properties file (which is what I did) that contains the following entry:

com.mchange.v2.c3p0.management.ManagementCoordinator=com.mchange.v2.c3p0.management.NullManagementCoordinator

One note: I had an errant space on the end of that line in the c3p0.properties file which caused a ClassNotFound exception. Yeesh.

So, c3p0 is working for me now. Except... I wish I could put the entry that is in the c3p0.properties file into the hibernate.cfg.xml file instead.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.