Note that there are some explanatory texts on larger screens.

plurals
  1. PONoClassDefFoundError with spring cache and aspectj
    primarykey
    data
    text
    <p>I am getting this error in my spring webapp (spring 3.1), and I don't know why.</p> <blockquote> <p>org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: mypackage/TestCache$AjcClosure1</p> </blockquote> <p>(the <code>$AjcClosure1</code> is weird)</p> <p>If I comment the annotation <code>@Cacheable</code> in the class below the error is gone.</p> <pre><code>public class TestCache { @Cacheable(value ="myCache") public List&lt;String&gt; getDummyList(){ Logger l = Logger.getLogger(this.getClass()); l.error("calling getDummyList"); ArrayList&lt;String&gt; foo = new ArrayList&lt;String&gt;(); foo.add("foo"); foo.add("bar"); return foo; } } </code></pre> <p>My controller class (simplified):</p> <pre><code>@Controller @RequestMapping("/mypage") public class MyController { @RequestMapping public String index(ModelMap model, Locale locale) { TestCache tc = new TestCache(); ... } } </code></pre> <p>Application Context (only cache part):</p> <pre><code>&lt;cache:annotation-driven mode="aspectj"/&gt; &lt;bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cache-manager-ref="ehcache"/&gt; &lt;bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:config-location="classpath:ehcache.xml"/&gt; </code></pre> <p>I tried proxy and aspectj mode (in proxy mode less error but the cache was doing nothing)</p> <p>This web application was built initially with roo and use spring mvc and webflow. So there is quite a lot of xml in the applicationContext.xml or webmvc-config.xml (and I am not able to understand what some beans are doing). I am running the wepapps in eclipse with m2e-wtp and the pom.xml is using the plug-in aspectj-maven-plugin (but no idea what it does)</p> <p>It looks like the issue is related with aspectj, but I never used aspectJ. If anyone spring/java/aspectj guru can explain me what is making this error and how I can make my cache working it would be awesome! (I could find only tutorial but no sample project using the cacheable annotation).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload