AWS XRay记录器尝试在启动时检测类

时间:2018-05-07 22:53:06

标签: spring-aop aws-xray

我正在尝试将aws-xray-recorder-sdk-spring lib添加到现有的Spring启动服务中,如docs here中所述。

我在启动时收到此错误:

{"@timestamp":"2018-05-08T08:04:23.026+10:00","@version":1,"message":"Application run failed","logger_name":"org.springframework.boot.SpringApplication","thread_name":"main","level":"ERROR","level_value":40000,"stack_trace":"org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'meterRegistryPostProcessor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: org.springframework.data.repository.Repository [Xlint:invalidAbsoluteTypeName]
\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:591)
\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
\tat org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
\tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
\tat org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
\tat org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205)
\tat org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:238)
\tat org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:709)
\tat org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:534)
\tat org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
\tat org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
\tat org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)
\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
\tat net.nxbos.vti.Application.main(Application.java:34)
Caused by: java.lang.IllegalArgumentException: warning no match for this type name: org.springframework.data.repository.Repository [Xlint:invalidAbsoluteTypeName]
\tat org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:319)
\tat org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:226)
\tat org.springframework.aop.aspectj.AspectJExpressionPointcut.obtainPointcutExpression(AspectJExpressionPointcut.java:197)
\tat org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:176)
\tat org.springframework.aop.support.AopUtils.canApply(AopUtils.java:224)
\tat org.springframework.aop.support.AopUtils.canApply(AopUtils.java:283)
\tat org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:315)
\tat org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:124)
\tat org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:93)
\tat org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:74)
\tat org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:352)
\tat org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:304)
\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:438)
\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1714)
\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583)
\t... 15 common frames omitted
"}

我已将Interceptor设置为在@XRayEnabled注释的类上运行,如此

  @Override
  @Around("@annotation(com.amazonaws.xray.spring.aop.XRayEnabled)")
  public void xrayEnabledClasses() {}

我的项目中没有spring-data,所以有点混淆AOP为什么要匹配它。

Theres a post here提到启动时线程本地使用可能是罪魁祸首,并建议手动检测。如果可能,更愿意使用AWS SDK,对上述错误有任何想法吗?

  

AWS X-Ray Recorder SDK依赖于InheritableThreadLocal存储   为了传播有关当前(子)段的信息   贯穿整个计划的执行。看来Spring正在使用   预先实例化的ThreadPoolExecutor来运行其Bean创建任务。   因此," InitializerListener"段,在创建之后   备用线程,I18nCache初始化不可用   功能

1 个答案:

答案 0 :(得分:0)

我面临着同样的问题。我发现我的项目缺少spring-data-commons依赖性。结果,我们遇到org.springframework.data.repository.Repository的ClassNotFoundException。 Spring AOP掩盖了该异常。添加此依赖项后,我的问题已解决。