首页 > 其他 > 详细

使用CGLib完成代理模式遇到的错误

时间:2018-01-30 13:42:09      阅读:2249      评论:0      收藏:0      [点我收藏+]

错误堆栈信息:

Exception in thread "main" java.lang.NoClassDefFoundError: org/objectweb/asm/Type
    at net.sf.cglib.core.TypeUtils.parseType(TypeUtils.java:184)
    at net.sf.cglib.core.KeyFactory.<clinit>(KeyFactory.java:66)
    at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
    at com.xxxx.model.proxy.cglib.CglibProxy.getProxy(CglibProxy.java:14)
    at com.xxxx.model.proxy.cglib.TestProxy.main(TestProxy.java:11)
Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Type
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 5 more

通过网上查询,发现是由于缺少jar包导致,引入了asm4.1.jar,又出现新的错误信息。

异常堆栈信息如下:

Exception in thread "main" java.lang.VerifyError: class net.sf.cglib.core.DebuggingClassWriter overrides final method visit.(IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)V
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at net.sf.cglib.core.AbstractClassGenerator.<init>(AbstractClassGenerator.java:38)
    at net.sf.cglib.core.KeyFactory$Generator.<init>(KeyFactory.java:127)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:112)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
    at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
    at com.xxxx.model.proxy.cglib.CglibProxy.getProxy(CglibProxy.java:14)
    at com.xxxx.model.proxy.cglib.TestProxy.main(TestProxy.java:11)

问题原因是由于版本不配套导致,将asm.jar改用3.3.1版本,问题得到解决。

 

使用CGLib完成代理模式遇到的错误

原文:https://www.cnblogs.com/woniu4/p/8384020.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!