java.lang.NoSuchMethodError: net.sf.ehcache.Cache.<init>

This entry is about the aforementioned exception which was thrown in an application I am working.

Environment

The application uses the following libraries

  • Spring framework (version 2.5)
  • Hibernate JPA (version 3.2.x)
  • Acegi Security

Cause

As indicated in the exception, the error is thrown by the ehcache library and in my case version 1.2.3. In simple terms the init method can not be found in the aforementioned version of ecache. The stack trace of the exception indicates that the absence of the method affected the creation of a cache for use by Acegi. The cache bean has been configured in Spring to allow it to be injected into Acegi authentication & authorization beans.

How did version 1.2.3 of ecache end up in the application’s class path? Well, that boils down to my recent decision to switch from using TopLink as a JPA library to using Hibernate JPA. The hibernate JPA in my IDE uses version 1.2.3 of ecache instead of version 1.3.0 which I also have in my class path.

Solution

The solution that worked for me (suggested in the reference below) was to remove the old version of ecache and using echache version 1.3.0.

Reference

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: