Results 1 to 6 of 6

Thread: AspectJ problem

  1. #1
    Join Date
    Oct 2004
    Posts
    5

    Default AspectJ problem

    When using the Spring IDE support in Eclipse 3.0 it flags the following:

    <bean id="loggingAspect"
    class="spring.aspectj.LoggingAspect" factory-method="aspectOf"/>


    with the error

    'Attribute "factory-method" must be declared for element type "bean"'

    I'm using the spring-framework-1.1.1 version

    I used the bean definition syntax similar to page 68 in the Spring reference manual, which is for version 1.1.2. So my question is how would I do this in version 1.1.1?

  2. #2
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    That syntax appears to be correct - have you tried running the application. This may just be a problem with Spring IDE.

    Rob

  3. #3
    Join Date
    Oct 2004
    Posts
    5

    Default

    Sometimes the aspect works other times I get this error

    java.lang.VerifyError: (class: spring/aspectj/LoggingAspect, method: <clinit> signature: ()V) Stack size too large

  4. #4
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Can you post the code for your LoggingAspect - also are you using any special VM startup params that affect the stack size?

    Rob

  5. #5
    Join Date
    Oct 2004
    Posts
    5

    Default

    The aspect worked great the first time I ran the application, every time after I get


    java.lang.VerifyError: (class: spring/aspectj/LoggingAspect, method: <clinit> signature: ()V) Stack size too large


    I'm not using any special VM startup params that affect the stack size.


    Here's the aspect:

    import org.apache.log4j.*;
    import org.aspectj.lang.*;

    public aspect LoggingAspect {

    private final Logger logger = Logger.getLogger("trace aspect");

    LoggingAspect() {
    logger.setLevel(Level.ALL);
    }


    pointcut loggedOperations()
    : (call(* *.*(..)) || call(*.new(..)))
    && ! within(LoggingAspect);


    before() : loggedOperations() {
    if(logger.isEnabledFor(Level.INFO)) {
    Signature sig = thisJoinPointStaticPart.getSignature();
    logger.log(Level.INFO,
    "Entering [" + sig.getDeclaringType().getName()
    + "." + sig.getName() + "]");
    }
    }


    after() : loggedOperations() {
    if(logger.isEnabledFor(Level.INFO)) {
    Signature sig = thisJoinPointStaticPart.getSignature();
    logger.log(Level.INFO,
    "Exiting [" + sig.getDeclaringType().getName()
    + "." + sig.getName() + "]");
    }
    }
    }

  6. #6
    Join Date
    Oct 2004
    Posts
    5

    Default

    I think what I'm trying to do is unnecessary for my particular application. If I don't include an aspect bean definition for the logging aspect in my application context the aspect works fine and there's no deployment problems. If I do, the spring IDE in eclipse flags it as an error and during deployment I sometimes get an error concerning the stack size and sometimes I don't. If the weaving takes place at compilation, before I even deploy the application, why would the spring container ever need to instantiate the aspect? Or more generally how useful is it to obtain a reference to the single aspect instance in a JVM through the aspectOf() method?

    Say for instance:

    public class X {

    private LoggingAspect loggingAspect;

    public void setLoggingAspect(LoggingAspect loggingAspect) {
    this.loggingAspect = loggingAspect;
    }

    public void printTotalLinesLogged() {
    int totalLinesLogger = this.loggingAspect.getTotalLinesLogged();

    System.out.println("Total lines logged: " + totalLinesLogged);
    }
    }

    Is that what would be possible in spring if I included a bean definition for my particular aspect, provided of course there was a public getTotalLinesLogged() method defined in LoggingAspect?

Similar Threads

  1. Closer ties between Spring and AspectJ
    By Rod Johnson in forum Announcements
    Replies: 3
    Last Post: Sep 7th, 2005, 10:26 AM
  2. Replies: 1
    Last Post: Jul 5th, 2005, 03:48 AM
  3. pagination and continuation problem in SWF
    By yfmoan in forum Web Flow
    Replies: 6
    Last Post: Jun 29th, 2005, 03:42 AM
  4. Lazy Load Problem when Doing UnitTest
    By yoshi in forum Data
    Replies: 7
    Last Post: Sep 29th, 2004, 10:00 AM
  5. AspectJ aspectOf - problem
    By bpolka in forum AOP
    Replies: 3
    Last Post: Sep 7th, 2004, 05:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •