Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] LTW and build-time weaving used together result in an unexpected org.aspectj.bridge.AbortException

Hi,

In our company we are considering the possibility to use LTW and  build-time weaving together with AspectJ 1.5.  What I mean is that we would like to allow LTW only for the "global" aspects (i.e. those that crosscut all our codebase) only in our system level jars (that are audited more carefully and owned by a more senior developers). At the same time we do not want to let the rest of our projects to have aspects that are weaved at load-time. However, we still want them to be able to use AspectJ at compile/build time should they have a need. The reason is that we just do not want some negligent, too broad pointcut definitions coming from some regular jar file with the LTW approach to "accidentally" harm/break other code in the system. This sounds like a safer approach for us.

Anyway, closer to my question.

>From what I know so far with the LTW  one has to declare all the aspects in the aop.xml files even if the aspect was already weaved into the desired classes. The AspectJ will issue an ERROR logging with the stack trace if some aspect is not declared.  In spite of that ERROR reporting, everything seems to work okay for us.

So, I'd like to understand why the described situation considered an error by AspectJ. I would expect just a warning message from AspectJ just saying that an aspect is found that is not declared (i.e. there is no LTW for this aspect).

Below is the relevent output from AspectJ with an error message and a stack trace:

info processing reweavable type com.metatv.user.hibernate.HibernateUserFactory: com\metatv\user\hibernate\HibernateUserFactory.java
error aspect 'com.metatv.user.hibernate.TransactionManager' woven into 'com.metatv.user.hibernate.HibernateUserFactory' must be declared in an aop.xml file.
Message: error aspect 'com.metatv.user.hibernate.TransactionManager' woven into 'com.metatv.user.hibernate.HibernateUserFactory' must be declared in an aop.xml file.
org.aspectj.bridge.AbortException: aspect 'com.metatv.user.hibernate.TransactionManager' woven into 'com.metatv.user.hibernate.HibernateUserFactory' must be declared in an aop.xml file.
        at org.aspectj.weaver.tools.WeavingAdaptor$WeavingAdaptorMessageHandler.handleMessage(WeavingAdaptor.java:413)
        at org.aspectj.weaver.World.showMessage(World.java:550)
        at org.aspectj.weaver.bcel.BcelWeaver.processReweavableStateIfPresent(BcelWeaver.java:1244)
        at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1024)
        at org.aspectj.weaver.tools.WeavingAdaptor.getWovenBytes(WeavingAdaptor.java:277)
        at org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java:210)
        at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:65)
        at org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:52)
        at sun.instrument.TransformerManager.transform(TransformerManager.java:122)

Thanks,
Seva 


Back to the top