对于我当前的任务,我必须在liferay门户中部署我们的应用程序。部署本身是成功的,但是当应用程序启动时,会抛出“No suitable driver”异常。
环境:
我们的应用程序的旧.war文件运行没有任何例外。但是,环境存在一些细微差别。
旧环境:
我已经尝试过的事情:
新的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>
旧的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>
您是否知道如何解决问题或找到根本原因?
提前致谢。
编辑:
堆栈跟踪:
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)
答案 0 :(得分:5)
经过三天的调试后,我终于找到了解决方案:
在某些情况下,histencenate / c3p0会忽略persistence.xml中的给定驱动程序类,并且由于这种情况 - 就像异常状态一样 - 找不到合适的驱动程序。为了防止这种情况,我将以下行添加到我的c3p0-config.xml中:
<property name="driverClass">oracle.jdbc.driver.OracleDriver</property>
我希望它也有助于其他人: - )