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
      nit:unitName=dpjwApp-ear-1.0.ear/dpjw-core-1.0.jar#dpjw.org.dpjw.base.domain.Dis
      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
      4)
       at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.buil
      dEntityRegion(RegionFactoryCacheProviderBridge.java:96)
       at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
      255)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
      a:1327)
       at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(Annotat
      ionConfiguration.java:867)
       at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Con
      figuration.java:669)
       at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFa
      ctory(HibernatePersistence.java:132)
       at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceU
      nitDeployment.java:311)


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

      Carlo

        • 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:

          persistence.unit:unitName=dpjwApp-ear-1.0.ear/dpjw-core-1.0.jar#dpjw_office.
          

          whereas in JBoss 4.2.3 it was
          dpjwApp-ear-1_0_ear,dpjw_office.
          
          .

          Carlo

          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??? ++