[已解决]jfinal3.2 连接 sqlserver c3p0 启动配置的时候报错

########################################

[a_little_config.txt]如下

driverClass = com.microsoft.sqlserver.jdbc.SQLServerDriver

jdbcUrl = jdbc:sqlserver://127.0.0.1:1433;DatabaseName=THwebDB

user = sa

password = keMI123456

devMode = true

########################################

[tomcat报错信息]如下

03-Nov-2017 18:10:33.865 严重 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.filterStart Exception starting filter [jfinal]

 java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector

at com.jfinal.plugin.c3p0.C3p0Plugin.start(C3p0Plugin.java:150)

at com.jfinal.core.Config.startPlugins(Config.java:107)

at com.jfinal.core.Config.configJFinal(Config.java:53)

at com.jfinal.core.JFinal.init(JFinal.java:63)

at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)

at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:285)

at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:266)

at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)

at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4591)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5233)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)

at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1739)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)

at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)

at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:482)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:431)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)

at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)

at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)

at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)

at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)

at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)

at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)

at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)

at sun.rmi.transport.Transport$1.run(Transport.java:200)

at sun.rmi.transport.Transport$1.run(Transport.java:197)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.Transport.serviceCall(Transport.java:196)

at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at java.lang.Thread.run(Thread.java:748)

Caused by: java.lang.ClassNotFoundException: com.mchange.v2.ser.Indirector

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1291)

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)

... 53 more

########################################

[DemoConfig]如下

//c3p0连接池插件

C3p0Plugin C3p0Plugin = createC3p0Plugin();

me.add(C3p0Plugin);

//数据库操作插件

ActiveRecordPlugin arp = new ActiveRecordPlugin(C3p0Plugin);

me.add(arp);

//设置方言(很重要,一定要设置)

//arp.setDialect(new AnsiSqlDialect());

//arp.addMapping("[lumosity].[account].[account]", "userId", Account.class);



ps:注释掉c3p0插件就运行ok了

报错信息来看应该是在c3p0配置start的时候有问题

大大大大牛们求看看

评论区

易风miao

2017-11-03 18:46

已解决,第一句话说的很清楚,缺少com/mchange/v2/ser/Indirector

易风miao

2017-11-03 18:48

看了一下,很多人也有这个问题.丢个c3p0的链接在这,解压开后,有3个jar包,其中c3p0还需要依赖mchange这个jar包,注意c3p0版本需要和mchange版本匹配,不能随意下载一个放进去
c3p0下载地址:https://sourceforge.net/projects/c3p0/?source=typ_redirect

易风miao

2017-11-03 18:48

补充看到的别人的同样的问题解决之路:http://www.cnblogs.com/Tmc-Blog/p/5797706.html

JFinal

2017-11-03 19:19

@易风miao 感谢你的分享

JFinal

2017-11-03 19:20

@易风miao 建议使用 DuirdPlugin 代替 C3p0Plugin,后者太古老了,而且很久没升级了

易风miao

2017-11-03 21:28

@JFinal 好的.我主要是做客户端的,服务器刚入门没多久,希望能帮助到大家

热门反馈

扫码入社