Bug 397829 - Aspect-J without LTW clashes with JBoss AS7 ModuleClassLoader
Summary: Aspect-J without LTW clashes with JBoss AS7 ModuleClassLoader
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Runtime (show other bugs)
Version: 1.7.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-10 04:07 EST by eis - CLA
Modified: 2013-01-10 07:49 EST (History)
0 users

See Also:


Attachments
source code for the used app (19.08 KB, application/zip)
2013-01-10 04:07 EST, eis - CLA
no flags Details
source code for the used aspect (1.32 KB, text/plain)
2013-01-10 04:12 EST, eis - CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description eis - CLA 2013-01-10 04:07:20 EST
Created attachment 225417 [details]
source code for the used app

Using aspects without load-time weaving works for the regular use cases. However, if this kind of Spring configuration is used:

<jee:jndi-lookup id="dataSource" jndi-name="jboss/datasources/ExampleDS"/>
<bean id="methodTraceAspect" class="fi.eis.applications.jboss.poc.gemini.spring.aop.support.api.MyMethodTraceAspect"/>
<aop:aspectj-autoproxy />

JBoss tries to use methodTraceAspect also on the data source. Data source is loaded by ModuleClassLoader that in has only visibility to org.jboss.jca.adapters* classes (confirmed with a debugger), so it cannot find the aspect class anymore, making aspect-j throw org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException: warning can't determine implemented interfaces of missing type
fi.eis.applications.jboss.poc.gemini.spring.aop.support.api.MyMethodTraceAspect [Xlint:cantFindType].

This has large problems in bigger applications, where general AOP pointcuts are used - no jboss-module stuff can be used as beans, anywhere. There are lot of stuff, such as mybatis-spring, that expect a bean parameter of type DataSource. I'm aware of no workaround for this.
Comment 1 eis - CLA 2013-01-10 04:12:38 EST
Created attachment 225418 [details]
source code for the used aspect
Comment 2 eis - CLA 2013-01-10 07:49:31 EST
Found a workaround for this: create a custom data source wrapper, like

<bean id="serviceLocator" class="fi.eis.applications.jboss.poc.gemini.spring.aop.beans.ServiceLocator"
factory-method="getInstance" />
<bean id="dataSource" class="fi.eis.applications.jboss.poc.gemini.spring.aop.beans.OurDataSourceProxy">
   <constructor-arg ref="serviceLocator" />
   <constructor-arg>
       <value>jboss/datasources/ExampleDS</value>
   </constructor-arg>
</bean> 

This would be needed for all datasources.