7 Replies Latest reply on Nov 3, 2011 2:37 PM by Sanne Grinovero

    HSearch and ISPN-658: You are not starting all your caches at the same time

    Horacio Vico Newbie

      Hi!

       

      I successfully configured my Hibernate Search 3.4.1 application to store its Lucene indexes using Infinispan 5.0.1. My infinispan cluster has 2 identical nodes and work fine.

       

      The thing is I get the following warning at application startup:

       

      WARN  [DefaultCacheManager] ISPN000156: You are not starting all your caches at the same time. This can lead to problems as asymmetric 
      
      clusters are not supported, see ISPN-658. We recommend using EmbeddedCacheManager.startCaches() to start all your caches upfront.
      

       

      My infinispan cache is started automatically somehow by Hibernate Search, so I do not have control to call this "startCaches()" method anywhere. My infinispan XML config has three namedCaches declared on it, LuceneIndexesLocking, LuceneIndexesMetadata and LuceneIndexesData. I would post my config here, but I think it has nothing to do with this warning. It seems that Hibernate Search starts the caches incorrectly, am I wrong?

       

      I would appreciate further information on this, and possibly a workaround to avoid this potential problem.

       

      Thanks in advance,

        • 1. Re: HSearch and ISPN-658: You are not starting all your caches at the same time
          Sanne Grinovero Master

          Hi. Hibernate Search was developed depending on Infinispan 4.2, which didn't have the startCaches method, so you are right it is not using the recommended way to start Infinispan 5.

           

          The startCaches method was introduced to avoid a timing issue at boot time of Infinispan: if the cluster is started fine then you can ignore the warning; occasionally it might fail to start Infinispan, especially when joining an existing cluster (the second node in your case).

           

          If that is a problem you can

          • a) patch Hibernate Search as the fix is trivial
          • b) upgrade to Hibernate Search 4
          • c) start Infinispan yourself and have Search retrieve it via JNDI
          • 2. Re: HSearch and ISPN-658: You are not starting all your caches at the same time
            Horacio Vico Newbie

            Excelent Sanne, I will try your suggested fixes!

             

            Thanks!

            • 3. Re: HSearch and ISPN-658: You are not starting all your caches at the same time
              Horacio Vico Newbie

              Hi!

               

              I've been trying to implement the third strategy (start Infinispan myself and have Search retrieve it via JNDI).

               

              I succeeded starting infinispan and exposing it via JNDI, but when my HSearch application tries to retrieve it I am getting the following exception:

               

              Caused by: java.lang.ClassCastException: org.infinispan.manager.DefaultCacheManager cannot be cast to org.infinispan.manager.EmbeddedCacheManager

                        at org.hibernate.search.infinispan.CacheManagerServiceProvider.locateCacheManager(CacheManagerServiceProvider.java:115)

                        at org.hibernate.search.infinispan.CacheManagerServiceProvider.start(CacheManagerServiceProvider.java:106)

                        at org.hibernate.search.engine.ServiceManager$ServiceProviderWrapper.increaseCounter(ServiceManager.java:135)

                        at org.hibernate.search.engine.ServiceManager.requestService(ServiceManager.java:88)

                        at org.hibernate.search.spi.SearchFactoryBuilder$BuildContext.requestService(SearchFactoryBuilder.java:656)

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

                        at org.hibernate.search.store.DirectoryProviderFactory.startDirectoryProviders(DirectoryProviderFactory.java:144)

                        at org.hibernate.search.spi.SearchFactoryBuilder.initDocumentBuilders(SearchFactoryBuilder.java:403)

                        at org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:262)

                        at org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:144)

                        at org.hibernate.search.event.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:151)

                        at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)

                        at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)

                        at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)

               

              My cache is initialized this way:

               

              EmbeddedCacheManager cache = new DefaultCacheManager("infinispan.xml");

               

              and then is exposed via JNDI:

               

              bind(jndiName,cache,org.infinispan.Cache.class,rootCtx);

               

              Any help would be appreciated.

               

              Thanks,

              • 4. Re: HSearch and ISPN-658: You are not starting all your caches at the same time
                Sanne Grinovero Master

                Hi,

                that means you're having duplicate class definitions. I guess you're having Infinispan jars with your application, in addition to another place?

                Remove them from your app and have it load the same Infinispan classes you're using to start it.

                 

                If you can't find the duplicates directly, use a classpath scanning tool like Tattletale.

                1 of 1 people found this helpful
                • 5. Re: HSearch and ISPN-658: You are not starting all your caches at the same time
                  Horacio Vico Newbie

                  Hi, thank you again Sanne.

                   

                  I have infinispan jar inside my HSearch application's lib folder. Initially I copied them inside my server/default/lib directory, but that didn't work because some logging classes that Infinispan require (BasicLogger), conflict with other libs provided by JBoss AS 4.2.

                   

                  I am starting infinispan in a separate JBoss SAR, and I had to isolate it for the same reason, so it has its own infinispan jars.

                   

                  Really, this classloader issues are a nightmare, I am really confused.

                   

                  Any suggestion?

                   

                  Thanks,

                  • 6. Re: HSearch and ISPN-658: You are not starting all your caches at the same time
                    Horacio Vico Newbie

                    I found a workaround and fixed it!

                     

                    I overode the org.hibernate.search.infinispan.CacheManagerServiceProvider class that ships in hibernate-search-infinispan.jar. Now I launch my Infinispan initialization code from there, at the start method before it tries to hook to the JNDI CacheManager.

                     

                    Thanks!

                    • 7. Re: HSearch and ISPN-658: You are not starting all your caches at the same time
                      Sanne Grinovero Master

                      Right! you can always plug in your own DirectoryProvider.

                      I didn't know about the Logger incompatibility with JBoss4, good to know.