开发者社区> 问答> 正文

JFinal 连接Oracle,jetty调试正常,部署到tomcat就报错?报错

Eclipse IDE for Java EE Developers 中使用Jetty运行正常,配置的两个数据库Mysql和Oracle都可以访问,但部署到Tomcat中就报错不能连接数据库,先前验证过部署到Tomcat中Mysql是可以访问的

SEVERE: Exception starting filter jfinal

java.lang.RuntimeException: Plugin start error: com.jfinal.plugin.activerecord.ActiveRecordPlugin. 
java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.jfinal.core.Config.startPlugins(Config.java:95)
at com.jfinal.core.Config.configJFinal(Config.java:48)
at com.jfinal.core.JFinal.init(JFinal.java:67)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:424)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4076)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4730)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: com.jfinal.plugin.activerecord.ActiveRecordException: java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:48)
at com.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:171)
at com.jfinal.core.Config.startPlugins(Config.java:85)
... 30 more
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:36)
... 32 more
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)
... 34 more

展开
收起
爱吃鱼的程序员 2020-06-22 10:39:37 870 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    publicvoidconfigPlugin(Pluginsme){//========dfeesysdatabase=============C3p0PlugincpMysql=newC3p0Plugin("jdbc:mysql://10.222.22.9/jftest","staroul","loveyou11");me.add(cpMysql);ActiveRecordPluginarpMysql=newActiveRecordPlugin("mysql",cpMysql);me.add(arpMysql);arpMysql.addMapping("tbpsd",Tbpsd.class);arpMysql.addMapping("tbfs",Tbfs.class);//========cfabksdbreportdatabase==============C3p0PlugincpOracle=newC3p0Plugin("jdbc:oracle:thin:@10.222.64.101:1521:kkdb","xxxxx","5DDsw");me.add(cpOracle);ActiveRecordPluginarpOracle=newActiveRecordPlugin("oracle",cpOracle);me.add(arpOracle);}

    附上数据库的配置C3P0配置默认,并没有修改


    注意用户名所对应的权限,默认情况下非root用户是无法本地登录的,在控制台通过mysql-uuserName-p测试一下本地登录是否有权限

    是这样的,我本地IDE用jetty运行是正常的,可以连接本地架的Mysql和公司远程的Oracle,只是要部署到其他机器中的tomcat时就报这样的错。我也在本地装了tomcat来部署也有同样的问题,真不知道问题出现那里了

    AResourcePoolcouldnotacquirearesourcefromitsprimaryfactoryorsource.

    看报错应该是数据库连接获取不到,,如果确认不是数据库权限的问题,那就看看是不是连接已满了,把初始连接开大一点,mysql那也调大一点看看。

    @南湖船老大 我也在怀疑是数据库驱动包的问题,我在jar包引用中使用的是ojdbc6.jar。公司电脑上都装有oracleclient10.2.不知道是不是jetty和tomcat两种运行环境中加载的驱动包不同造成的,初学java,没有经验啊,不知道这种猜想有无可能

    找到问题所在了,在tomcat中部署的时候oracle的驱动要用Class.forName("oracle.jdbc.driver.OracleDriver")加载。 今天在eclipse中使用tomcat调试的时候看到有nosuitabledriver的报警,所以想到要用上面的语句加载一下驱动,但在jetty中却不用,mysql也不需要,不知为何

    2020-06-22 10:39:55
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
PostgresChina2018_樊文凯_ORACLE数据库和应用异构迁移最佳实践 立即下载
PostgresChina2018_王帅_从Oracle到PostgreSQL的数据迁移 立即下载
Oracle云上最佳实践 立即下载

相关镜像