I am trying to run AspectJ on Weblogic with LTW. My pointcut is for public constructor and methods, and advices are for Before, AfterReturning and AfterThrowing. I am getting following error when I access a simple "Hello World" jsp:
javax.servlet.ServletException: Servlet class: 'jsp_servlet.__index' doesn't have a default constructor
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:315)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:288)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
Truncated. see log file for complete stacktrace
Root cause of ServletException.
java.lang.NoSuchMethodError: foo.aspect.DefaultAspect.aspectOf()Lfoo/aspect/DefaultAspect;
at jsp_servlet.__index._jspService(__index.java:76)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
Truncated. see log file for complete stacktrace
Here is my aop.xml file:
<aspectj>
<aspects>
<aspect name="foo.aspect.DefaultAspect" />
</aspects>
<weaver options="-verbose">
<include within="foo.aspect.*" />
<include within="jsp_servlet..*"/>
</weaver>
</aspectj>
Here is my aspect file:
package foo.aspect;
@Aspect
public class DefaultAspect {
@Pointcut("execution(public *.new(..)) && !within(foo.aspect.*)")
public void pointCutNew(JoinPoint thisJoinPoint) {
}
@After("pointCutNew(thisJoinPoint)")
public void adviceForNew(JoinPoint thisJoinPoint) {
}
//Simiar pattern for other advices and pointcuts (for methods)
}
This aspect is compiled (using normal javac compiler) into foo.jar
I am running Weblogic by adding the following:
java -javaagent:<path_to aspectweaver.jar> -Xbootclasspath/p:<path to {foo.jar, aspectweaver.jar}>
I believe this is most likely a classpath/classloader issue due to which AspectJ is not able to create "aspectOf()" methods in DefaultAspect class
Please help.