Liferay:找不到合适的驱动程序 [英] Liferay: No suitable driver found

查看:105
本文介绍了Liferay:找不到合适的驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我当前的任务,我必须在liferay门户中部署我们的应用程序.部署本身是成功的,但是在应用程序启动时会引发没有合适的驱动程序"异常.

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.

环境:

  • Oracle 10g Express
  • Hibernate 4 Final
  • 带有Tomcat 7的Liferay 6
  • OJDBC 6
  • c3p0 0.9
  • 使用Maven构建

我们的应用程序的.war文件较旧,没有任何例外.但是,环境之间存在一些细微差异.

An older .war file of our app runs without any exceptions. However, there are some small differences in the environment.

旧环境:

  • Oracle 10g Express
  • Hibernate 3 Final
  • 带有Tomcat 7的Liferay 6
  • OJDBC 14
  • 休眠建立在连接池中
  • 没有maven的构建

我已经尝试过的事情:

  • 将ojdbc.jar从webapp lib文件夹移至liferay tomcat lib/ext文件夹
  • 在context.xml中强制执行Class Loader的"webapp类/库/资源优先"行为:
  • 删除c3p0以再次使用ojdbc14(我认为这可能是由ojdbc6引起的)
  • 在旧版本中将ojdbc14与ojdbc6交换(有效)

新的persistence.xml:

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>

旧的persistence.xml:

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?

谢谢.

Stacktrace:

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)

推荐答案

经过三天的调试,我终于找到了解决方案:

After three days of debugging I finally found the solution:

在某些情况下,hibernate/c3p0会忽略persistence.xml中给定的驱动程序类,因此-像异常状态一样-找不到合适的驱动程序.为了防止这种情况,我在c3p0-config.xml中添加了以下行:

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 :-)

这篇关于Liferay:找不到合适的驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆