Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AspectJExpressionPointcut unpredictable behavior in OSGi environment [SPR-10871] #15498

spring-issuemaster opened this issue Aug 28, 2013 · 1 comment


Copy link

@spring-issuemaster spring-issuemaster commented Aug 28, 2013

Temnov Aleksey opened SPR-10871 and commented

We have a java application consisting of multiple OSGi modules running with Apache Felix container. Spring DM is responsible for loading spring application contexts of our bundles.
We faced this kind of error:

Caused by: java.lang.IllegalArgumentException: warning no match for this type name: my.bundle.second.api.MarkerInterface [Xlint:invalidAbsoluteTypeName]
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(

After some researching we found that this exception is thrown while trying to match this aop expression:

@Before("within(my.bundle..*) && target(my.bundle.second.api.MarkerInterface)")

So, we looked up for an issue #13973 and made a small test project that represents the architecture of problematic funсtionality in our project. After we coded it, we faced another problem. Every time we start felix, we randomly get one of two different errors. One of them I already specified upwards and the other one is:

Caused by: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException: warning can't determine implemented interfaces of missing type
        at org.aspectj.weaver.reflect.ReflectionWorld$ExceptionBasedMessageHandler.handleMessage(
        at org.aspectj.weaver.Lint$Kind.signal(
        at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.raiseCantFindType(
        at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.getDeclaredInterfaces(
        at org.aspectj.weaver.ReferenceType.isAssignableFrom(
        at org.aspectj.weaver.ReferenceType.isAssignableFrom(
        at org.aspectj.weaver.ReferenceType.isAssignableFrom(
        at org.aspectj.weaver.ReferenceType.isAssignableFrom(
        at org.aspectj.weaver.patterns.ExactTypePattern.matchesInstanceof(
        at org.aspectj.weaver.patterns.TypePattern.matches(
        at org.aspectj.weaver.patterns.ThisOrTargetPointcut.matchInternal(
        at org.aspectj.weaver.patterns.Pointcut.match(
        at org.aspectj.weaver.patterns.AndPointcut.matchInternal(
        at org.aspectj.weaver.patterns.Pointcut.match(
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.getShadowMatch(
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(

The logic of this functionality is very easy:
We have Bundle-1, that contains just one class, we called it "FirstAbstractClass".
Bundle-2 contains class "SecondAbstractClass" that extends "FirstAbstractClass" from bundle-1, aspect "CommonAspect" with expression that I specified earlier and an interface, called "MarkerInterface".
Bundle-3 contains OSGi service classes "ConcreteClass" and "ConcreteClassMarkered", that extend "SecondAbstractClass" and aspect declaration in bundle-3-context file:

<bean id="aspect" class="my.bundle.second.CommonAspect"/>

This is it.
If you comment declaration of "concreteClass" bean in bundle-3 spring context, all the bundles will start fine, but if you comment "concreteClassMarkered" - application won't work.
If you import package of "FirstAbstractClass" from first bundle to third one - it will solve the problem. But I guess it's a weird workaround, and application should work perfectly without it.
I guess, first type of error caused by using wrong classloader during aspect expression processing (guess it was classloader from bundle-1, that can't see bundle-3 "MarkerInterface"). What causes the second one - I don't know.

So, we found that this is a wrong and unpredictable behavior and made this bug.

Test project is also commited to: spring-framework-issues SPR-10871

Affects: 3.2.4

Reference URL:

1 votes, 2 watchers


This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jan 12, 2019

Bulk closing outdated, unresolved issues. Please, reopen if still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.