Reputation: 367
For my current task I have to deploy our application in a liferay portal. The deployment itself was successful, but when the application is at start up a "No suitable driver" exception is thrown.
Environment:
An older .war file of our app runs without any exceptions. However, there are some small differences in the environment.
Old environment:
Things I already tried:
New persistence.xml:
<persistence-unit name="ipointdefault">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<mapping-file>META-INF/hbm.xml</mapping-file>
<class>Entity declaration...</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@HOST:PORT:DB" />
<property name="javax.persistence.jdbc.user" value="user" />
<property name="javax.persistence.jdbc.password" value="pw" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.archive.autodetection" value="class" />
<property name="hibernate.current_session_context_class" value="thread" />
<property name="hibernate.connection.pool_size" value="10" />
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider" />
<property name="hibernate.bytecode.use_reflection_optimizer" value="true" />
<property name="hibernate.c3p0.acquire_increment" value="3" />
<property name="hibernate.c3p0.min_size" value="3" />
<property name="hibernate.c3p0.max_size" value="5" />
<property name="hibernate.c3p0.timeout" value="10800" />
<property name="hibernate.c3p0.idleConnectionTestPeriod" value="1800" />
<property name="hibernate.c3p0.max_statements" value="0" />
</properties>
Old persistence.xml:
<persistence-unit name="ipointdefault">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>Entity declaration...</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@HOST:PORT:DB" />
<property name="javax.persistence.jdbc.user" value="user" />
<property name="javax.persistence.jdbc.password" value="pw" />
<property name="hibernate.default-access" value="property" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.archive.autodetection" value="class" />
<property name="hibernate.current_session_context_class" value="thread" />
<property name="hibernate.connection.pool_size" value="10" />
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider" />
<property name="hibernate.bytecode.use_reflection_optimizer" value="true" />
</properties>
Do you have any idea how to solve the problem or to find the root cause at all?
Thanks in advance.
Edit:
Stacktrace:
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:264)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:224)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:135)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Upvotes: 2
Views: 6503
Reputation: 367
After three days of debugging I finally found the solution:
Under certain circumstances the given driver class in the persistence.xml was ignored by hibernate/ c3p0 and because of this -like the exception states- no suitable driver could be found. To prevent this I added the following line to my c3p0-config.xml:
<property name="driverClass">oracle.jdbc.driver.OracleDriver</property>
I hope it helps others as well :-)
Upvotes: 5