开发者社区> 问答> 正文

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

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

总结一下,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

展开
收起
爱吃鱼的程序员 2020-06-05 15:55:59 596 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <p>应该是你的运行环境下面有老版本的 jfinal 干扰, 因为 getGlobalServiceInterceptorClasses() 这个方法在 jfinal 老版本中没有,是在 jfinal 4.2 中添加的</p> 
    

     

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

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

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

    立即下载 >>

    @JFinal

     

    2020-06-05 15:56:18
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载

相关实验场景

更多