Announcement Announcement Module
Collapse
No announcement yet.
What are the required JAR files for Spring AOP? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • What are the required JAR files for Spring AOP?

    Shouldn't spring.jar enough? I thought it had all the files needed for Spring already? But I found myself still having to import aspectjweaver-x.x.x.jar.

    Please help.

  • #2
    you need at least a couple more

    you need at least aspectjweaver and aspectjrt, below is part of the pom.xml from the maven project I myself am using to experiment with Spring AOP, I think you might also need the jars from cglib if you're using class proxies, but hopefully an expert will post a comment to clear that up a bit more; I'm also having trouble using AOP with annotations so I'm whether those jars are enough, there might be more which I'm not including already.

    <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring</artifactId>
    <version>2.5.6</version>
    </dependency>
    <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.6.4</version>
    </dependency>
    <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjrt</artifactId>
    <version>1.6.4</version>
    </dependency>
    </dependencies>

    Comment


    • #3
      more jars than previously thought

      I just solved the same problem by including cglib2 and asm jars, here is the thread I started asking pretty much the same question as this one:

      http://forum.springsource.org/showthread.php?p=243151

      hope it helps
      Last edited by darklonewolf; May 29th, 2009, 01:55 PM. Reason: the spring-reference manual does specify cglib2 has to be used

      Comment


      • #4
        Originally posted by darklonewolf View Post
        you need at least aspectjweaver and aspectjrt, below is part of the pom.xml from the maven project I myself am using to experiment with Spring AOP, I think you might also need the jars from cglib if you're using class proxies, but hopefully an expert will post a comment to clear that up a bit more; I'm also having trouble using AOP with annotations so I'm whether those jars are enough, there might be more which I'm not including already.

        <dependencies>
        <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
        </dependency>
        <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring</artifactId>
        <version>2.5.6</version>
        </dependency>
        <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.6.4</version>
        </dependency>
        <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.6.4</version>
        </dependency>
        </dependencies>
        Where to download the 1.6.4 version of Aspectjweaver and Aspectjrt? I download the Aspectj-1.6.4.jar from Eclipse site and it is not right library.

        Comment


        • #5
          where to get jars from

          I used maven, which is a really nice project management and comprehension tool (the name is more complicated than what it actually is). Once I tell maven what jars my project depends on, it downloads them automatically. I think you have the right jars, do you have cglib and asm jars too? Here's the last pom I used for maven with all the dependencies:

          Code:
             <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring</artifactId>
                <version>2.5.6</version>
              </dependency>
              <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjweaver</artifactId>
                <version>1.6.4</version>
              </dependency>
              <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjrt</artifactId>
                <version>1.6.4</version>
              </dependency>
              <dependency>
                <groupId>cglib</groupId>
                <artifactId>cglib2</artifactId>
                <version>2.2</version>
              </dependency> 
              <dependency>
                <groupId>asm</groupId>
                <artifactId>asm</artifactId>
                <version>3.1</version>
              </dependency>
          Maybe you're not interested in diving into Maven just yet, which is ok. At least you can see which versions I've used and look for them. By the way, to make the code work I had to add this to Spring's xml configuration file:



          Code:
            <bean id="fruit" class="org.example.entities.Fruit">
              <constructor-arg index="0" value="Orange" />
              <constructor-arg index="1" value="orange" />
              <constructor-arg index="2" value="sour" />
            </bean>
          
            <aop:aspectj-autoproxy />
          
            <bean class="org.example.aspect.SimpleAspect"/>
          Bean with id 'fruit' is the one being advised, SimpleAspect is the advisor, and <aop:aspectj-autoproxy /> is the one that bootstraps the whole AOP Framework as far as I know. Sorry for omitting those parts before, I hope it helps.
          Last edited by darklonewolf; May 29th, 2009, 11:27 AM. Reason: I had to include an updated pom file

          Comment


          • #6
            Originally posted by darklonewolf View Post
            I used maven, which is a really nice project management and comprehension tool (the name is more complicated than what it actually is). Once I tell maven what jars my project depends on, it downloads them automatically. I think you have the right jars, do you have cglib and asm jars too? Here's the last pom I used for maven with all the dependencies:
            ...

            I already use AspectJ in the project. After introducing annotation, I run into a problem on AOP annotation notation. It seems I need to have a newer version of Aspectjrt and Aspectjweave (the new version I have were built in 2007). I know the Maven can manage library version. The project is not with Maven and I don't have a plan to change the condition. At this point, I only want to know where to download the newer version of AspectJ.

            Comment


            • #7
              What errors are you getting?

              Originally posted by vw729 View Post
              I run into a problem on AOP annotation notation. It seems I need to have a newer version of Aspectjrt and Aspectjweave (the new version I have were built in 2007).
              Can you show any errors you're getting? Is it a compile-time or runtime error?

              Show the Spring configuration file and the Aspect you're trying to use as well.
              Last edited by darklonewolf; May 29th, 2009, 01:56 PM. Reason: forgot to ask for additional details

              Comment


              • #8
                jar required for aop of spring 3.0 are aspectjweaver.jar,aspectjrt-1.6.0.jar,aopalliance.jar,asm.jar,cglib-2.2.2.jar

                and all the above jars are available at sourceforge.net

                Comment

                Working...
                X