Eric Brun opened SPR-8893 and commented
Hi,
I have annotated method of my class with the new cache abstraction feature.
a method by example :
@Cacheable
(value="jackrabbitCache", key="#login+':'+#path")
public RessourceItem getPathContent(String path, String login) {...}
On MacOSX JVM 1.6 and Jetty + tomcat 7 libs when I put login and path parameter with for example 'JEAN-MICHEL.JULLIEN' and path '/JEAN-MICHEL.JULLIEN' My traceback says :
02-12-2011 17:30:30:113 43707 DEBUG org.springframework.cache.interceptor.CacheInterceptor - Computed cache key JEAN-MICHEL.JULLIEN:/JEAN-MICHEL.JULLIEN for operation CacheableOperation[public com.pentila.evalcomp.domain.transit.RessourceItem com.pentila.evalcomp.repository.Storage.getPathContent(java.lang.String,java.lang.String)] caches=[jackrabbitCache] | condition='' | key='#login+':'+#path'
=> Here it works
When I deploy on Linux JVM IBM 1.6 or JVM SUN 1.6.0_22 on tomcat 6.0.33 or tomcat 7.0.22
My traceback is always :
02-12-2011 18:51:28:829 848685 DEBUG org.springframework.cache.interceptor.CacheInterceptor - Computed cache key null:null for operation CacheableOperation[public com.pentila.evalcomp.domain.transit.RessourceItem com.pentila.evalcomp.repository.Storage.getPathContent(java.lang.String,java.lang.String)] caches=[jackrabbitCache] | condition='' | key='#login+':'+#path'
=> Here Fail !
My key is wrong but I pass the right values for parameters (not null values).
Is there a bug in parameters interpretation in SpeL language expression ? Or a conflict libs with tomcat ?
Please Help
Thanks Eric
Affects: 3.1 RC2
Comment From: spring-projects-issues
Costin Leau commented
There might several things that might cause this error. I doubt that there's a problem with SpEL itself (since it does the parsing) but it might be the JVM or the way the classes are compiled. First try to isolate this problem - create a very simple application and try to use the same web container on all platforms. Make sure your classes are compiled with debug symbols on. Start from the Windows/Linux JVM first and then see how things are working on the Mac. Also make sure that you have the same libraries on all these OSes. If the problem still occurs please send us the version of the libraries used, the sources of your app but also the binary that works on some platform and fails on the other.
I don't think the web container make much of a difference in terms of SpEL - again, I would guess it's the way the field names are added or not to the byte-code.
Also, let us know if you use any type of byte-code enhancer (JVM agent/LoadTimeWeaver/etc...)
Comment From: spring-projects-issues
Eric Brun commented
Hi Costin,
I finally found a way to get SpEL parameter work in my annotation @Cacheable
(value="jackrabbitCache", key="#login+':'+#path").
My project is compiler both with Eclispe Compiler and by my ant task 'javac'.
With Eclipse compiled .class , their is no problem with my annotation above =
Computed cache key JEAN-MICHEL.JULLIEN:/JEAN-MICHEL.JULLIEN for operation CacheableOperation[public com.pentila.evalcomp.domain.transit.RessourceItem
With my ant compilation \
Computed cache key null:null for operation CacheableOperation[public com.pentila.evalcomp.domain.transit.RessourceItem
the #login and #path is really not null by the annotation get it null : error
So, I put "debug" directive to my javac task : \
And then try the compiled bytecode on my apache-tomcat server : IT WORKS !
The size of my .class file are more important cause of debug information.
Well, I don't know really why I must add 'debug' directive, have you an idea.
I spend a lot of time for testing this.
Cheers
Eric
Comment From: spring-projects-issues
Eric Brun commented
I forgot to say I made my tests with Spring 3.1.0 GA version
Bye
Comment From: spring-projects-issues
Costin Leau commented
Eric, this is explained in the docs: http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/cache.html#cache-spel-context I should probably make it more visible - w/o debug information, the field names cannot be detected. You should also get a warning in the logs regarding this.
We should probably improve this by throwing an exception if the SpEL variable cannot be found...
Comment From: spring-projects-issues
Eric Brun commented
Thanks for explanations
Eric
Comment From: snicoll
I believe this issue is outdated now so I am going to close it.