Skip to content
Advertisement

NoAspectBoundException with aspectj and tapestry 5

I have a web project built with Tapestry 5.2.1. I have a simple logging aspect that I was using for tracing on this application. Everything was working fine until I started refactoring parts of the application and attempted to deploy it.

When I deploy the application, no matter what page I attempt to go to I get the following exception:

Caused by: java.lang.RuntimeException: Exception assembling root component of page Index: Exception while initializing TraceAspect: org.aspectj.lang.NoAspectBoundException: TraceAspect
    at org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl.performAssembleRootComponent(ComponentAssemblerImpl.java:124)
    at org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl.access$000(ComponentAssemblerImpl.java:38)
    at org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl$1.invoke(ComponentAssemblerImpl.java:82)
    at org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl$1.invoke(ComponentAssemblerImpl.java:79)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65)
    ... 73 more
Caused by: org.aspectj.lang.NoAspectBoundException: Exception while initializing TraceAspect: org.aspectj.lang.NoAspectBoundException: TraceAspect
    at TraceAspect.aspectOf(TraceAspect.aj:1)
    at com.wex.rrt.wrightweb.reportrequest.webapp.pages.Index.initializer(Index.java:3)
    at com.wex.rrt.wrightweb.reportrequest.webapp.pages.Index.<init>(Index.java)
    at $Instantiator_12d4da06f67.newInstance($Instantiator_12d4da06f67.java)
    at org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.<init>(InternalComponentResourcesImpl.java:146)
    at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.<init>(ComponentPageElementImpl.java:593)
    at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.<init>(ComponentPageElementImpl.java:609)
    at org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl.performAssembleRootComponent(ComponentAssemblerImpl.java:93)
    ... 77 more
Caused by: org.aspectj.lang.NoAspectBoundException: TraceAspect
    at TraceAspect.aspectOf(TraceAspect.aj:1)
    at AbstractLoggingAspect.<init>(AbstractLoggingAspect.aj:7)
    at TraceAspect.<init>(TraceAspect.aj:12)
    at TraceAspect.ajc$postClinit(TraceAspect.aj:1)
    at TraceAspect.<clinit>(TraceAspect.aj:1)
    ... 84 more

My aspect has remained unchanged and is this:

@Aspect
public class TraceAspect {

    Logger logger = Logger.getLogger("trace");

    public TraceAspect() {
        logger.setLevel(Level.ALL);
    }

    /**
     * Will log every execution of
     * <ul>
     * <li>doEverything</li>
     * <li>doSomething</li>
     * </ul>
     * excluding any test classes.
     */
    @Pointcut("(execution(public void *(..)) || execution(*.new(..))) && !within(*Test) !within(com.aspects.*)")
    protected void logging() {
    }

    @Around("logging()")
    public void doThing(final ProceedingJoinPoint thisJoinPoint) throws Throwable {
        final String joinPointName = thisJoinPoint.getThis().getClass().getSimpleName() + "." + thisJoinPoint.getSignature().getName() + "()";
        logger.info("Entering [" + joinPointName + "]");
        thisJoinPoint.proceed();
        logger.info("Leaving  [" + joinPointName + "]");
    }
}

During compilation everything works fine. I’m using the maven plugin to compile the aspects:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.3</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
        <complianceLevel>1.6</complianceLevel>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal> 
                <goal>test-compile</goal>
            </goals>
        </execution>
    </executions>
</plugin>

I’ve been working at this off and on for most of the day and haven’t gotten anywhere. I’m not exactly understanding the NoAspectBoundException. It would seem that the compiler is not weaving the aspect completely? I’m new to AspectJ but I’m wondering if this is something to do with Tapestry5. Although I know that Tap5 uses AOP though.

As I said, this was all working as is just fine until I moved some things into a separate tapestry custom library that is now a dependency for my web app.

Advertisement

Answer

I think we are having a conflict of AOP. AspectJ has done something to the code, and then Tapestry comes along and does something else … including ignoring existing Class constructors on the component class and adding its own. I’m not sure how to get the two working together.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement