简体   繁体   English

Spring的AspectJ NoSuchMethodError

[英]AspectJ NoSuchMethodError with Spring

I have a spring web rest project (3.0.4) running with aspectJ (1.8.14) for logging. 我有一个与AspectJ(1.8.14)一起运行的spring web rest项目(3.0.4),用于记录日志。 I have a pointcut defined in all methods that are annotated with @Logging. 我在所有用@Logging注释的方法中定义了切入点。

When I call a generic helloWorld controller annotated with @Logging. 当我调用以@Logging注释的通用helloWorld控制器时。 AspectJ works fine. AspectJ正常工作。

When I call the real controller annotated with @Logging, which also happens to call a lib jar method that is also annotated with @Logging. 当我调用以@Logging注释的实际控制器时,它也会碰巧也用@Logging注释的lib jar方法。 Unfortunally, during the inner method call the error below occurs. 不幸的是,在内部方法调用期间,发生以下错误。 How does it come that only the method inside the lib has such error? 为什么只有lib内部的方法才会出现这种错误?

java.lang.NoSuchMethodError:
  logging.aop.LoggingAspect.ajc$inlineAccessFieldGet$logging_aop_LoggingAspect$logging_aop_LoggingAspect$pLogger()Lorg/slf4j/Logger;
service.impl.DAOClass.getMethod_aroundBody1$advice(DAOClass.java:101)
service.impl.DAOClass.getMethod(DAOClass.java:1)

What I tried: I checked jdk compiled versions, jar versions in maven dependencies, web.xml and aop.xml configuration and installing AJDT plugin for eclipse photon to debug. 我尝试了什么:我检查了jdk编译版本,maven依赖项中的jar版本,web.xml和aop.xml配置,并安装了AJDT插件以供日食光子调试。 I tried to deploy in weblogic to see the class loader, but I was not able to, trying in tomcat i cannot see what is loaded or not. 我尝试在weblogic中进行部署以查看类加载器,但是我无法这样做,在tomcat中尝试无法看到加载的内容。

PS: please do not downgrade the question for lack of code, i would have to make a complete mock to avoid showing company code for now I am looking for people that worked with AOP with spring and has some idea what I am using based on this info plus the error stack. PS:请不要因为缺少代码而降级这个问题,我将不得不做一个完整的模拟以避免现在显示公司代码。我正在寻找与spring一起使用AOP并基于此有一些想法的人信息加上错误堆栈。 I can make a mock code later if nobody guess what is the cause until there. 如果没有人猜到是什么原因,我以后可以制作一个模拟代码。

Thanks! 谢谢!

No SuchMethodError usually happens when runtime class path contains different version/both version of jar the library was compile against. 当运行时类路径包含针对该库编译的jar的不同版本/两个版本时,通常不会发生SuchMethodError。 You should check the pom dependency against runtime class path. 您应该根据运行时类路径检查pom依赖项。 I bet it was promoted to newer version which is not backward compatible. 我敢打赌,它被提升为不向后兼容的较新版本。 How do you package your application, spring boot? Spring Boot,如何打包您的应用程序?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM