JFinal 升级到3.0之后,链接数据库报错。

把项目升级到3.0之后,使用XXConfig中的main方法启动项目时,出现如下错误:

2017-03-04 16:34:45[INFO]-[Thread: main]-[com.hm.astock.manage.config.ManageConfig.configPlugin()]: redis 连接信息.缓存名称: astock,主机:120.77.217.142,端口:6389

2017-03-04 16:34:45[INFO]-[Thread: main]-[com.hm.astock.manage.config.ManageConfig.configPlugin()]: 常用参数缓存插件

2017-03-04 16:34:47[ERROR]-[Thread: main]-[com.alibaba.druid.pool.DruidDataSource.init()]: init datasource error

java.sql.SQLException: java.lang.IllegalAccessError: class sun.reflect.GeneratedConstructorAccessor2 cannot access its superclass sun.reflect.ConstructorAccessorImpl

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:937)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:872)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:904)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:894)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:418)

at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)

at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)

at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:148)

at com.alibaba.druid.filter.FilterAdapter.connection_connect(FilterAdapter.java:786)

at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:142)

at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:211)

at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:142)

at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1360)

at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1414)

at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:602)

at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:876)

at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:872)

at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:97)

at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:38)

at com.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:209)

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.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:119)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)

at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:724)

at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)

at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)

at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:706)

at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)

at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)

at org.eclipse.jetty.server.Server.doStart(Server.java:277)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)

at com.jfinal.server.JettyServer.doStart(JettyServer.java:131)

at com.jfinal.server.JettyServer.start(JettyServer.java:70)

at com.jfinal.core.JFinal.start(JFinal.java:159)

at com.hm.astock.manage.config.ManageConfig.main(ManageConfig.java:124)

Caused by: java.lang.IllegalAccessError: class sun.reflect.GeneratedConstructorAccessor2 cannot access its superclass sun.reflect.ConstructorAccessorImpl

at sun.misc.Unsafe.defineClass(Native Method)

at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:63)

at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:399)

at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:394)

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

at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:393)

at sun.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java:92)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:55)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:422)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)

at com.mysql.jdbc.ResultSetImpl.getInstance(ResultSetImpl.java:339)

at com.mysql.jdbc.MysqlIO.buildResultSetWithRows(MysqlIO.java:3026)

at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:469)

at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:3009)

at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:2257)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2650)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2541)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2499)

at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1432)

at com.mysql.jdbc.ConnectionImpl.loadServerVariables(ConnectionImpl.java:3870)

at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3284)

at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2122)

at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2084)

at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)

at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:422)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)

... 34 more

Can not create Table object, maybe the table account_bank is not exists.

2017-03-04 16:34:48[ERROR]-[Thread: main]-[com.jfinal.core.Config.startPlugins()]: Plugin start error: com.jfinal.plugin.activerecord.ActiveRecordPlugin. 

java.sql.SQLException: Error

com.jfinal.plugin.activerecord.ActiveRecordException: java.sql.SQLException: Error

at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:50)

at com.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:209)

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.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:119)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)

at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:724)

at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)

at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)

at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:706)

at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)

at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)

at org.eclipse.jetty.server.Server.doStart(Server.java:277)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)

at com.jfinal.server.JettyServer.doStart(JettyServer.java:131)

at com.jfinal.server.JettyServer.start(JettyServer.java:70)

at com.jfinal.core.JFinal.start(JFinal.java:159)

at com.hm.astock.manage.config.ManageConfig.main(ManageConfig.java:124)

Caused by: java.sql.SQLException: Error

at com.alibaba.druid.pool.DruidDataSource.handleConnectionException(DruidDataSource.java:1116)

at com.alibaba.druid.pool.DruidPooledConnection.handleException(DruidPooledConnection.java:127)

at com.alibaba.druid.pool.DruidPooledStatement.checkException(DruidPooledStatement.java:68)

at com.alibaba.druid.pool.DruidPooledStatement.executeQuery(DruidPooledStatement.java:154)

at com.jfinal.plugin.activerecord.TableBuilder.doBuild(TableBuilder.java:66)

at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:42)

... 20 more

Caused by: java.lang.ExceptionInInitializerError

at com.alibaba.druid.wall.spi.MySqlWallVisitor.preVisit(MySqlWallVisitor.java:394)

at com.alibaba.druid.sql.ast.SQLObjectImpl.accept(SQLObjectImpl.java:38)

at com.alibaba.druid.wall.WallProvider.checkInternal(WallProvider.java:656)

at com.alibaba.druid.wall.WallProvider.check(WallProvider.java:586)

at com.alibaba.druid.wall.WallFilter.check(WallFilter.java:694)

at com.alibaba.druid.wall.WallFilter.statement_executeQuery(WallFilter.java:491)

at com.alibaba.druid.filter.FilterChainImpl.statement_executeQuery(FilterChainImpl.java:2360)

at com.alibaba.druid.filter.FilterAdapter.statement_executeQuery(FilterAdapter.java:2482)

at com.alibaba.druid.filter.FilterEventAdapter.statement_executeQuery(FilterEventAdapter.java:302)

at com.alibaba.druid.filter.FilterChainImpl.statement_executeQuery(FilterChainImpl.java:2360)

at com.alibaba.druid.proxy.jdbc.StatementProxyImpl.executeQuery(StatementProxyImpl.java:211)

at com.alibaba.druid.pool.DruidPooledStatement.executeQuery(DruidPooledStatement.java:143)

... 22 more

 1.使用的Druid版本是1.0.5.

 2.debug后发现是在启动plugin时报错。

3.错误信息中提到 Can not create Table object, maybe the table account_bank is not exists. 我可以确定数据库中是有这个表的。

实在找不到原因,来求助了 @JFINAL

评论区

junkai007

2018-01-18 17:41

@JFinal http://www.jfinal.com/feedback/2429 用这个解决的,谢谢!

之乎者也

2018-02-07 14:37

@梦下花开 对eclipse也需要删除这个参数,头疼好久

wenwen

2018-04-22 20:29

4.7.2也不行,删了参数解决的,好蛋疼啊

Terry

2018-05-30 10:08

果然在 Eclipse 下,也需要删除最后的一个参数。。。。折腾好久时间

热门反馈

扫码入社