JFinal4.2 自带的代理问题!Proxy.get()报未找到类的问题!

发布于 2022-01-07 13:42:44 字数 5501 浏览 853 评论 2

找了大半天,终于定位到报错的地方了!

总结一下,JFinal4.2.如果使用JFinal自带的代理方法的话,在Interceptor实例化中使用代理类(Proxy.get方法)的话,会报找不到类的错误,估计是Classloader的问题!

问题重现方法:

public class Test{

}

public class MyInteceptor implements Inteceptor{
    private Test test = Proxy.get(Test.class);

    @Override
    public void intercept(Invocation inv) {
          //do sth.
    }
}

启动时会报以下错误:

13-Jun-2019 20:48:14.571 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.filterStart Exception starting filter jfinal
 java.lang.NoSuchMethodError: com.jfinal.aop.InterceptorManager.getGlobalServiceInterceptorClasses()Ljava/util/List;
	at com.jfinal.proxy.ProxyGenerator.getMethodUpperInterceptors(ProxyGenerator.java:310)
	at com.jfinal.proxy.ProxyGenerator.generate(ProxyGenerator.java:74)
	at com.jfinal.proxy.ProxyFactory.getProxyClass(ProxyFactory.java:67)
	at com.jfinal.proxy.ProxyFactory.get(ProxyFactory.java:41)
	at com.jfinal.proxy.Proxy.get(Proxy.java:32)
	at ManagerLoginInterceptor.<init>(ManagerLoginInterceptor.java:24)
	at res.shop.config.ManageRoutes.config(ManageRoutes.java:14)
	at com.jfinal.config.Routes.add(Routes.java:68)
	at res.shop.config.SystemConfig.configRoute(SystemConfig.java:95)
	at com.jfinal.core.Config.configJFinal(Config.java:54)
	at com.jfinal.core.JFinal.init(JFinal.java:61)
	at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:63)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4615)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5222)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1585)
	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:483)
	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:463)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:413)
	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:483)
	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:1466)
	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307)
	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399)
	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:828)
	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:483)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
	at sun.rmi.transport.Transport$1.run(Transport.java:178)
	at sun.rmi.transport.Transport$1.run(Transport.java:175)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:174)
[2019-06-13 08:48:14,605] Artifact res_shop:war exploded: Error during artifact deployment. See server log for details.
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:557)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:812)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:671)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

解决方法:

保留cglib-nodep-3.2.5.jar

配置加上

constants.setProxyFactory(new CglibProxyFactory());

很想抛弃cglib包,希望能够修复一下!

@JFinal

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绝情姑娘 2022-01-07 21:44:15

用jetty启动没问题,用Tomcat有问题,估计真的是ClassLoader导致。

下面是最简单的JFinal项目,里面可以重现问题,请使用Tomcat作为服务器!

立即下载 >>

@JFinal

 

心舞飞扬 2022-01-07 19:43:28

应该是你的运行环境下面有老版本的 jfinal 干扰, 因为 getGlobalServiceInterceptorClasses() 这个方法在 jfinal 老版本中没有,是在 jfinal 4.2 中添加的

 

检查一下可能被加载的老版本的 jfinal 

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文