Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching mode=aspectj doesn't work [SPR-9182] #13820

Closed
spring-issuemaster opened this issue Feb 29, 2012 · 9 comments
Closed

Caching mode=aspectj doesn't work [SPR-9182] #13820

spring-issuemaster opened this issue Feb 29, 2012 · 9 comments
Assignees
Labels

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Feb 29, 2012

Alexander Fedorov opened SPR-9182 and commented

AspectJ configured and work. Tomcat with LWT instrument.

Did't work:
<cache:annotation-driven mode="aspectj" />
Work's fine:
<cache:annotation-driven />

If I use my adviser:
@Before("execution(@org.springframework.cache.annotation.Cacheable * *(..))")
It executed fine too.

Log with aop -verbose:
info register aspect org.springframework.cache.aspectj.AnnotationCacheAspect

aop.xml

<!DOCTYPE aspectj PUBLIC
"-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>

<weaver options="-verbose -showWeaveInfo">
    <!-- only weave classes in our application-specific packages -->
    <include within="my.company.name.*"/>
</weaver>

</aspectj>


Affects: 3.1.1

Attachments:

1 votes, 7 watchers

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Feb 29, 2012

Alexander Fedorov commented

With CTW same situation

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Mar 19, 2012

Alexander Fedorov commented

Solution for Compile-time-weavering.
Add <weaveDependency>

pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<configuration>

<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<encoding>${project.build.sourceEncoding}</encoding>
<!-- fix "Bad type signature" in test-compile -->
<weaveWithAspectsInMainSourceFolder>false</weaveWithAspectsInMainSourceFolder>

<weaveDependencies>
    <weaveDependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aspects</artifactId>
    </weaveDependency>
</weaveDependencies>

</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jul 7, 2012

Muthiah commented

can you provide your complete pom and config.xml i am stuck with the same issue. If you have fixed it for CTW, It would be very helpful for others

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jun 17, 2013

Alexander Kharitonov commented

I found solution for CTW.
You need set cacheManager property on singleton org.springframework.cache.aspectj.AnnotationCacheAspect.

  1. remove any <cache:annotation-driven ... />
  2. add bean definitions:
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
        ...
</bean>
<bean class="org.springframework.cache.aspectj.AnnotationCacheAspect" factory-method="aspectOf">
        <property name="cacheManager" ref="cacheManager"/>
</bean>
  1. add plugin to pom:
<build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.4</version>
                <configuration>
                    <showWeaveInfo>true</showWeaveInfo>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                    <Xlint>ignore</Xlint>
                    <complianceLevel>${maven.compiler.target}</complianceLevel>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <weaveWithAspectsInMainSourceFolder>false</weaveWithAspectsInMainSourceFolder>
                    <verbose>false</verbose>
                    <forceAjcCompile>true</forceAjcCompile>
                    <aspectLibraries>
                        <aspectLibrary>
                            <groupId>org.springframework</groupId>
                            <artifactId>spring-aspects</artifactId>
                        </aspectLibrary>
                    </aspectLibraries>
                    <weaveDependencies>
                        <weaveDependency>
                            <groupId>org.springframework</groupId>
                            <artifactId>spring-aspects</artifactId>
                        </weaveDependency>
                    </weaveDependencies>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjrt</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjtools</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
  1. add dependencies to pom:
<dependencies>        
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>${springframework.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${aspectj.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Feb 5, 2014

Andrei Varabyeu commented

Guys, do you have any plans according fixing this issue?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Feb 5, 2014

Juergen Hoeller commented

So the issue is that <cache:annotation-driven mode="aspectj"/> doesn't set a CacheManager on AnnotationCacheAspect, as it should? I can have a look at this ASAP.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Feb 5, 2014

Juergen Hoeller commented

It seems the CacheManager is being set there as it should... So I'm not sure what's going wrong there. If you got any further insight, please let us know. We're going to try to reproduce this but any help would be appreciated.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Feb 5, 2014

Stéphane Nicoll commented

Hi, here's a project that works as expected. Could you please let me know how it differs from your use case? Thanks!

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Apr 7, 2014

Stéphane Nicoll commented

Can anyone provide a sample or instructions as how to reproduce this issue? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.