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

3.6.5 to 3.7.1 Upgrade breaks Spring cache #9023

Closed
we64 opened this issue Sep 29, 2016 · 5 comments

Comments

Projects
None yet
4 participants
@we64
Copy link

commented Sep 29, 2016

I have a Spring 3.2.17 project that has been using Hazelcast 3.6.5 fine with Spring cache utilizing com.hazelcast.spring.cache.HazelcastCacheManager directly.

When I change the Hazelcast version to 3.7.1 in my pom, calls to Spring cache will generate the following exception:
java.lang.ClassNotFoundException: org.springframework.cache.Cache$ValueRetrievalException org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332) org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166) com.hazelcast.spring.cache.HazelcastCacheManager.getCache(HazelcastCacheManager.java:51) org.springframework.cache.interceptor.CacheAspectSupport.getCaches(CacheAspectSupport.java:164) org.springframework.cache.interceptor.CacheAspectSupport$CacheOperationContext.<init>(CacheAspectSupport.java:411) org.springframework.cache.interceptor.CacheAspectSupport.getOperationContext(CacheAspectSupport.java:176) org.springframework.cache.interceptor.CacheAspectSupport.createOperationContext(CacheAspectSupport.java:366) org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:195) org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:66) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633) com.brilent.ga.parser.util.ApplicantMatchingResultUtil$$EnhancerBySpringCGLIB$$72abbb9a.clearAllApplicantMatchingResultCache(<generated>) com.brilent.ga.parser.dao.ParsingDAO.processMatchingTasks(ParsingDAO.java:4643) com.brilent.ga.parser.dao.ParsingDAO.matchJobActualWork(ParsingDAO.java:4105) com.brilent.ga.parser.dao.ParsingDAO.matchJobDescription(ParsingDAO.java:4068) com.brilent.ga.parser.rest.ParsingService.matchJD(ParsingService.java:1265) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:497) org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:743) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:672) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:82) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:933) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:867) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:951) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:853) javax.servlet.http.HttpServlet.service(HttpServlet.java:648) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:827) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:131) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) org.apache.catalina.filters.CorsFilter.handleSimpleCORS(CorsFilter.java:301) org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:165)

@mesutcelik

This comment has been minimized.

Copy link
Contributor

commented Oct 3, 2016

Hi @we64 ,

I just asked this to Spring Developers. please see my comment.

The other option is to move to Spring 4.3 but i don't know if that is easy for you

@we64

This comment has been minimized.

Copy link
Author

commented Oct 3, 2016

Thanks you!

Moving to Spring 4.3 will take quite a bit of time for us and I would much prefer not to go down that route if possible. Hopefully the issue will get resolved by 3.7.3 and considering that the change was suppose to be backward compatible to older versions of Spring, it would make sense to try fixing this.

@snicoll

This comment has been minimized.

Copy link
Contributor

commented Oct 20, 2016

Sorry for the late reply guys!

I've just submitted a PR that fixes the issue. It's very weird that the method body is parsed upfront when the class is loaded. I was able to reproduce the issue and #9148 should fix this for this use case.

mesutcelik pushed a commit that referenced this issue Oct 20, 2016

Delegate resolution of ValueRetrievalException in inner delegate
This commit fixes a `ClassNotFoundException` on
`Cache$ValueRetrievalException` when using the cache abstraction with
Spring Framework prior to 4.3.

`ValueRetrievalException` is an inner exception class introduced in
Spring Framework 4.3. Throwing that exception in the body of a method
should have been working fine but for some reason the body of the method
is resolved upfront when the class is loaded.

This commits moves the resolution to an inner class to enforce that such
type is not going to be loaded unless the class is invoked explicitly and
this only happens if the `sync` attribute is used (new in 4.3).

Closes gh-9023

mesutcelik added a commit that referenced this issue Oct 20, 2016

Merge pull request #9148 from snicoll/gh-9023
Delegate resolution of ValueRetrievalException in inner delegate
@emrahkocaman

This comment has been minimized.

Copy link
Contributor

commented Oct 20, 2016

Fixed by #9148

emrahkocaman added a commit to emrahkocaman/hazelcast that referenced this issue Oct 21, 2016

Delegate resolution of ValueRetrievalException in inner delegate
This commit fixes a `ClassNotFoundException` on
`Cache$ValueRetrievalException` when using the cache abstraction with
Spring Framework prior to 4.3.

`ValueRetrievalException` is an inner exception class introduced in
Spring Framework 4.3. Throwing that exception in the body of a method
should have been working fine but for some reason the body of the method
is resolved upfront when the class is loaded.

This commits moves the resolution to an inner class to enforce that such
type is not going to be loaded unless the class is invoked explicitly and
this only happens if the `sync` attribute is used (new in 4.3).

Closes hazelcastgh-9023
@mesutcelik

This comment has been minimized.

Copy link
Contributor

commented Oct 21, 2016

@we64 ,

Can you please check if that is ok for you? You can try 3.7.3-SNAPSHOT right away or 3.7.3 when it is released.

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