Hi everyone,
I have a big problem using AspectJ and Spring, although I suspect this
problem may be AspectJ-specific. However, I can't be sure.
I am trying to use Spring's @Configurable to add dependency injection to my
domain objects. The reason I don't think I have a Spring issue is that I
have this feature working fine - the one and only object that is being
injected is working with the Spring aspect that comes out of the box.
The problem I am having is that sometimes the AspectJ weaver does not "see"
the object that I need weaved. When I turn on DEBUG in log4j, I sometimes
see that my class isn't in the list of classes that the weaver is iterating
through when it starts up. Do you know how this could happen? My class is
obviously in the classpath, because it gets used in the tests or in the web
container afterward.
This happens in a variety of cases. When I test a class in
project.domain.subpackage, the weaving works fine. If I even test the entire
package with multiple test classes, it works great. However, when I test all
the Test classes in project.domain.*, the weaver cannot find my class
anymore. The same is true testing everything in project.*,
project.controllers.*, etc.
Before you say anything, I am using the exact jvm settings when I run JUnit,
and the same thing happens when I test in Maven as well (so it's not IDE
specific).
This problem is annoying enough, but sometimes Tomcat calling aspectJ
doesn't see the class either. I have to shut down and start up the server,
hoping that each time aspectJ will weave the class I need it to. Right now,
it's about a 30% success rate. Once AspectJ weaves my class, everything is
golden.
I can only assume that this is all the same problem. What could be causing
this?
These are the arguments I am passing into the JVM:
-Xms256m -Xmx512m -javaagent:"C:\Documents and
Settings\Username\.m2\repository\org\springframework\spring-agent\2.5.6.SEC01\spring-agent-2.5.6.SEC01.jar"
This is my aop.xml:
<aspectj>
<weaver options="-showWeaveInfo
-XmessageHandlerClass:org.springframework.aop.aspectj.AspectJWeaverMessageHandler">
<include within="jobprep.domain..*"/>
<exclude within="jobprep.domain..*CGLIB*"/>
</weaver>
</aspectj>
These are the spring application context lines to get it to work:
<context:annotation-config />
<context:spring-configured />
<context:load-time-weaver />
<context:component-scan
base-package="jobprep.dao,jobprep.service,jobprep.domain.openended" />
I really don't see what I'm doing wrong, and if I can't get this ramdom
behaviour fixed... then I think I'm going to have to dump AOP/aspectJ
completely. I really don't want to.
Has anyone used @Configurable with compile-time weaving to good effect? If I
can do this at compile time, I would LOVE to. I am only weaving 1 class, so
the hit to compile time is a non-issue here.
Please help.
Ken
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users