Skywalking: agent spring-plugins aop

Created on 30 Jan 2018  ·  12Comments  ·  Source: apache/skywalking

version>3.2.6-2017

Question

  • What happen:

我本地 加了aop 引用了自定义业务类
现在 探针报错 报找不到类
java.lang.ClassCastException: org.skywalking.apm.plugin.spring.mvc.commons.EnhanceRequireObjectCache cannot be cast to com...framework.response.RspData

这个要怎么处理好吗


Translation by @wu-sheng

When use AOP to a custom class, trigger the following exception:

java.lang.ClassCastException: org.skywalking.apm.plugin.spring.mvc.commons.EnhanceRequireObjectCache cannot be cast to com...framework.response.RspData

Why?

agent question

All 12 comments

@xjr100419 All question must be in English. Please follow Apache rule.

Can you provide RspData source code? Why is its source code manipulated by SkyWalking? Exist an annotation or what?

@xjr100419 Thanks. @ascrutae will check for you. The first step is that make sure whether it fixed in 5.0-alpha. We already did a lot of compatible adjustments.

please add proxy-target-class=true, the default proxy way in spring is jdk proxy, so it can't cast down to the specific class

@clevertension I think that is the reason. Your way may help @xjr100419 to fix this in 3.2.6 . And further, we did a patch for the plugin to make sure the compatible with Spring core. That is why I want @ascrutae to run some tests under 5.0-alpha develop branch.

when I add proxy-target-class=true
that was invalid

spring.aop.proxy-target-class=true

can you add
@EnableAspectJAutoProxy(proxyTargetClass=true) in your GpsApplication?

i see you are using the aspectj proxy

I check again
@EnableAspectJAutoProxy(proxyTargetClass=true)

that was the same problem

please change your controllerMethodPointcut()

    @Pointcut("execution(@org.springframework.web.bind.annotation.RequestMapping * com.candao.dms2.gps.controller..*(..))")
    public void controllerMethodPointcut(){}

your annotation hook is not work, you can refer to this

http://forum.spring.io/forum/spring-projects/aop/59391-pointcut-with-annotation-does-not-work

@wu-sheng , i think this is not the skywalking issue, it is the aop pointcut configuration

I found an issue in your demo
the annotation in ExceptionInterceptorAspect class
@Pointcut("execution(* com.candao.dms2.gps.controller..*(..)) and @annotation(org.springframework.web.bind.annotation.RequestMapping)")

should be like this:
@Pointcut("execution(* com.candao.dms2.gps.controller..*(..)) && @annotation(org.springframework.web.bind.annotation.RequestMapping)")

@xjr100419

I cannot reproduce this issue in the latest version when I using the @Pointcut("execution(* com.candao.dms2.gps.controller..*(..)) && @annotation(org.springframework.web.bind.annotation.RequestMapping)")
if you don't have any question. I'm going to close this issue three days later

@ascrutae @clevertension
it was done
thank you very much

Was this page helpful?
0 / 5 - 0 ratings