2 Replies Latest reply on Jan 12, 2009 7:34 AM by Israel Lacerra

    JBoss5, Hibernate and EHCache

    Carlo Luib-Finetti Newbie

      With JBoss 5 going to GA, I gave it a try with our application which is a EJB3 application with Hibernate as JPA provider running on JBoss 4.2.x. We have also configured to use EhCache.

      Installing the application as EAR on JBoss 5 now shows an error on startup for which I have no idea to solve it. Here is the relevant stacktrace:

      09:16:25,199 INFO [SessionFactoryImpl] building session factory
      09:16:26,167 WARN [EhCacheProvider] Could not find configuration [persistence.u
      trict]; using defaults.
      09:16:26,167 ERROR [AbstractKernelController] Error installing to Start: name=pe
      rsistence.unit:unitName=dpjwApp-ear-1.0.ear/dpjw-core-1.0.jar#dpjw state=Create
      java.lang.IllegalArgumentException: Cache name cannot contain '/' characters.
       at net.sf.ehcache.Cache.setName(Cache.java:1272)
       at net.sf.ehcache.CacheManager.addCache(CacheManager.java:501)
       at org.hibernate.cache.EhCacheProvider.buildCache(EhCacheProvider.java:9
       at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.buil
       at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
       at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(Annotat
       at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Con
       at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFa
       at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceU

      Is there anybody here who can give us a pointer to a solution?


        • 1. Re: JBoss5, Hibernate and EHCache
          Carlo Luib-Finetti Newbie

          I tracked the problem within the debugger and found the source of the error. Obivously it is a different naming scheme they have in JBoss 5.

          Looking at the constructor of Hibernate's SessionFactoryImpl(), I saw the creation of a local variable named 'cacheRegionPrefix' (String cacheRegionPrefix = settings.getCacheRegionPrefix()), which is then later used as argument for a cache region name.
          Now, in JBoss this cacheRegionPrefix results into something like this:


          whereas in JBoss 4.2.3 it was


          Nice to see: BUT what can WE do here???

          • 2. Re: JBoss5, Hibernate and EHCache
            Israel Lacerra Newbie

            I'm having the same problem!

            BUT what can WE do here??? ++