标签:blank idea gen call ace 引入 -- fse etc
援引:使用CGlib出现java.lang.NoClassDefFoundError: org/objectweb/asm/Type异常
IDE:IntelliJ IDEA
项目目的:测试动态代理 -- CGLIB
项目属性:Java Application
项目结构:
依赖:第三方jar包
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:72) at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:72) at com.spring_02_aop.$_02_proxy.cglib.Client.main(Client.java:28) Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Type 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) ... 4 more
援引中的博主原文:"报错显示有找不到的类,上网查了以下知道了很多java字节码操作和分析的第三方类库都引用了asm.jar文件,由于工程不是Maven管理的,无法解决以来传递问题,所以要手动引入asm.jar文件。把asm.jar文件添加到项目路径类,运行,然后就正常了。"
ASM原文(来自github.com/cglib/cglib/wiki):"cglib-#.#_#.jar - binary distribution, CGLIB classes only, it must be used to extend cglib classes dependant on ASM API"
ASM白话翻译:"cglib-#.#_#.jar - 必须依赖于ASM API来扩展cglib"
Exception in thread "main" java.lang.ExceptionInInitializerError at com.spring_02_aop.$_02_proxy.cglib.Client.main(Client.java:28) Caused by: java.lang.IllegalStateException: Unable to load cache item at net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:79) at net.sf.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291) at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:221) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:174) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:153) at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:73) ... 1 more Caused by: java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has interface org.objectweb.asm.ClassVisitor as super class at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) at java.net.URLClassLoader.access$100(URLClassLoader.java:74) at java.net.URLClassLoader$1.run(URLClassLoader.java:369) at java.net.URLClassLoader$1.run(URLClassLoader.java:363) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:362) 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 net.sf.cglib.core.DefaultGeneratorStrategy.getClassVisitor(DefaultGeneratorStrategy.java:30) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24) at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:329) at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93) at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91) at net.sf.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61) ... 8 more
博主原文:"(试错)..(试错)..(试错)..(试错)......我们下载最新的ASM文件,则解决了以上问题。"
刚好我手头上存有一份 asm-5.0.4版本,导入项目,Run...Bingo!
asm-5.0.4.jar(链接:https://pan.baidu.com/s/1cZJLWQwDk8cEM69RWg521w)
使用CGlib出现java.lang.NoClassDefFoundError: org/objectweb/asm/Type异常【补充】
标签:blank idea gen call ace 引入 -- fse etc
原文地址:https://www.cnblogs.com/alicia-memory/p/12565022.html