I have an application which is implemented in two ways: one implementation uses a web front end (html, servlets, tomcat, etc), and the other uses a swing front end with no app server or servlet engine of any kind.
The web front-end implementation works like a champ! (I did it first.) I am having problems making the swing standalone implementation work. I obviously had to modify the configuration some (no tomcat, no jndi, no tomcat connection pool, etc). I have solved many problems of configuration to get to this point, but now I believe I have a complete and sound configuration (maybe not) but the application craters with an exception I can't sort out when the code executes the HibernateUtil. As best I can tell it never returns from trying to build the session factory.
Here is the exception report I get:
Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@6545d2 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@1dd9891 [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, idleConnectionTestPeriod -> 3000, initialPoolSize -> 20, maxIdleTime -> 300, maxPoolSize -> 100, maxStatements -> 50, maxStatementsPerConnection -> 0, minPoolSize -> 20, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@c0c8b5 [ description -> null, driverClass -> null, factoryClassLocation -> null, jdbcUrl -> jdbc:mysql://localhost:3306/CSRapp, properties -> {user=******, password=******} ] , preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ] , factoryClassLocation -> null, numHelperThreads -> 3, poolOwnerIdentityToken -> 6545d2 ]
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError
at org.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.java:321)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at suncertify.db.HibernateUtil.<clinit>(Unknown Source)
at suncertify.db.ModelFacade.findAllLikeThis(Unknown Source)
at suncertify.client.gui.SelectionPage.findAllLikeThis(Unknown Source)
at suncertify.client.gui.SelectionPage.doSearch(Unknown Source)
at suncertify.client.gui.SelectionPage.access$000(Unknown Source)
at suncertify.client.gui.SelectionPage$4.actionPerformed(Unknown Source) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
The first part is the report back from a (successful, I think) startup of the c3p0 connection pooling facility. I include it because it shows many configuration parameters. Then there is this exception ... a NoClassDefFoundError, but I cannot identify what class it can't find ... and it looks to me that it is deep in the hibernate code when it craters. Notice that it does not report an Initializer error. I looked at line 321 in the source for SessionFactoryImpl but that didn't really tell me anything I could use.
My hibernate.cfg.xml follows:
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/CSRapp </property>
<property name="connection.username">CSRapp</property>
<property name="connection.password">XXXX</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="c3p0.min_size">20</property>
<property name="c3p0.max_size">100</property>
<property name="c3p0.timeout">300</property>
<property name="c3p0.max_statements">50</property>
<property name="c3p0.idle_test_period">3000</property>
<property name="show.sql">false</property>
<!-- Mapping files -->
<mapping resource="suncertify/client/ServiceProvider.hbm.xml"/>
</session-factory>
</hibernate-configuration>
I will certainly be grateful for any guidance any of you might like to offer. I have beat my head against this brick wall longer than a fella should ever have to do.
Frankly, I believe the problem is related to the fact that it is running in a non-managed environment. The symptoms suggest to me this is either an internal hibernate problem (dare I say bug?) or it certainly could be some configuration issue I have overlooked (but all the configuration issues seem to have executed successfully) ... or... lord knows what else it might be.
Remember, both implementations use exactly the same classes at the back end. The successful web implementation runs through the very same code as does this implementation which does not succeed. I am surely puzzled!
|