Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] org.aspectj.weaver.bcel.BcelWorld - Unable to find class

Good old gmail... it helped me discover where I'd seen it before.

http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg10323.html

Perhaps you already found that thread as it is one in which I
suggested the bcelRepositoryCaching option.  However, that thread
didn't end with a post covering the solution unfortunately :(

Just to help you progress - there are some variations of pointcut you
can try (I'm not sure which part you wildcarded when you said you had
tried):

What you have:
 @Around("execution(public com.x.y.z.payload.Payload
com.something.services..*Bean.*(com.x.y.z.payload.Payload)) &&
args(payload)")
public Object doStuff(ProceedingJoinPoint jp, Payload payload) throws
Throwable {...

Wildcard parameter:
 @Around("execution(public com.x.y.z.payload.Payload
com.something.services..*Bean.*(*)) && args(payload)")
public Object doStuff(ProceedingJoinPoint jp, Payload payload) throws
Throwable {...

Wild return type:
 @Around("execution(public * com.something.services..*Bean.*(*)) &&
args(payload)")
public Object doStuff(ProceedingJoinPoint jp, Payload payload) throws
Throwable {...

Object binding:
 @Around("execution(public * com.something.services..*Bean.*(*)) &&
args(payload)")
public Object doStuff(ProceedingJoinPoint jp, Object payload) throws
Throwable {... if (payload instanceof Payload) {...

that last one removing all trace of Payload apart from inside the
advice itself.

Have you tried with the return type of doStuff advice matching the
join point? (ie. 'Payload' rather than Object).

Or you could try code style to see if that fixes it (that will confirm
for me it is an AspectJ issue and not an environment issue - like a
misbehaving classloader)

I would like to get to the bottom of it this time around, but thought
I'd present some options in the meantime.

What join point are you actually trying to match on?  If you enable
-verbose -debug in the weaver options section of aop.xml, that you see
the type containing the joinpoint correctly passed to the weaver for
weaving?

Andy


2009/11/17 Jonathan T Cone <cone0010@xxxxxxxxxxx>:
>
> I'm using AspectJ LTW with Spring and having the trouble with the following
> around advice:
>
>  @Around("execution(public com.x.y.z.payload.Payload
> com.something.services..*Bean.*(com.x.y.z.payload.Payload)) &&
> args(payload)")
>
> public Object doStuff(ProceedingJoinPoint jp, Payload payload) throws
> Throwable {...
>
>
> For whatever reason, this is not intercepting and is throwing a bizarre
> exception that I've included at the bottom.  I have other interceptors in
> the same application that use the com.x.y.z.payload.Payload class as a
> parameter and return type and they work just fine.  I've tried with
> -Xset:bcelRepositoryCaching=false as well.
>
> It appears that for some reason AspectJ can't find the Payload class for
> this particular advice.  Below is just one example of the Exception, notice
> the class name.  It appears BCEL/AspectJ try a bunch of different
> combinations (there are about 20 stack traces similar to this one) of
> package names, none of which exist.
>
> I've turned on classloading logging and it appears the class gets loaded at
> the end of all these exceptions.  I could really use a tip here, the class
> is on the classpath and I'm not having problems referencing it from the
> application.  In fact, I can change the advice to use a wildcard and the
> code works fine in a unit test (but not when deployed to the app server).
> I've tested this in 1.6.6.  Any ideas what I should try next?
>
>
> 2009-11-16 15:57:31,515 ERROR [main] org.aspectj.weaver.bcel.BcelWorld -
> Unable to find class 'java.lang.com.x.y.z.payload.Payload' in repository
> java.lang.ClassNotFoundException: java.lang.com.x.y.z.payload.Payload not
> found.
>        at
> org.aspectj.apache.bcel.util.NonCachingClassLoaderRepository.loadClass(NonCachingClassLoaderRepository.java:222)
>        at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:224)
>        at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:205)
>        at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107)
>        at org.aspectj.weaver.World.resolveToReferenceType(World.java:363)
>        at org.aspectj.weaver.World.resolve(World.java:258)
>        at org.aspectj.weaver.patterns.SimpleScope.lookupType(SimpleScope.java:63)
>        at
> org.aspectj.weaver.bcel.AtAjAttributes$BindingScope.lookupType(AtAjAttributes.java:1666)
>        at
> org.aspectj.weaver.patterns.WildTypePattern.lookupTypeInScope(WildTypePattern.java:717)
>        at
> org.aspectj.weaver.patterns.WildTypePattern.resolveBindingsFromFullyQualifiedTypeName(WildTypePattern.java:704)
>        at
> org.aspectj.weaver.patterns.WildTypePattern.resolveBindings(WildTypePattern.java:632)
>        at
> org.aspectj.weaver.patterns.SignaturePattern.resolveBindings(SignaturePattern.java:73)
>        at
> org.aspectj.weaver.patterns.KindedPointcut.resolveBindings(KindedPointcut.java:262)
>        at
> org.aspectj.weaver.patterns.AndPointcut.resolveBindings(AndPointcut.java:75)
>        at org.aspectj.weaver.patterns.Pointcut.resolve(Pointcut.java:196)
>        at
> org.aspectj.weaver.bcel.AtAjAttributes.handleAroundAnnotation(AtAjAttributes.java:1152)
>        at
> org.aspectj.weaver.bcel.AtAjAttributes.readAj5MethodAttributes(AtAjAttributes.java:389)
>        at
> org.aspectj.weaver.bcel.BcelMethod.unpackAjAttributes(BcelMethod.java:186)
>        at org.aspectj.weaver.bcel.BcelMethod.<init>(BcelMethod.java:95)
>        at
> org.aspectj.weaver.bcel.BcelObjectType.getDeclaredMethods(BcelObjectType.java:258)
>        at org.aspectj.weaver.bcel.LazyClassGen.<init>(LazyClassGen.java:297)
>        at
> org.aspectj.weaver.bcel.BcelObjectType.getLazyClassGen(BcelObjectType.java:522)
>        at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1726)
>        at
> org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1694)
>        at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1464)
>        at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1245)
>        at
> org.aspectj.weaver.tools.WeavingAdaptor.getWovenBytes(WeavingAdaptor.java:394)
>        at
> org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java:281)
>        at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:95)
>        at
> org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:52)
>        at
> org.springframework.context.weaving.AspectJWeavingEnabler$AspectJClassBypassingClassFileTransformer.transform(AspectJWeavingEnabler.java:92)
>        at
> org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver$FilteringClassFileTransformer.transform(InstrumentationLoadTimeWeaver.java:181)
>        at sun.instrument.TransformerManager.transform(TransformerManager.java:169)
>        at
> sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:365)
>        at java.lang.ClassLoader.defineClass1(Native Method)
>        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
>        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
>        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
>        at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
>        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>        at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)
>        at
> org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:385)
>        at
> org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138)
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:573)
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:521)
>        at
> org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1177)
>        at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:222)
>        at
> org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:505)
>        at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:362)
>        at
> org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
>        at
> org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:42)
>        at
> org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:173)
>        at
> org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:197)
>        at
> org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
>        at
> org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
>        at
> org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:255)
>        at
> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:111)
>        at
> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:148)
>        at
> org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
>        at
> org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
>        at
> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
>        at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
>        at
> org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
>        at
> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
>        at
> oracle.jdevimpl.junit.runner.junit4.JUnit4Testable.run(JUnit4Testable.java:24)
>        at oracle.jdevimpl.junit.runner.TestExecution.run(TestExecution.java:27)
>        at
> oracle.jdevimpl.junit.runner.JUnitTestRunner.main(JUnitTestRunner.java:88)
>
>
>
>
>
> --
> View this message in context: http://old.nabble.com/org.aspectj.weaver.bcel.BcelWorld---Unable-to-find-class-tp26379913p26379913.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top