10 Replies Latest reply on Feb 16, 2016 3:13 AM by André Faber

    Unable to load class InfinispanDirectoryProvider

    André Faber Newbie

      Hello,

       

      I'm trying to create a project in wildfly 10 using infinispan as second cache for hibernate.

       

      When deploying my project I get the error

       

      Caused by: org.hibernate.search.engine.service.classloading.spi.ClassLoadingException: Unable to load class [org.infinispan.hibernate.search.spi.InfinspanDirectoryProvider

       

      So I added the depency to my pom file

      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-directory-provider</artifactId>
         <version>8.1.0.Final</version>
      </dependency>
      

       

       

      But this leads to the following error:

      11:37:48,876 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 26) MSC000001: Failed to start service jboss.persistenceunit."accident-w

      ildfly10-DVLP.war#accident": org.jboss.msc.service.StartException in service jboss.persistenceunit."accident-wildfly10-DVLP.war#accident": java.lang.L

      inkageError: loader constraint violation in interface itable initialization: when resolving method "org.infinispan.lucene.logging.Log_$logger.customIn

      terceptorMissingClass()Lorg/infinispan/commons/CacheConfigurationException;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the

      current class, org/infinispan/lucene/logging/Log_$logger, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for interface org/in

      finispan/util/logging/Log have different Class objects for the type org/infinispan/commons/CacheConfigurationException used in the signature

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172)

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117)

              at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:667)

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182)

              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

              at java.lang.Thread.run(Thread.java:745)

              at org.jboss.threads.JBossThread.run(JBossThread.java:320)

      Caused by: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.infinispan.lucene.loggin

      g.Log_$logger.customInterceptorMissingClass()Lorg/infinispan/commons/CacheConfigurationException;" the class loader (instance of org/jboss/modules/Mod

      uleClassLoader) of the current class, org/infinispan/lucene/logging/Log_$logger, and the class loader (instance of org/jboss/modules/ModuleClassLoader

      ) for interface org/infinispan/util/logging/Log have different Class objects for the type org/infinispan/commons/CacheConfigurationException used in t

      he signature

              at java.lang.Class.forName0(Native Method)

              at java.lang.Class.forName(Class.java:344)

              at org.jboss.logging.Logger$1.run(Logger.java:2554)

              at java.security.AccessController.doPrivileged(Native Method)

              at org.jboss.logging.Logger.getMessageLogger(Logger.java:2529)

              at org.jboss.logging.Logger.getMessageLogger(Logger.java:2516)

              at org.infinispan.util.logging.LogFactory.getLog(LogFactory.java:21)

              at org.infinispan.lucene.impl.DirectoryBuilderImpl.<clinit>(DirectoryBuilderImpl.java:25)

              at org.infinispan.lucene.directory.DirectoryBuilder.newDirectoryInstance(DirectoryBuilder.java:25)

              at org.infinispan.hibernate.search.spi.InfinispanDirectoryProvider.start(InfinispanDirectoryProvider.java:117)

              at org.hibernate.search.indexes.spi.DirectoryBasedIndexManager.initialize(DirectoryBasedIndexManager.java:108)

              at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:256)

              at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:513)

              at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManagers(IndexManagerHolder.java:482)

              at org.hibernate.search.indexes.impl.IndexManagerHolder.buildEntityIndexBinding(IndexManagerHolder.java:91)

              at org.hibernate.search.spi.SearchIntegratorBuilder.initDocumentBuilders(SearchIntegratorBuilder.java:358)

              at org.hibernate.search.spi.SearchIntegratorBuilder.buildNewSearchFactory(SearchIntegratorBuilder.java:199)

              at org.hibernate.search.spi.SearchIntegratorBuilder.buildSearchIntegrator(SearchIntegratorBuilder.java:117)

              at org.hibernate.search.hcore.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated(HibernateSearchSessionFactoryObserver.java:75)

              at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35)

              at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:530)

              at org.hibernate.boot.internal.SessionFactoryBuilderImpl.__build(SessionFactoryBuilderImpl.java:444)

              at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java)

              at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879)

              at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.__build(TwoPhaseBootstrapImpl.java:44)

              at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java)

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:154)

              ... 7 more

      So there seems to be a "crash" of the signature of "CacheConfigurationException" in this modul?

      Am I missing something? Can anyone help?

       

      Thanks in advance

        • 1. Re: Unable to load class InfinispanDirectoryProvider
          Radim Vansa Master

          You shouldn't be forced to add any infinispan modules yourselves. Please provide the full stack trace of the classloading error, and preferably your config (server standalone.xml and app's persistence.xml) as well.

          • 2. Re: Unable to load class InfinispanDirectoryProvider
            André Faber Newbie

            Here is my persistence:

            <?xml version="1.0" encoding="UTF-8"?>
            <persistence xmlns="http://java.sun.com/xml/ns/persistence"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
               version="2.0">

               <persistence-unit name="${project.name}">

               <jta-data-source>${jta.datasource}</jta-data-source>

               <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>

               <properties>

               <property name="hibernate.default_schema" value="${jta.schema}" />

               <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />

             

               <property name="jboss.entity.manager.factory.jndi.name" value="java:/${project.name}EntityManagerFactory" />

               <property name="hibernate.hbm2ddl.auto" value="validate" />

               <property name="hibernate.show_sql" value="false" />

               <property name="hibernate.format_sql" value="false" />

             

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

               <property name="hibernate.cache.use_query_cache" value="true" />

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

             

               <property name="org.hibernate.envers.audit_table_suffix" value="_hist" />

               <property name="org.hibernate.envers.store_data_at_delete" value="true" />

               <property name="org.hibernate.envers.do_not_audit_optimistic_locking_field" value="false" />

             

               <property name="hibernate.search.default.directory_provider" value="infinispan" />

               <property name="hibernate.search.default.worker.backend" value="jgroups" />

               <property name="hibernate.search.infinispan.configuration_resourcename" value="infinispan-config.xml" />

               <property name="hibernate.search.services.jgroups.clusterName"
               value="HibernateSearch-Infinispan-cluster_${project.name}_${classifier}" />

             

               <property name="hibernate.search.default.data_cachename" value="LuceneIndexesData_${project.name}_${classifier}" />

               <property name="hibernate.search.default.metadata_cachename" value="LuceneIndexesMetadata_${project.name}_${classifier}" />

               </properties>

               </persistence-unit>

            </persistence>

            I found out that

            <property name="hibernate.search.default.directory_provider" value="infinispan" />

            causes the need for the dependency, but if I delete it it seems that I can no longer specify the directory of the saved indexes which I specify by using

            <replicated-cache name="LuceneIndexesMetadata_${project.name}_${classifier}" mode="SYNC" remote-timeout="25000">
               <transaction mode="NONE"/>

               <eviction max-entries="-1" strategy="NONE"/>
               <persistence passivation="false">

               <file-store path="/data/indexes/infinispan/fullTextStore/${project.name}_${classifier}" preload="true"/>

               </persistence>
            </replicated-cache>

            In my "infinispan-config.xml" file...

            • 3. Re: Unable to load class InfinispanDirectoryProvider
              Gustavo Fernandes Apprentice

              As Radim pointed out, to use the second level cache on Infinispan you don't need to add any Infinispan dependency at all, it will automatically use the Infinispan subsystem present in Wildfly.

              More info on https://docs.jboss.org/author/display/WFLY10/JPA+Reference+Guide#JPAReferenceGuide-UsingtheInfinispansecondlevelcache

               

              But it looks like you also want to use Hibernate Search with indexes on Infinispan, is that correct? If so, since Hibernate Search is not shipping the Infinispan Directory Provider anymore, you need to add it to the modules/ folder of your Wildfly distribution. The modules can be obtained from http://infinispan.org/download/

               

              Finally, you do not need to depend on Infinispan in your pom.xml

              • 4. Re: Unable to load class InfinispanDirectoryProvider
                André Faber Newbie

                But it looks like you also want to use Hibernate Search with indexes on Infinispan, is that correct?

                Yes, that's correct.

                 

                I downloaded the modules from the infinispan page an extracted them to my modules directory.

                 

                Now I get the following error:

                09:33:11,475 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 6) MSC000001: Failed to start service jboss.persistenceunit."accident-wi

                ldfly10-DVLP.war#accident": org.jboss.msc.service.StartException in service jboss.persistenceunit."accident-wildfly10-DVLP.war#accident": javax.persis

                tence.PersistenceException: [PersistenceUnit: accident] Unable to build Hibernate SessionFactory

                        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172)

                        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117)

                        at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:667)

                        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182)

                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

                        at java.lang.Thread.run(Thread.java:745)

                        at org.jboss.threads.JBossThread.run(JBossThread.java:320)

                Caused by: javax.persistence.PersistenceException: [PersistenceUnit: accident] Unable to build Hibernate SessionFactory

                        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:954)

                        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:882)

                        at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.__build(TwoPhaseBootstrapImpl.java:44)

                        at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java)

                        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:154)

                        ... 7 more

                Caused by: org.hibernate.search.exception.SearchException: HSEARCH000103: Unable to initialize IndexManager named 'lu.etat.pch.accident.ejb.entity.Res

                ponsable'

                        at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:260)

                        at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:513)

                        at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManagers(IndexManagerHolder.java:482)

                        at org.hibernate.search.indexes.impl.IndexManagerHolder.buildEntityIndexBinding(IndexManagerHolder.java:91)

                        at org.hibernate.search.spi.SearchIntegratorBuilder.initDocumentBuilders(SearchIntegratorBuilder.java:358)

                        at org.hibernate.search.spi.SearchIntegratorBuilder.buildNewSearchFactory(SearchIntegratorBuilder.java:199)

                        at org.hibernate.search.spi.SearchIntegratorBuilder.buildSearchIntegrator(SearchIntegratorBuilder.java:117)

                        at org.hibernate.search.hcore.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated(HibernateSearchSessionFactoryObserver.java:75)

                        at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35)

                        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:530)

                        at org.hibernate.boot.internal.SessionFactoryBuilderImpl.__build(SessionFactoryBuilderImpl.java:444)

                        at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java)

                        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879)

                        ... 10 more

                Caused by: org.hibernate.search.exception.SearchException: Wrong configuration of directory provider: class org.infinispan.hibernate.search.spi.Infini

                spanDirectoryProvider does not implement interface org.hibernate.search.store.DirectoryProvider

                        at org.hibernate.search.util.impl.ClassLoaderHelper.verifySuperTypeCompatibility(ClassLoaderHelper.java:113)

                        at org.hibernate.search.util.impl.ClassLoaderHelper.instanceFromClass(ClassLoaderHelper.java:93)

                        at org.hibernate.search.util.impl.ClassLoaderHelper.instanceFromName(ClassLoaderHelper.java:58)

                        at org.hibernate.search.store.spi.BaseDirectoryProviderService.initialize(BaseDirectoryProviderService.java:57)

                        at org.hibernate.search.store.spi.BaseDirectoryProviderService.create(BaseDirectoryProviderService.java:52)

                        at org.hibernate.search.indexes.spi.DirectoryBasedIndexManager.createDirectoryProvider(DirectoryBasedIndexManager.java:230)

                        at org.hibernate.search.indexes.spi.DirectoryBasedIndexManager.initialize(DirectoryBasedIndexManager.java:90)

                        at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:256)

                        ... 22 more

                 

                So I looked into the InfinispanDirectoryProvider file where I found:

                ...

                import org.hibernate.search.store.DirectoryProvider;

                ...

                public class InfinispanDirectoryProvider implements DirectoryProvider<Directory> {

                 

                This seems to be correct?

                • 5. Re: Unable to load class InfinispanDirectoryProvider
                  Gustavo Fernandes Apprentice

                  Hi, please ensure that both the Hibernate and the Infinispan dependencies used in your application are those shipped with Wildfly or the Infinispan modules, more specifically:

                   

                  - You do not have hibernate search jars in your war

                  - You do not have Infinispan deps in our war

                  - Your WAR's META-INF/MANIFEST.MF contains:

                   

                  Dependencies: org.hibernate.search.orm:5.5.1.Final services

                  • 6. Re: Unable to load class InfinispanDirectoryProvider
                    André Faber Newbie

                    Yes, no hibernate and no infinispan dependencies in my war anymore and

                    <module name="org.hibernate.search.orm" services="export"/>

                    in my jboss-deployement-structure.xml

                     

                    P.S.: my configuration was working for wildfly9

                    • 7. Re: Unable to load class InfinispanDirectoryProvider
                      Gustavo Fernandes Apprentice

                      The Infinispan Directory Provider that is distributed with the modules zip links against its own hibernate search engine, so you need a small change in your manifest:

                      <module name="org.hibernate.search.orm" services="export" slot="5.5"/>

                      • 8. Re: Unable to load class InfinispanDirectoryProvider
                        André Faber Newbie

                        Still the same error :

                        Caused by: org.hibernate.search.exception.SearchException: Wrong configuration of directory provider: class org.infinispan.hibernate.search.spi.Infini

                        spanDirectoryProvider does not implement interface org.hibernate.search.store.DirectoryProvider

                        • 9. Re: Unable to load class InfinispanDirectoryProvider
                          Gustavo Fernandes Apprentice

                          Before opening a JIRA with debug logs, I just came across a change that might explain why you have version conflict even though manually specifying the slot you want, documented in https://issues.jboss.org/browse/WFLY-4956

                          Long story short, try adding to your persistence.xml the following to prevent the deployer to automatically pick the hibernate search version for you:

                           

                          <property name="wildfly.jpa.hibernate.search.module" value="none" />

                          • 10. Re: Unable to load class InfinispanDirectoryProvider
                            André Faber Newbie

                            Yes! This did it! Thank you, very much for your work