Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » load time weaving with existing servlet
load time weaving with existing servlet [message #57237] Wed, 05 October 2005 16:24 Go to next message
Eclipse UserFriend
Originally posted by: drinkevich.hotmail.com

I am trying to add an aspect to an existing servlet; where the servlet does
not know about the aspect in advance (i.e. it's already deployed) (Note: I
was able to make this work if I created an eclipse project and put them in
the same project prior to building my war file)

I created a simple Hello World servlet (hwservlet) and deployed that war
file to Tomcat. (5.5 using 1.5)

I then created an aspect HttpServletMonitor to listen to the doGet method.
(code below)

I placed
- HttpServletMonitor.class file in hwservlet\web-inf\classes
- aop.xml in hwservlet\META-INF (file below)
- Added aspectj.jar and aspectjweaver.jar to Tomcat's classpath
-Dclasspath=c:\aspectj1.5\lib\aspectjrt.jar;c:\aspectj1.5\li b\aspectweaver.jar
Added the javaagent parameter to tomcat:
-Djavaagent=c:\aspect1.5\lib\aspectjweaver.jar

I restart Tomcat ... the HelloWorld servlet still works just file but the
aspect is not executed. If I run Tomcat through Eclipse in debug mode, I can
hit a breakpoint in the servlet, but not the aspect.

What have I missed?

Thanks
Debbie

*****

public aspect HttpServletMonitor {

/** Execution of any 'do' Servlet request methods. */
public pointcut monitoredOperation(Object operation) :
execution(void HttpServlet.do*(..)) && this(operation);

/** Advice that records statistics for each monitored operation. */
void around(Object operation) : monitoredOperation(operation) {
String threadId = Thread.currentThread().getName();
proceed(operation);
}

private void writeLog(){
// write a temp file to disk
}

public HttpServletMonitor(){ }
}

***

<aspectj>


<aspects>

<!-- declare existing aspects to the weaver -->

<aspect name="HttpServletMonitor"/>


</aspects>

<weaver options="-verbose -XlazyTjp">

<include within="HWServlet"/>

</weaver>


</aspectj>
Re: load time weaving with existing servlet [message #57265 is a reply to message #57237] Wed, 05 October 2005 21:34 Go to previous message
Eclipse UserFriend
Originally posted by: drinkevich.hotmail.com

I've made some progress on at least getting the weaver to acknowledge I want
to do something! However I end up with lots of exceptions (below). Any
thoughts on why this is being thrown?
info weaving 'org/apache/catalina/security/SecurityClassLoad'

warning Register definition failed -- (BCException) malformed
org.aspectj.weaver.EffectiveSignature attribute java.io.EOFException

malformed org.aspectj.weaver.EffectiveSignature attribute
java.io.EOFException

org.aspectj.weaver.BCException: malformed
org.aspectj.weaver.EffectiveSignature attribute java.io.EOFException

at org.aspectj.weaver.AjAttribute.read(AjAttribute.java:121)

at
org.aspectj.weaver.bcel.BcelAttributes.readAjAttributes(Bcel Attributes.java:59)

at
org.aspectj.weaver.bcel.BcelMethod.unpackAjAttributes(BcelMe thod.java:106)

at org.aspectj.weaver.bcel.BcelMethod.<init>(BcelMethod.java:71)

at
org.aspectj.weaver.bcel.BcelObjectType.getDeclaredMethods(Bc elObjectType.java:188)

at
org.aspectj.weaver.ReferenceType.getDeclaredMethods(Referenc eType.java:367)



"Debbie Rinkevich" <drinkevich@hotmail.com> wrote in message
news:di0unb$akh$1@news.eclipse.org...
>I am trying to add an aspect to an existing servlet; where the servlet does
>not know about the aspect in advance (i.e. it's already deployed) (Note: I
>was able to make this work if I created an eclipse project and put them in
>the same project prior to building my war file)
>
> I created a simple Hello World servlet (hwservlet) and deployed that war
> file to Tomcat. (5.5 using 1.5)
>
> I then created an aspect HttpServletMonitor to listen to the doGet
> method. (code below)
>
> I placed
> - HttpServletMonitor.class file in hwservlet\web-inf\classes
> - aop.xml in hwservlet\META-INF (file below)
> - Added aspectj.jar and aspectjweaver.jar to Tomcat's classpath
> -Dclasspath=c:\aspectj1.5\lib\aspectjrt.jar;c:\aspectj1.5\li b\aspectweaver.jar
> Added the javaagent parameter to tomcat:
> -Djavaagent=c:\aspect1.5\lib\aspectjweaver.jar
>
> I restart Tomcat ... the HelloWorld servlet still works just file but the
> aspect is not executed. If I run Tomcat through Eclipse in debug mode, I
> can hit a breakpoint in the servlet, but not the aspect.
>
> What have I missed?
>
> Thanks
> Debbie
>
> *****
>
> public aspect HttpServletMonitor {
>
> /** Execution of any 'do' Servlet request methods. */
> public pointcut monitoredOperation(Object operation) :
> execution(void HttpServlet.do*(..)) && this(operation);
>
> /** Advice that records statistics for each monitored operation. */
> void around(Object operation) : monitoredOperation(operation) {
> String threadId = Thread.currentThread().getName();
> proceed(operation);
> }
>
> private void writeLog(){
> // write a temp file to disk
> }
>
> public HttpServletMonitor(){ }
> }
>
> ***
>
> <aspectj>
>
>
> <aspects>
>
> <!-- declare existing aspects to the weaver -->
>
> <aspect name="HttpServletMonitor"/>
>
>
> </aspects>
>
> <weaver options="-verbose -XlazyTjp">
>
> <include within="HWServlet"/>
>
> </weaver>
>
>
> </aspectj>
>
>
>
>
Re: load time weaving with existing servlet [message #590315 is a reply to message #57237] Wed, 05 October 2005 21:34 Go to previous message
Eclipse UserFriend
Originally posted by: drinkevich.hotmail.com

I've made some progress on at least getting the weaver to acknowledge I want
to do something! However I end up with lots of exceptions (below). Any
thoughts on why this is being thrown?
info weaving 'org/apache/catalina/security/SecurityClassLoad'

warning Register definition failed -- (BCException) malformed
org.aspectj.weaver.EffectiveSignature attribute java.io.EOFException

malformed org.aspectj.weaver.EffectiveSignature attribute
java.io.EOFException

org.aspectj.weaver.BCException: malformed
org.aspectj.weaver.EffectiveSignature attribute java.io.EOFException

at org.aspectj.weaver.AjAttribute.read(AjAttribute.java:121)

at
org.aspectj.weaver.bcel.BcelAttributes.readAjAttributes(Bcel Attributes.java:59)

at
org.aspectj.weaver.bcel.BcelMethod.unpackAjAttributes(BcelMe thod.java:106)

at org.aspectj.weaver.bcel.BcelMethod.<init>(BcelMethod.java:71)

at
org.aspectj.weaver.bcel.BcelObjectType.getDeclaredMethods(Bc elObjectType.java:188)

at
org.aspectj.weaver.ReferenceType.getDeclaredMethods(Referenc eType.java:367)



"Debbie Rinkevich" <drinkevich@hotmail.com> wrote in message
news:di0unb$akh$1@news.eclipse.org...
>I am trying to add an aspect to an existing servlet; where the servlet does
>not know about the aspect in advance (i.e. it's already deployed) (Note: I
>was able to make this work if I created an eclipse project and put them in
>the same project prior to building my war file)
>
> I created a simple Hello World servlet (hwservlet) and deployed that war
> file to Tomcat. (5.5 using 1.5)
>
> I then created an aspect HttpServletMonitor to listen to the doGet
> method. (code below)
>
> I placed
> - HttpServletMonitor.class file in hwservlet\web-inf\classes
> - aop.xml in hwservlet\META-INF (file below)
> - Added aspectj.jar and aspectjweaver.jar to Tomcat's classpath
> -Dclasspath=c:\aspectj1.5\lib\aspectjrt.jar;c:\aspectj1.5\li b\aspectweaver.jar
> Added the javaagent parameter to tomcat:
> -Djavaagent=c:\aspect1.5\lib\aspectjweaver.jar
>
> I restart Tomcat ... the HelloWorld servlet still works just file but the
> aspect is not executed. If I run Tomcat through Eclipse in debug mode, I
> can hit a breakpoint in the servlet, but not the aspect.
>
> What have I missed?
>
> Thanks
> Debbie
>
> *****
>
> public aspect HttpServletMonitor {
>
> /** Execution of any 'do' Servlet request methods. */
> public pointcut monitoredOperation(Object operation) :
> execution(void HttpServlet.do*(..)) && this(operation);
>
> /** Advice that records statistics for each monitored operation. */
> void around(Object operation) : monitoredOperation(operation) {
> String threadId = Thread.currentThread().getName();
> proceed(operation);
> }
>
> private void writeLog(){
> // write a temp file to disk
> }
>
> public HttpServletMonitor(){ }
> }
>
> ***
>
> <aspectj>
>
>
> <aspects>
>
> <!-- declare existing aspects to the weaver -->
>
> <aspect name="HttpServletMonitor"/>
>
>
> </aspects>
>
> <weaver options="-verbose -XlazyTjp">
>
> <include within="HWServlet"/>
>
> </weaver>
>
>
> </aspectj>
>
>
>
>
Previous Topic:load time weaving with existing servlet
Next Topic:AspectJ project dependent on normal java project
Goto Forum:
  


Current Time: Thu Apr 25 05:03:47 GMT 2024

Powered by FUDForum. Page generated in 0.02737 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top