Liferay的:没有合适的驱动程序找到(Liferay: No suitable driver f

2019-09-17 16:24发布

对于我目前的任务,我必须部署我们在Liferay门户应用。 部署本身是成功的,但是当应用程序在启动时“无合适的驱动程序”会抛出异常。

环境:

  • 甲骨文10g快捷
  • 休眠4决赛
  • Liferay的6使用Tomcat 7
  • OJDBC 6
  • C3P0 0.9
  • 与Maven构建

我们的应用程序的一个旧的.war文件运行没有任何异常。 不过,也有环境的一些小的差异。

旧的环境:

  • 甲骨文10g快捷
  • Hibernate 3的最终
  • Liferay的6使用Tomcat 7
  • OJDBC 14
  • 在连接池Hibernate的构建
  • 建立一个没有行家

事情我已经尝试过:

  • 从移动Web应用程序的lib文件夹中ojdbc.jar到Liferay的Tomcat的lib / ext文件夹
  • 强制执行的context.xml类加载器的“Web应用类/库/第一资源”的行为:
  • 删除C3P0再次使用ojdbc14(我认为这可能ojdbc6引起的)
  • SWAP与ojdbc6的ojdbc14在旧版本(它的工作原理)

新的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)

Answer 1:

调试后三天,我终于找到了解决办法:

在某些情况下在persistence.xml给定的驱动程序类是由休眠/ C3P0忽略,因为这样明─没有合适的驱动程序,可以发现异常。 为了防止这种情况,我添加下面一行到我C3P0-config.xml文件:

<property name="driverClass">oracle.jdbc.driver.OracleDriver</property>

我希望它能帮助其他人也:-)



文章来源: Liferay: No suitable driver found