Upgrading to Spring 2.0 and Hibernate 3.2

Tonight I just completed the upgrade from Spring 1.2 and Hibernate 3.1 to Spring 2.0 and Hibernate 3.2 for work. I was expecting a rough upgrade but was pleasantly surprised how easily it went.

Our entire unit and integration test suite which hits Spring and Hibernate pretty good runs in about the same amount of time so there doesn’t appear to be any significant performance penalty or improvement with the upgrade.

I had one minor problem and it was that we connect to multiple databases so we have multiple session factories that interact with EhCache. Hibernates org.hibernate.cache.EhCacheProvider now expects one configuration per sesssion factory which I wasn’t too excited about given we have 51 databases (1 database per state plus Washington DC) and it’s been working fine for 2 years with one cache provider. The problem caused this exception:

 Invocation of init method failed; nested exception is java.lang.NullPointerException
    [java] Caused by: org.springframework.beans.factory.BeanCreationException: 
       Error creating bean with name 'surveysSessionFactory' defined in class path resource
          [gs/data/dao/hibernate/applicationContext-hibernate.xml]: 
          Invocation of init method failed; 
          nested exception is java.lang.NullPointerException
    [java] Caused by: java.lang.NullPointerException
    [java] at net.sf.ehcache.CacheManager.detectAndFixDiskStorePathConflict(CacheManager.java:269)
    ...

However, I wasn’t the only person who had this problem so a quick search turned up that EhCache now offers the net.sf.ehcache.hibernate.SingletonEhCacheProvider and switching the hibernate.cache.provider_class property to this new provider solved the problem and allows us to continue using a single cache provider.

This entry was posted in Database, Java, Software Engineering. Bookmark the permalink.

3 Responses to Upgrading to Spring 2.0 and Hibernate 3.2

  1. Mike Dillon says:

    That NPE is a bug in EHCache. In the case that there is more than one CacheManager, the code attempts to check disk store paths to make sure no two managers are using the same path. Unfortunately, it does not have an exception for CacheManagers without a disk store path, so it ends up blowing up with the NPE when it tries to compare the null disk store path to another manager’s path.

  2. Mike Dillon says:

    FYI, the bug has been patched and will be fixed in EHCache 1.2.4.

  3. spike says:

    the null path check bug can be replicated in ehcache 2.0.1

Leave a Reply

Your email address will not be published. Required fields are marked *