之前一直用的jfinal老版本3.5,一直很稳定,看到4.2发布了,于是决定与时俱进升级一下。但是,问题来了,启动很正常,但是涉及到service调用的基本都报错。注:4.2在本机windows下调试的时候也正常,但是部署到linux服务器上之后出问题了。
Caused by: java.lang.ClassNotFoundException: com.work.web.system.daolian.DaoLianService$$EnhancerByJFinal at java.lang.ClassLoader.findClass(ClassLoader.java:530) at com.jfinal.proxy.ProxyClassLoader.findClass(ProxyClassLoader.java:64) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at com.jfinal.proxy.ProxyClassLoader.loadProxyClass(ProxyClassLoader.java:49) at com.jfinal.proxy.ProxyFactory.getProxyClass(ProxyFactory.java:70) at com.jfinal.proxy.ProxyFactory.get(ProxyFactory.java:41) at com.jfinal.proxy.Proxy.get(Proxy.java:32) at com.jfinal.aop.Duang.duang(Duang.java:42) at com.work.web.system.daolian.DaoLianService.<clinit>(DaoLianService.java:16) at com.work.web.system.daolian.DaoLianController.<init>(DaoLianController.java:20) 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:423) at java.lang.Class.newInstance(Class.java:442) at com.jfinal.core.ControllerFactory.getController(ControllerFactory.java:25) at com.jfinal.core.ActionHandler.handle(ActionHandler.java:76) at com.core.handler.XssHandler.handle(XssHandler.java:31) at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:89) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610) at com.core.filter.LoginFilter.chainAdmin(LoginFilter.java:115) at com.core.filter.LoginFilter.doFilter(LoginFilter.java:48) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610) at com.core.filter.WebFilter.doFilter(WebFilter.java:86) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610) at com.core.filter.DomainFilter.doFilter(DomainFilter.java:50) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1602) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1588) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1557) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.Server.handle(Server.java:502) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onFillable(SslConnection.java:411) at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:305) at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:159) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126) at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683) at java.lang.Thread.run(Thread.java:748) Jun 07, 2019 8:34:23 PM com.jfinal.proxy.ProxyCompiler error SEVERE: /SessionService$$EnhancerByJFinal.java:3: error: package com.jfinal.aop does not exist import com.jfinal.aop.Invocation; ^ Jun 07, 2019 8:34:23 PM com.jfinal.proxy.ProxyCompiler error SEVERE: /SessionService$$EnhancerByJFinal.java:4: error: cannot find symbol public class SessionService$$EnhancerByJFinal extends SessionService { ^ symbol: class SessionService Jun 07, 2019 8:34:23 PM com.jfinal.proxy.ProxyCompiler error SEVERE: /SessionService$$EnhancerByJFinal.java:6: error: package com.core.tools does not exist public void del(com.core.tools.PageData p0) throws java.lang.Exception { ^ Jun 07, 2019 8:34:23 PM com.jfinal.proxy.ProxyCompiler error SEVERE: /SessionService$$EnhancerByJFinal.java:7: error: cannot find symbol Invocation inv = new Invocation(this, 13L, ^ symbol: class Invocation location: class com.work.web.system.session.SessionService$$EnhancerByJFinal Jun 07, 2019 8:34:23 PM com.jfinal.proxy.ProxyCompiler error SEVERE: /SessionService$$EnhancerByJFinal.java:7: error: cannot find symbol Invocation inv = new Invocation(this, 13L, ^ symbol: class Invocation location: class com.work.web.system.session.SessionService$$EnhancerByJFinal
总结一下,以上核心的报错如下:
Caused by: java.lang.ClassNotFoundException: com.work.web.system.daolian.DaoLianService$$EnhancerByJFinal Jun 07, 2019 8:34:23 PM com.jfinal.proxy.ProxyCompiler error SEVERE: /SessionService$$EnhancerByJFinal.java:3: error: package com.jfinal.aop does not exist Jun 07, 2019 8:34:23 PM com.jfinal.proxy.ProxyCompiler error SEVERE: /SessionService$$EnhancerByJFinal.java:7: error: cannot find symbol Invocation inv = new Invocation(this, 13L,
在社区看到一篇帖子,跟我的情况很像,但是帖子并没有给出解决方案。http://www.jfinal.com/feedback/5931
目前我还在排查原因,尚未解决。已经暂时降到3.5版本了,降级后一切恢复正常。
------------------------------------
后续补充:
1.如果是web项目,jfinal最新版本已经解决上述问题
2.如果是非web项目,手动指定cglib为代理库可解决问题:ProxyManager.me().setProxyFactory(new CglibProxyFactory()); 更多请参考在线文档:https://jfinal.com/doc/4-8