12 Replies Latest reply on Nov 11, 2010 9:53 AM by AJ Joy

    Unable to query Infinispan. Getting the Module propertes error. Please advise

    Savin Seven Newbie

      Dear All,

       

      I am querying Infinispan using the below class, That queries the customer class with field name customerId and have to fetches the value for that Customer.

       

      -------------------------------------------------------------------------

       

      import model.Customer;

      public class OurQueryingTest {

      /**
        * @param args
        */
      public static void main(String[] args) {
        Configuration cfg = new Configuration();
        cfg.setIndexingEnabled(true);
        cfg.setIndexLocalOnly(true);
       
        Cache<String,Customer> c  = new DefaultCacheManager(cfg).getCache();
       
        QueryHelper qh = new QueryHelper(c, new Properties(), Customer.class);

        //Adding values to cache
        for(int i=0; i<3; i++){
         Customer customer1 = new Customer("ID"+i,"Name"+i,"Add"+i);
         c.put("cust"+i, customer1);
        }
       
        QueryFactory qf = new QueryFactory(c, qh);
       
        try {
         CacheQuery cq = qf.getBasicQuery("customerID", "ID0");
         System.out.println("CQ Size :"+cq.getResultSize());
         List<Object> found = cq.list();  
         Iterator<Object> itr = found.iterator();
         while(itr.hasNext()) {
          Customer cust = (Customer)itr.next();
          System.out.println("ID is: "+cust.getCustomerID());
          System.out.println("Name is: "+cust.getCustomerID());
          System.out.println("Address is: "+cust.getCustomerID());   
         }    

        } catch(Exception e) {
         e.getStackTrace();
        }

       


      }

      }

      ----------------------------------------------------------------------------------------

      Class to query is Customer class with simple setter & getter methods

       

      -----------------------------------------------------------------------------------------

       

      public class Customer {

      private String customerID;
      private String customerName;
      private String customerAddr;
       
      public Customer(String customerID, String customerName, String customerAddr) {
        super();
        this.customerID = customerID;
        this.customerName = customerName;
        this.customerAddr = customerAddr;
      }

      public String getCustomerID() {
        return customerID;
      }
      public void setCustomerID(String customerID) {
        this.customerID = customerID;
      }
      public String getCustomerName() {
        return customerName;
      }
      public void setCustomerName(String customerName) {
        this.customerName = customerName;
      }
      public String getCustomerAddr() {
        return customerAddr;
      }
      public void setCustomerAddr(String customerAddr) {
        this.customerAddr = customerAddr;
      }

      }

      ----------------------------------------------------------------------------------------------------------

       

      But I was getting the below exception at the execution of this line Cache<String,Customer> c  = new DefaultCacheManager(cfg).getCache();

       

      ----------------------------------------------------------------------------------------------------------

      20-Jul-2010 09:01:01 org.infinispan.util.ModuleProperties loadModuleProperties

      WARNING: Could not load module at URL jar:file:/D:/ourWorkSpace/Infinispan_local/lib/infinispan-query.jar!/infinispan-module.properties

      org.infinispan.config.ConfigurationException

       

      : Module propertes does not specify module configuration class name. Module configuration class name should be specified using key infinispan.module.configurationClassName

      at org.infinispan.util.ModuleProperties.verify(

      ModuleProperties.java:144)

      at org.infinispan.util.ModuleProperties.loadModuleProperties(

      ModuleProperties.java:100)

      at org.infinispan.util.ModuleProperties.resolveModuleLifecycles(

      ModuleProperties.java:112)

      at org.infinispan.factories.AbstractComponentRegistry.<clinit>(

      AbstractComponentRegistry.java:104)

      at org.infinispan.manager.DefaultCacheManager.<init>(

      DefaultCacheManager.java:235)

      at org.infinispan.manager.DefaultCacheManager.<init>(

      DefaultCacheManager.java:157)

      at Test.OurQueryingTest.main(

      OurQueryingTest.java:38)

      20-Jul-2010 09:01:01 org.infinispan.factories.AbstractComponentRegistry internalStart

      INFO: Infinispan version: Infinispan 'Starobrno' 4.0.0.FINAL

      20-Jul-2010 09:01:01 org.infinispan.factories.AbstractComponentRegistry internalStart

      INFO: Infinispan version: Infinispan 'Starobrno' 4.0.0.FINAL

      Exception in thread "main"

      java.lang.IllegalArgumentException: There is no provided id on model.Customer class

      at org.infinispan.query.backend.QueryHelper.validateClasses(

      QueryHelper.java:202)

      at org.infinispan.query.backend.QueryHelper.<init>(

      QueryHelper.java:93)

      at Test.OurQueryingTest.main(

      OurQueryingTest.java:41)

      -------------------------------

       

      -----------------------------------------------------------------------------------------------------------------------------

       

      Please advice how to get rid of this error and sucessfully query my class Customer.

       

      Thanks & Regards,

      Savin

        • 1. Re: Unable to query Infinispan. Getting the Module propertes error. Please advise
          Navin Surtani Newbie

          Hola,

           

          I have the sneakiest of sneaky feelings that you might have missed out on the <indexEnabled /> tag within your configuration. Could you please copy up your configuration.xml file so we can have a look?

           

          Because this is occurring in the setup another possible issue that springs to mind is that there might be a problem with the way that Hibernate Search is dealing with adding the classes that you wish to index. However, I don't see any hibernate exceptions being thrown so I doubt that's the case in there.

           

          Could you just reply with the xml file if possible please? I'm on our #infinispan channel on freenode IRC if you would like to speak with me/us there.

           

          Thanks,

          Navin.

          • 2. Re: Unable to query Infinispan. Getting the Module propertes error. Please advise
            mark chen Newbie

            hi,

            i have encontered this problem, the version of infinispan lib is infinispan-4.0.0.FINAL-single_jar.

            The following is my configer.xml:

             

            --

             

            <?xml version="1.0" encoding="UTF-8"?>
            <infinispan
                xsi:schemaLocation="urn:infinispan:config:4.0 http://www.infinispan.org/schemas/infinispan-config-4.0.xsd"
                xmlns="urn:infinispan:config:4.0">
            </infinispan>

             

            --

            it's just a simple try as using local cache, and i'm the beginner of infinispan.

            Could anyone please give me some hint to solve this problem?

            The following is the error stack trace while compiling(eclipse as the development enviroment):

             

            2010/7/22  12:31:41 org.infinispan.util.ModuleProperties loadModuleProperties

            Warning: Could not load module at URL jar:file:/D:/infinispan-4.0.0.FINAL-single_jar/infinispan-4.0.0.FINAL/infinispan-all.jar!/infinispan-module.properties

            org.infinispan.config.ConfigurationException: Module propertes does not specify module configuration class name. Module configuration class name should be specified using key infinispan.module.configurationClassName

            at org.infinispan.util.ModuleProperties.verify(ModuleProperties.java:144)

            at org.infinispan.util.ModuleProperties.loadModuleProperties(ModuleProperties.java:100)

            at org.infinispan.util.ModuleProperties.resolveModuleLifecycles(ModuleProperties.java:112)

            at org.infinispan.factories.AbstractComponentRegistry.<clinit>(AbstractComponentRegistry.java:104)

            at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:235)

            at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:183)

            at tt.main(tt.java:28)

            those error just occured in this line: CacheManager manager=new DefaultCacheManager();

            • 3. Re: Unable to query Infinispan. Getting the Module propertes error. Please advise
              Manik Surtani Master

              @Mark

               

              We have seen issues with the single_jar ZIP distribution before.  Could you try one of the other distributions, the -bin.ZIP or -all.ZIP distribution?  In 4.1.0 we've discontinued the single_jar ZIP.

              • 4. Re: Unable to query Infinispan. Getting the Module propertes error. Please advise
                mark chen Newbie

                Thank you about the suggestion.

                 

                But I cannot found the infinispan-core.jar in the root of the folder to import into my project.

                I can't find the "lib" folder, too, in other distrubuted like infinispan-4.1.0.CR2-all.

                Should I import every .jar in the "modules" folder or other else?

                 

                Sorry i know this is a "noob" question, but i can't find any infomation about the structure

                of the folder in README or somewhere.

                • 5. Re: Unable to query Infinispan. Getting the Module propertes error. Please advise
                  Manik Surtani Master

                  This is weird - I just downloaded Infinispan 4.1.0.CR2-all.zip from Sourceforge and it's all there.

                   

                  http://dl.dropbox.com/u/6524335/infinispan_jar.png

                  • 6. Re: Unable to query Infinispan. Getting the Module propertes error. Please advise
                    Ananta Amalkar Newbie

                    Hi,

                     

                    I'm using infinispan as local cache mode.

                     

                    After fixing slf4j and other errors(jar specific), I came across an exception about:

                     

                    No provided Id available on this class. After looking at the soure code, I added @ProvidedId  annotation on my class ( searchable object).

                     

                    cache-config is pretty simple, since I'm creating POC with infinispan.

                     

                     

                     

                    <namedCache name="MyCache">

                     

                    <expiration lifespan="60000000" maxIdle="100000"/>

                     

                    <indexing enabled="true" indexLocalOnly="true" />

                     

                    </namedCache>

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                    @ProvidedId

                    @Indexed

                    public

                     

                     

                     

                     

                     

                     

                    class Person {

                     

                     

                     

                    private String id

                    ;

                     

                     

                     

                     

                    public

                    String getId() {

                     

                     

                    return id

                    ;

                    }

                     

                     

                    public void

                    setId(String id) {

                     

                     

                    this.id

                    = id;

                    }

                     

                     

                    private String name

                    ;

                     

                     

                    private String account

                    ;

                     

                     

                    public

                    String getName() {

                     

                     

                    return name

                    ;

                    }

                     

                     

                    public void

                    setName(String name) {

                     

                     

                    this.name

                    = name;

                    }

                     

                     

                    public

                    String getAccount() {

                     

                     

                    return account

                    ;

                    }

                     

                     

                    public void

                    setAccount(String account) {

                     

                     

                    this.account

                    = account;

                    }

                     

                     

                     

                     

                    }

                     

                    After adding Person objects to Cache, with account as a Key, Itried to query the cache based on name.

                     

                    QueryHelper qh = new QueryHelper(c, new Properties(), Person.class);
                           
                           CacheQuery cq = null;
                           try{
                           // Create a QueryFactory.
                           QueryFactory qf = new QueryFactory(c, qh);
                        System.out.println("c ## "+((Person)c.get("abcd4999")).getName());

                         
                            cq = qf.getBasicQuery("name", "John");
                           }catch(Exception e){
                            System.out.println(" e ## "+e);
                           }

                     

                     

                     

                    Lucene Query looks like: name:john

                     

                    I can see there are objects with name as john in cache, but  cq.list() comes as null and cq.getResultSize(); comes as 0.

                     

                    Anyhelp will be highly appreciated. I'm not able to find sample code, this will help beginers. I will post my project as an example for newbees.

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                    • 7. Re: Unable to query Infinispan. Getting the Module propertes error. Please advise
                      Savin Seven Newbie

                      Try setting the  default directory provider properties to RAM Directory provider, [default it will be File Directory provider and i.e the reason for your cq.list() comes as null and cq.getResultSize(); comes as 0.]

                       

                      Below is the sample code for your reference.

                       

                      Java Client Program:

                      =================================================================

                      public class OurXmlQueryTest {

                      /**
                        * @param args
                        */
                      public static void main(String[] args) throws IOException {
                        String filePath1 = "D:\\config-query.xml";
                        EmbeddedCacheManager manager = new DefaultCacheManager(filePath1);
                        Cache<String, Address> cache = manager.getCache("evictionCache");
                        QueryFactory qf = null;
                        Properties p = new Properties();
                        p.setProperty("hibernate.search.default.directory_provider", "org.hibernate.search.store.RAMDirectoryProvider");
                        //p.setProperty("hibernate.search.default.directory_provider", "org.hibernate.search.store.FSDirectoryProvider");
                        QueryHelper qh = new QueryHelper(cache,p,Address.class);
                        qf = new QueryFactory(cache, qh);
                       
                        //Store Values to Cache
                        for(int i=0; i<100; i++){  
                         Address address = new Address("addrONE"+i,"addrTWO"+i);
                         cache.putForExternalRead("addr"+i, address);
                        }
                        System.out.println("The val is "+cache.containsKey("addr95"));
                       
                        //Retrieve Values from Cache
                        try {
                         CacheQuery cq = qf.getBasicQuery("addr1", "addrONE99");
                         System.out.println("CQ Size :"+cq.getResultSize());
                         List<Object> list = cq.list();
                         System.out.println("list size :"+list.size());
                         Iterator<Object> itr =list.iterator();
                         while(itr.hasNext()) {
                          Address addr = (Address)itr.next();
                          System.out.println("Address :"+addr.toString());  
                         }  
                        }
                        catch(Exception e) {
                         System.out.println("Exception in retrieve Values :"+e.toString());
                        }
                      }

                      }

                      ==============================================================

                       

                      Address.java

                       

                      @ProvidedId
                      @Indexed(index = "address")
                      public class Address implements Serializable{

                      /**
                        *
                        */
                      private static final long serialVersionUID = 1L;

                      @Field(store = Store.YES)
                      private String addr1;
                      @Field(store = Store.YES)
                      private String addr2;

                      public Address(String addr1,String addr2) {
                        super();
                        this.addr1 = addr1;
                        this.addr2 = addr2; 
                      }

                      public String getAddr1() {
                        return addr1;
                      }
                      public void setAddr1(String addr1) {
                        this.addr1 = addr1;
                      }
                      public String getAddr2() {
                        return addr2;
                      }
                      public void setAddr2(String addr2) {
                        this.addr2 = addr2;
                      }

                      public String toString() {
                        return "{Address: "
                          +"Addr1 :"+getAddr1()
                          +" / "
                          +"Addr2 :"+getAddr2()
                          +" }";
                      }

                      }

                      =========================================================

                       

                      config-query.xml

                       

                      <?xml version="1.0" encoding="UTF-8"?>

                      <infinispan

                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                      xsi:schemaLocation="urn:infinispan:config:4.0 http://www.infinispan.org/schemas/infinispan-config-4.0.xsd"

                      xmlns="urn:infinispan:config:4.0">

                       

                      <namedCache name="evictionCache">

                      <indexing enabled="true" indexLocalOnly="true" />

                      <eviction wakeUpInterval="500" maxEntries="500" strategy="FIFO" />

                      <expiration lifespan="60000" maxIdle="1000"/>

                      </namedCache>

                       

                      </infinispan>

                       

                      Please check and revert back, Hopefully it should work .. If you have sample programs that uses lucene query, kindly post that as well...

                      • 8. Re: Unable to query Infinispan. Getting the Module propertes error. Please advise
                        Savin Seven Newbie

                        And also in your Person.class, I think you have missed the annotation "@Field(store = Store.YES)" before your field\attributes.
                        That might also be the reason, It couldn't able to store the field values.

                         

                        Please add something below, in your person class as well..

                         

                        import org.hibernate.search.annotations.Field;
                        import org.hibernate.search.annotations.Indexed;
                        import org.hibernate.search.annotations.ProvidedId;
                        import org.hibernate.search.annotations.Store;


                        @Field(store = Store.YES)
                        private String id;
                        @Field(store = Store.YES)
                        private String name;

                         

                        It will resolve your issue.

                         

                        If you have sample program that uses lucene queries. Kindly try to post the full programs. So that it will be elaborate and easy to understand for others.

                         

                        I really wonder, Why generally people are very conservative in pasting their codes.. The forum is basically to understand each other problems and solving it. So there is nothing wrong in bit elaborating when answering.. Its a request to all who are using not only to this forum, to any technical forums.... [Its just a genereal thought.. ]

                         

                        Thanks

                        Savin

                        • 9. Re: Unable to query Infinispan. Getting the Module propertes error. Please advise
                          AJ Joy Newbie

                          Savin

                          I am hitting the same issue as above. (java.lang.IllegalArgumentException: There is no provided id). I am on 4.1.0-Final. I have indexing enabled programatically. Any inputs

                           

                          java.lang.IllegalArgumentException: There is no provided id on com.abc.Person class
                          at org.infinispan.query.backend.QueryHelper.validateClasses(QueryHelper.java:205)
                          at org.infinispan.query.backend.QueryHelper.<init>(QueryHelper.java:94)
                          at com.bladelogic.om.infra.cache.query.BlQueryHelper.<init>(BlQueryHelper.java:25)
                          at com.bladelogic.om.infra.cache.TestBlCache.testBlCache(TestBlCache.java:24)
                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                          at java.lang.reflect.Method.invoke(Unknown Source)

                           

                          =============

                          EmbeddedCacheManager manager = new DefaultCacheManager();

                           

                          Configuration configuration =

                          new Configuration();

                          configuration.setIndexingEnabled(

                          true);

                          configuration.setIndexLocalOnly(

                          true);

                          manager.defineConfiguration("mycache", configuration);

                          _cache

                           

                           

                           

                          = manager.getCache("mycache");

                          QueryHelper helper = new QueryHelper(cache, new properties, Person.class)

                          ===============

                           

                          public

                           

                          class Person implements Serializable{

                           

                           

                          private static final long serialVersionUID = -5799727130742626731L;

                           

                           

                          int age;

                          String

                          name;

                           

                           

                          public int getAge() {

                           

                          return age;

                          }

                           

                           

                          public void setAge(int age) {

                           

                          this.age = age;

                          }

                           

                           

                          public String getName() {

                           

                          return name;

                          }

                           

                           

                          public void setName(String name) {

                           

                          this.name = name;

                          }

                           

                          Person(

                          int age, String name)

                          {

                           

                          this.age = age;

                           

                          this.name = name;

                           

                          }

                           

                           

                          }

                          at junit.framework.TestCase.runTest(TestCase.java:168)
                          at junit.framework.TestCase.runBare(TestCase.java:134)
                          at junit.framework.TestResult$1.protect(TestResult.java:110)
                          at junit.framework.TestResult.runProtected(TestResult.java:128)

                          • 10. Re: Unable to query Infinispan. Getting the Module propertes error. Please advise
                            AJ Joy Newbie

                            Another question, do I have to use the hiberbate annotation on my searchable class, for the query to work like the @providerId annotation etc. Thanks

                            AJ

                            • 11. Re: Unable to query Infinispan. Getting the Module propertes error. Please advise
                              Navin Surtani Newbie

                              Hi AJ,

                               

                              If you look at  http://community.jboss.org/wiki/JBossCacheSearchable which explains which annotations need to be put on your class. Sure, it's regarding JBoss Cache and not Infinispan but you need the same annotations on the class that you intend to index.

                               

                              Now your exception is being thrown because @ProvidedId has not been put on your class. I don't know if in your example you have removed your annotations or if they haven't got copied in. Either way, you have to, have to annotate your classes with those provided in the link above.

                               

                              Once the Query API has been finalised for Infinispan we'll update the wiki for Querying Infinispan regarding the annotations as well explaining how to provide your own custom Object as a key etc.

                               

                              Thanks,

                              Navin.

                              • 12. Re: Unable to query Infinispan. Getting the Module propertes error. Please advise
                                AJ Joy Newbie

                                Thanks Navin. I got it working, the mistake I did was not instantiating the query helper before populating the cache.