我正在使用AspectJ来处理我正在进行的项目。 作为项目的一部分,我试图使用“maven-shade-plugin”和“jarjar-maven-plugin”,以便将类从一个jar重新定位到另一个jar。
在这两种情况下,当我尝试使用生成的JAR时,AspectJ失败并出现以下异常:
Jan 12, 2016 7:18:52 PM org.aspectj.weaver.tools.Jdk14Trace error
SEVERE: register definition failed
java.lang.RuntimeException: Problem processing attributes in io.myproject.MyAspect
at org.aspectj.weaver.bcel.BcelObjectType.ensureAspectJAttributesUnpacked(BcelObjectType.java:387)
at org.aspectj.weaver.bcel.BcelObjectType.<init>(BcelObjectType.java:162)
at org.aspectj.weaver.bcel.BcelWorld.buildBcelDelegate(BcelWorld.java:410)
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:405)
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107)
at org.aspectj.weaver.World.resolveToReferenceType(World.java:478)
at org.aspectj.weaver.World.resolve(World.java:319)
at org.aspectj.weaver.bcel.BcelWeaver.addLibraryAspect(BcelWeaver.java:159)
at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerAspects(ClassLoaderWeavingAdaptor.java:485)
at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerDefinitions(ClassLoaderWeavingAdaptor.java:304)
at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize(ClassLoaderWeavingAdaptor.java:171)
at org.aspectj.weaver.loadtime.Aj$ExplicitlyInitializedClassLoaderWeavingAdaptor.initialize(Aj.java:340)
at org.aspectj.weaver.loadtime.Aj$ExplicitlyInitializedClassLoaderWeavingAdaptor.getWeavingAdaptor(Aj.java:345)
at org.aspectj.weaver.loadtime.Aj$WeaverContainer.getWeaver(Aj.java:319)
at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:113)
at org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:54)
at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
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:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
Caused by: org.aspectj.weaver.BCException: malformed org.aspectj.weaver.PointcutDeclaration attribute (length:530)org.aspectj.weaver.BCException: Bad type signature log
at org.aspectj.weaver.AjAttribute.read(AjAttribute.java:137)
at org.aspectj.weaver.bcel.Utility.readAjAttributes(Utility.java:101)
at org.aspectj.weaver.bcel.BcelObjectType.ensureAspectJAttributesUnpacked(BcelObjectType.java:383)
... 30 more
[AppClassLoader@14dad5dc] warning register definition failed -- (RuntimeException) Problem processing attributes in io.myproject.MyAspect
Problem processing attributes in io.myproject.MyAspect
java.lang.RuntimeException: Problem processing attributes in io.myproject.MyAspect
at org.aspectj.weaver.bcel.BcelObjectType.ensureAspectJAttributesUnpacked(BcelObjectType.java:387)
at org.aspectj.weaver.bcel.BcelObjectType.<init>(BcelObjectType.java:162)
at org.aspectj.weaver.bcel.BcelWorld.buildBcelDelegate(BcelWorld.java:410)
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:405)
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107)
at org.aspectj.weaver.World.resolveToReferenceType(World.java:478)
at org.aspectj.weaver.World.resolve(World.java:319)
at org.aspectj.weaver.bcel.BcelWeaver.addLibraryAspect(BcelWeaver.java:159)
at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerAspects(ClassLoaderWeavingAdaptor.java:485)
at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerDefinitions(ClassLoaderWeavingAdaptor.java:304)
at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize(ClassLoaderWeavingAdaptor.java:171)
at org.aspectj.weaver.loadtime.Aj$ExplicitlyInitializedClassLoaderWeavingAdaptor.initialize(Aj.java:340)
at org.aspectj.weaver.loadtime.Aj$ExplicitlyInitializedClassLoaderWeavingAdaptor.getWeavingAdaptor(Aj.java:345)
at org.aspectj.weaver.loadtime.Aj$WeaverContainer.getWeaver(Aj.java:319)
at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:113)
at org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:54)
at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
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:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
Caused by: org.aspectj.weaver.BCException: malformed org.aspectj.weaver.PointcutDeclaration attribute (length:530)org.aspectj.weaver.BCException: Bad type signature log
at org.aspectj.weaver.AjAttribute.read(AjAttribute.java:137)
at org.aspectj.weaver.bcel.Utility.readAjAttributes(Utility.java:101)
at org.aspectj.weaver.bcel.BcelObjectType.ensureAspectJAttributesUnpacked(BcelObjectType.java:383)
... 30 more
如果你能指出我做错了什么,我将不胜感激。
谢谢, Nadav
答案 0 :(得分:0)
最后我没有使用maven-jarjar-plugin和maven-shade插件。我已经使用了JarJar的JAR本身,这解决了这个问题(因为它在编译期间没有用AspectJ修改JAR)。
以下问题的答案描述了解决方案:
Relocating fastxml.jackson classes to my.package.fastxml.jackson