Liferay:找不到合适的驱动程序

编程入门 行业动态 更新时间:2024-10-27 14:19:50
本文介绍了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:找不到合适的驱动程序

本文发布于:2023-10-18 23:41:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1505760.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   驱动程序   合适   Liferay

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!