使用@Before(Tx.class)后抛异常

image.png



Starting JFinal 4.8
Starting Jetty Server 9.4.z-SNAPSHOT on port: 9999
四月 23, 2020 4:59:28 下午 com.alibaba.druid.pool.DruidDataSource info
信息: {dataSource-1} inited
Starting Complete. Welcome To The JFinal World (^_^)
四月 23, 2020 4:59:32 下午 com.jfinal.proxy.ProxyCompiler error
严重: /StudentService$$EnhancerByJFinal.java:3: 错误: 程序包com.jfinal.aop不存在
import com.jfinal.aop.Invocation;
                     ^
四月 23, 2020 4:59:32 下午 com.jfinal.proxy.ProxyCompiler error
严重: /StudentService$$EnhancerByJFinal.java:4: 错误: 找不到符号
public class StudentService$$EnhancerByJFinal extends StudentService {
                                                      ^
  符号: 类 StudentService
四月 23, 2020 4:59:32 下午 com.jfinal.proxy.ProxyCompiler error
严重: /StudentService$$EnhancerByJFinal.java:6: 错误: 程序包cn.hutool.json不存在
 public  java.lang.String addStudent(cn.hutool.json.JSONObject p0) {
                                                   ^
四月 23, 2020 4:59:32 下午 com.jfinal.proxy.ProxyCompiler error
严重: /StudentService$$EnhancerByJFinal.java:7: 错误: 找不到符号
  Invocation inv = new Invocation(this, 1L,
  ^
  符号:   类 Invocation
  位置: 类 com.studentmanagement.service.StudentService$$EnhancerByJFinal
四月 23, 2020 4:59:32 下午 com.jfinal.proxy.ProxyCompiler error
严重: /StudentService$$EnhancerByJFinal.java:7: 错误: 找不到符号
  Invocation inv = new Invocation(this, 1L,
                       ^
  符号:   类 Invocation
  位置: 类 com.studentmanagement.service.StudentService$$EnhancerByJFinal
四月 23, 2020 4:59:32 下午 com.jfinal.proxy.ProxyCompiler error
严重: /StudentService$$EnhancerByJFinal.java:22: 错误: 找不到符号
  Invocation inv = new Invocation(this, 2L,
  ^
  符号:   类 Invocation
  位置: 类 com.studentmanagement.service.StudentService$$EnhancerByJFinal
四月 23, 2020 4:59:32 下午 com.jfinal.proxy.ProxyCompiler error
严重: /StudentService$$EnhancerByJFinal.java:22: 错误: 找不到符号
  Invocation inv = new Invocation(this, 2L,
                       ^
  符号:   类 Invocation
  位置: 类 com.studentmanagement.service.StudentService$$EnhancerByJFinal
四月 23, 2020 4:59:32 下午 com.jfinal.core.ActionHandler error
严重: com.studentmanagement.controller.StudentManController.index() : /student
java.lang.RuntimeException: java.lang.ClassNotFoundException: com.studentmanagement.service.StudentService$$EnhancerByJFinal
 at com.jfinal.proxy.ProxyClassLoader.loadProxyClass(ProxyClassLoader.java:51)
 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.AopFactory.createObject(AopFactory.java:181)
 at com.jfinal.aop.AopFactory.doGetSingleton(AopFactory.java:91)
 at com.jfinal.aop.AopFactory.doGet(AopFactory.java:65)
 at com.jfinal.aop.AopFactory.doInject(AopFactory.java:165)
 at com.jfinal.aop.AopFactory.inject(AopFactory.java:133)
 at com.jfinal.aop.Aop.inject(Aop.java:105)
 at com.jfinal.core.ActionHandler.handle(ActionHandler.java:84)
 at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:90)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1634)
 at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
 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:1595)
 at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
 at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1340)
 at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
 at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
 at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
 at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
 at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1242)
 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
 at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
 at org.eclipse.jetty.server.Server.handle(Server.java:503)
 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.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
 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)
Caused by: java.lang.ClassNotFoundException: com.studentmanagement.service.StudentService$$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)
 ... 36 more

评论区

蓝雨007

2020-04-23 17:05

我试了哈把工程移到桌面后运行就没有抛异常,不知道为啥,,,

JFinal

2020-04-23 18:36

@蓝雨007 不知道你的 StudentService 是如何定义的,但下面的方法一定能解决,添加配置:
me.setToCglibProxyFactory();

注意看文档:
https://jfinal.com/doc/4-8

可能是你的开发环境是 JRE 而不是 JDK

蓝雨007

2020-05-07 17:49

@JFinal 加了以后直接报错,运行不起
Starting JFinal 4.8
Starting Jetty Server 9.4.z-SNAPSHOT on port: 9999
2020-05-07 17:46:29.312:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@1ed6388a{jfinal-demo,/,file:///F:/Study/JAVA%20Engineer/5_JAVA%20WEB/eclipse-workspace/student-management-jfinal/WebContent/,UNAVAILABLE}
java.lang.NoClassDefFoundError: net/sf/cglib/proxy/Callback
at com.jfinal.config.Constants.setToCglibProxyFactory(Constants.java:171)
at com.studentmanagement.config.StudentManConfig.configConstant(StudentManConfig.java:32)
at com.jfinal.core.Config.configJFinal(Config.java:51)
at com.jfinal.core.JFinal.init(JFinal.java:61)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:64)
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:139)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:741)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:374)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:847)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:287)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
at org.eclipse.jetty.server.Server.start(Server.java:416)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart(Server.java:383)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.jfinal.server.jetty.JettyServer.doStart(JettyServer.java:154)
at com.jfinal.server.jetty.JettyServer.start(JettyServer.java:70)
at com.jfinal.core.JFinal.start(JFinal.java:160)
at com.studentmanagement.startserver.StartServer.main(StartServer.java:8)
Caused by:
java.lang.ClassNotFoundException: net.sf.cglib.proxy.Callback
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:565)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.jfinal.config.Constants.setToCglibProxyFactory(Constants.java:171)
at com.studentmanagement.config.StudentManConfig.configConstant(StudentManConfig.java:32)
at com.jfinal.core.Config.configJFinal(Config.java:51)
at com.jfinal.core.JFinal.init(JFinal.java:61)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:64)
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:139)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:741)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:374)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:847)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:287)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
at org.eclipse.jetty.server.Server.start(Server.java:416)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart(Server.java:383)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.jfinal.server.jetty.JettyServer.doStart(JettyServer.java:154)
at com.jfinal.server.jetty.JettyServer.start(JettyServer.java:70)
at com.jfinal.core.JFinal.start(JFinal.java:160)
at com.studentmanagement.startserver.StartServer.main(StartServer.java:8)
Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/cglib/proxy/Callback
at com.jfinal.config.Constants.setToCglibProxyFactory(Constants.java:171)
at com.studentmanagement.config.StudentManConfig.configConstant(StudentManConfig.java:32)
at com.jfinal.core.Config.configJFinal(Config.java:51)
at com.jfinal.core.JFinal.init(JFinal.java:61)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:64)
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:139)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:741)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:374)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:847)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:287)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
at org.eclipse.jetty.server.Server.start(Server.java:416)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart(Server.java:383)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.jfinal.server.jetty.JettyServer.doStart(JettyServer.java:154)
at com.jfinal.server.jetty.JettyServer.start(JettyServer.java:70)
at com.jfinal.core.JFinal.start(JFinal.java:160)
at com.studentmanagement.startserver.StartServer.main(StartServer.java:8)
Caused by: java.lang.ClassNotFoundException: net.sf.cglib.proxy.Callback
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:565)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 24 more

JFinal

2020-05-07 18:05

注意看文档:
https://jfinal.com/doc/4-8

要添加 cglib 的依赖

sliver

2021-11-11 08:38

这个问题可能和路径中带有中文有关。
我调试了下,在undertow环境下运行的时候,在编译加强后的文件时com.sun.tools.javac.main.Main#compile(java.lang.String[], java.lang.String[], com.sun.tools.javac.util.Context, com.sun.tools.javac.util.List, java.lang.Iterable)方法中的参数中文能够正常显示
但是在非web环境下直接进行加强时中文会编码%e9%82%b5%e8这种格式。导致报类似的错误
@JFinal @蓝雨007

热门反馈

扫码入社