2 Replies Latest reply on Aug 26, 2013 10:30 AM by vikrammurugesan

    java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.cache.infinispan.JndiInfinispanRegionFactory"

    vikrammurugesan

      I am trying to migrate an application from EAP 5.1.2 to EAP 6.0.1. We have been using JBoss Cache 2 previously and this is my first try at using Infinispan.

       

      I see this exception during app startup. As far as I understand in order to use Infinispan I have to add a module dependency in my jboss-deployment-structure.xml

       

       

      {code}11:00:58,899 ERROR [com.myapp.core.hibernate.HibernateUtil] (MSC service thread 1-8) Initial SessionFactory creation failed.: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.infinispan.JndiInfinispanRegionFactory"]

                at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:410) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]

                at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:264) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]

                at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2279) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]

                at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2275) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]

                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1744) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]

                at com.myapp.core.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:75) [myapp-core-10.0.0-HEAD-SNAPSHOT.jar:]

                at com.myapp.MyappListener.contextInitialized(MyappListener.java:74) [classes:]

                at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.17.Final-redhat-1.jar:]

                at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.17.Final-redhat-1.jar:]

                at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:89) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExAecutor.java:1145) [rt.jar:1.7.0_25]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]

                at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]

      Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.cache.infinispan.JndiInfinispanRegionFactory"]

                at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]

                at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:393) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]

                ... 14 more

      Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.cache.infinispan.JndiInfinispanRegionFactory"

                at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.java:99) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]

                at java.lang.ClassLoader.loadClass(ClassLoader.java:424) [rt.jar:1.7.0_25]

                at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [rt.jar:1.7.0_25]

                at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_25]

                at java.lang.Class.forName(Class.java:270) [rt.jar:1.7.0_25]

                at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]

                ... 15 more{code}

       

       

       

      Here is the subdeployment section of my jboss-deployment-structure.xml

       

      {code:xml}

      <sub-deployment name="mywebapp.war">

                <dependencies>

                          <module name="javax.api" />

                          <module name="javax.persistence.api" />

                          <module name="org.hibernate" />

                </dependencies>

       

                <resources>

                          <resource-root path="mydependency.jar"/>

                </resources>

       

       

                <local-last value="false" />

      </sub-deployment>

      {code}

       

      Here is part of my hibernate.cfg.xml

       

      {code:xml}

      <property name="hibernate.cache.region.factory_class">org.hibernate.cache.infinispan.JndiInfinispanRegionFactory"</property>

      <property name="hibernate.cache.infinispan.cachemanager">java:jboss/infinispan/hibernate"</property>

      <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>

      <property name="hibernate.cache.use_second_level_cache">true</property>

      <property name="hibernate.cache.use_minimal_puts">true</property>

      {code}

       

      Appreciate any help. I would be glad to provde more details.