8 Replies Latest reply: Mar 4, 2013 8:56 AM by Anders Jespersen RSS

    Error using indexed cache in JBoss 7.1.0 Final

    Anders Jespersen Newbie

      Setup three containers in standalone.xml:

        <cache-container name="bskCache" default-cache="data">

                      <local-cache name="data" start="EAGER">

                          <eviction strategy="LRU" max-entries="10000"/>

                          <expiration max-idle="600000"/>


                      <local-cache name="credentials">

                          <eviction strategy="LRU" max-entries="10000"/>

                          <expiration max-idle="600000"/>


                      <local-cache name="searchindex" start="EAGER" indexing="LOCAL">

                          <eviction strategy="LRU" max-entries="10000"/>

                          <expiration max-idle="108000000"/>





      Added infinispan-query, hibernate-search with dependencies as jar-files to the org.infinispan-module. module.xml:

         <resource-root path="infinispan-query-5.1.1.Final.jar"/>

          <resource-root path="avro-1.5.1.jar"/>

          <resource-root path="jackson-core-asl-1.7.3.jar"/>

          <resource-root path="jackson-mapper-asl-1.7.3.jar"/>

          <resource-root path="paranamer-2.3.jar"/>

          <resource-root path="snappy-java-1.0.1-rc3.jar"/>


          <resource-root path="lucene-core-3.5.0.jar"/>


          <resource-root path="hibernate-search-4.1.0.CR1.jar"/>

          <resource-root path="hibernate-search-orm-4.1.0.CR1.jar"/>

          <resource-root path="hibernate-search-analyzers-4.1.0.CR1.jar"/>

          <resource-root path="hibernate-search-engine-4.1.0.CR1.jar"/>


          <resource-root path="lucene-analyzers-3.5.0.jar"/>

          <resource-root path="lucene-grouping-3.5.0.jar"/>

          <resource-root path="lucene-highlighter-3.5.0.jar"/>

          <resource-root path="lucene-memory-3.5.0.jar"/>

          <resource-root path="lucene-misc-3.5.0.jar"/>

          <resource-root path="lucene-smartcn-3.5.0.jar"/>

          <resource-root path="lucene-spatial-3.5.0.jar"/>

          <resource-root path="lucene-spellchecker-3.5.0.jar"/>

          <resource-root path="lucene-stempel-3.5.0.jar"/>


          <resource-root path="solr-analysis-extras-3.5.0.jar"/>

          <resource-root path="solr-commons-csv-3.5.0.jar"/>

          <resource-root path="solr-core-3.5.0.jar"/>

          <resource-root path="solr-solrj-3.5.0.jar"/>



      Plus these dependencies already in other JBoss 7 modules:


         <module name="javax.api"/>

      <!--added -->

         <module name="org.hibernate"/>

         <module name="org.apache.commons.codec"/>

         <module name="org.apache.commons.io"/>

         <module name="org.apache.commons.lang"/>

         <module name="com.google.guava"/>



      Deployed as EAR with this jboss-deployment-structure.xml:





            <module name="org.apache.log4j" export="true"/>

            <module name="com.h2database.h2" export="true"/>

            <module name="org.slf4j" export="true"/>

            <module name="org.hibernate" export="true" services="import"/>

            <module name="org.infinispan" export="true" services="import"/>

            <module name="org.apache.commons.beanutils" export="true"/>

            <module name="org.apache.commons.codec" export="true"/>

            <module name="org.jboss.ws.cxf.jbossws-cxf-client" export="true" services="import"/>






      I can @Resource-inject the cache and put index-annotated into it, but when I attempt to get a searchmanager:

        SearchManager searchManager = Search.getSearchManager(searchindexCache);


      I get:

      java.lang.IllegalArgumentException: Indexing was not enabled on this cache. interface org.hibernate.search.spi.SearchFactoryIntegrator not found in registry



      I have this running on plain JRE with a new DefaultCacheManager and infinispan.xml-configuration.

      I tried including the jars in the ear, and also to instatiate my own DefaultCacheManager inside JBoss 7. But the error is the same.

      Added: I tried adding the SearchFactoryIntegrator manually, which gets me to a new missing component, QueryInterceptor (which I cannot add after cache has started).. This appears to be a classloader issue ?


      Message was edited by: Anders Jespersen  - added info

        • 1. Re: Error using indexed cache in JBoss 7.1.0 Final
          Anders Jespersen Newbie

          Well, gave it another shot including search-jars in the ear and got something running by starting a cache embedded.


          I still think all those jars should rather be in a module on the server, letting the AS handle cache lifecycle. But even with the export=true, the ServiceLoader won't pick up the Infinispan Query being present:

          ServiceLoader<ModuleLifecycle> moduleLifecycleLoader = ServiceLoader.load(ModuleLifecycle.class, cl);

          I couldn't see how to experiment with other classloader or get the LifecycleManager available from the default one.


          Is this more of an AS 7 issue (or JBoss Modules) ?

          • 2. Re: Error using indexed cache in JBoss 7.1.0 Final
            Anders Jespersen Newbie

            Not sure exactly what made the difference, but I've got it running now.

            I created a new module 'org.infinispan.query' containing alle the hibernate-search and infinispan-query-jars and dependencies.

            I further modified module jboss.as.clustering.infinispan's module.xml to include my new module:

                 <module name="org.infinispan.query" services="import"/>


            As well as added it to the EAR's jboss-deployment-structure.xml:

                 <module name="org.infinispan.query" export="true" services="import"/>


            I guess this was then after all a JBoss 7 issue..


            Update: I've written an update on this regarding 7.2-alpha: https://community.jboss.org/thread/223455

            • 3. Re: Error using indexed cache in JBoss 7.1.0 Final
              Jithendra reddy Newbie

              Hi Anders,


              can you be kind enough to share your implementation with me? I am also doing something similar now and need some help making this infinispan-query work on the jboss server.


              It's been almost three years now that you last replied to your post. Hoping that you still have your implementation. Thanks



              • 4. Re: Error using indexed cache in JBoss 7.1.0 Final
                Anders Jespersen Newbie

                it's been a little less than a year


                We've got this running in production, 7.1.0.Final. Only current issue is the inability to keep the lucene index in memory. Index files are written into files on the server, and must be removed at server restart, to function properly. Should be fixed in 7.2 though (https://issues.jboss.org/browse/AS7-4022)


                I have attached my infinispan-query-module as query.zip, place it in modules: <AS7>/modules/org/infinispan/query

                And modified version of modules/org/jboss/as/clustering/infinispan/main/module.xml

                And example jboss-deployment-structure.xml.

                • 5. Re: Error using indexed cache in JBoss 7.1.0 Final
                  Jithendra reddy Newbie

                  Thanks a lot Anders. With the help of the query module you gave, i did some upgrades as i am using jboss as 7.1.2.

                  Upgraded infinispan-query to 5.2.0.ALPHA2 and hibernate-search and related jars to 4.1.0.CR3.


                  The server starts fine now. But when i test the infinispan querying, it's failing at the place where we get the SearchManager.


                  SearchManager sm = Search.getSearchManager(cache);


                  I get a classcast exception saying



                  java.lang.ClassCastException: org.hibernate.search.impl.MutableSearchFactory cannot be cast to org.hibernate.search.spi.SearchFactoryIntegrator


                       at org.infinispan.query.SearchManagerImpl.<init>(SearchManagerImpl.java:59)


                       at org.infinispan.query.Search.getSearchManager(Search.java:39)


                  Checked the source on the MutableSearchFactory, looks like it's implementing the SearchFactoryIntegrator. Not sure why am i getting the class cast there.


                  Help me if you have run into similar situation like this.


                  By the way, my cache configuration is same as what you have at the top of your description.



                  • 6. Re: Error using indexed cache in JBoss 7.1.0 Final
                    Anders Jespersen Newbie

                    I can't recall having seen that. Some extracts from my implementation (an EJB):


                    import org.infinispan.Cache;

                    import org.infinispan.query.CacheQuery;

                    import org.infinispan.query.Search;

                    import org.infinispan.query.SearchManager;


                    @Resource(mappedName = "java:jboss/infinispan/cache/bskCache/searchindex")

                    Cache<String, Object> searchindexCache;


                    SearchManager searchManager = Search.getSearchManager(searchindexCache);


                    I had it running briefly on EAP6 (7.1.2.Final-redhat-1) using:



                    + dependencies.


                    Can't remember if search worked a 100% though.

                    • 7. Re: Error using indexed cache in JBoss 7.1.0 Final
                      Jithendra reddy Newbie

                      Hi Anders,


                      I should try that. I was injecting the embeddedCacheManager instead of injecting the particular cache as you did. May be, this might make a difference.

                      For now, i have my implementation running by creating a cache programatically, not using the one from the infinispan subsystem, which i guess is not the right way.


                      Also i am trying to do the wild card searching on some of my fields in the object which i have indexed. The field values will have DS1IT-12 as common and when i am doing the wild card search passing in the query string as serviceId:DS1IT-12*, the queryAnalyzer is changing that to serviceId:ds1it-12* which is resulting zero results. The normal searches work just fine though. Do you have anything that could help me here?


                      My search implementation:


                      SearchManager sm = Search.getSearchManager(cache);



                                  Query q = new QueryParser(Version.LUCENE_35, "serviceId", sm.getSearchFactory().getAnalyzer(Qcinventory.class)).parse(searchString);

                                  CacheQuery cq = sm.getQuery(q, Qcinventory.class);

                              }catch(Exception e){

                                  System.out.println("Exception parsing query : ");



                      searchString being the serviceId:DS1IT-12* or something else.


                      The analyzer used seems to be ScopedAnalyzer. So not sure, if you have a different implemenation to this.



                      • 8. Re: Error using indexed cache in JBoss 7.1.0 Final
                        Anders Jespersen Newbie

                        I'm haven't seen this. Not too sharp on lucene/hib search, though, so you might wan't to ask there.


                        My analyzer is set manually, like this (I can no longer remember, exactly why..):



                        @AnalyzerDef(name = "bskAnalyzer",

                                tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),

                                filters = {

                                        @TokenFilterDef(factory = ASCIIFoldingFilterFactory.class),

                                        @TokenFilterDef(factory = LowerCaseFilterFactory.class)


                        @Analyzer(definition = "bskAnalyzer")

                        public class IndexedUser implements Serializable {


                          @Field(index = Index.YES, analyze = Analyze.NO, store = Store.NO)

                          private String cn;





                        I use * in some queries, but all rolled into on big hibernate search query (and not from user entry).