5 Replies Latest reply on Sep 12, 2012 4:24 AM by ajcmartins

    Error while reading file-store after eviction while using infinispan-cdi

    ajcmartins

      Hi, i am having troubles while trying to run a small test using infinispan-cdi version 5.1.5.FINAL on JBoss AS 7.1.1. I did tried to run the quickstart and everything works ok.

       

      The error is:

      17:28:05,963 ERROR [org.infinispan.loaders.file.FileCacheStore] (http--0.0.0.0-8080-1) ISPN000062: Error while reading from file: D:\jboss\standalone\data\learning\learning-cache\1450574848: java.lang.ClassNotFoundException: org.infinispan.cdi.interceptor.DefaultCacheKey from [Module "org.jboss.as.clustering.infinispan:main" from local module loader @43f46f3b (roots: D:\jboss\modules)]

       

      On the maven POM file i have

       

             <dependency>

                 <groupId>org.infinispan</groupId>

                 <artifactId>infinispan-cdi</artifactId>

                 <version>5.1.5.FINAL</version>

             </dependency>

       

      and

            <manifestEntries>

                <Dependencies>org.infinispan</Dependencies>

            </manifestEntries>

       

       

       

      on the jboss standalone-ha.xml i have:

              <subsystem xmlns="urn:jboss:domain:infinispan:1.2" default-cache-container="learning">

                  <cache-container name="learning" default-cache="learning-cache">

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

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

                          <file-store/>

                      </local-cache>

                  </cache-container>

              </subsystem>

       

      To setup the cache on java i have:

      public class Config {

                     @Resource(lookup = "java:jboss/infinispan/container/learning")

                     @Produces

                     EmbeddedCacheManager defaultCacheManager;

      }

       

      The data being used is:

      public class User implements Serializable{

       

                private static final long serialVersionUID = -577278578670082130L;

       

                private long id;

                private String name = "abs";

       

        ...getters and setters...

      }

       

       

      and i am using interceptors on the service, like:

      @CacheResult(cacheName = "learning-cache")

                public User findUser(String id) {

       

                               User user = new User();

                               user.setName(id);

                               return user;

                }

       

      @CachePut(cacheName = "learning-cache")

                public void storeUser(String id, @CacheValue User user) {

                               Log("Stored:" + user.getName());

                }

       

       

      I have to say that everything works great until i try to insert the 4rd element. That's when i get the error presented above.

      When i open the cache file with a text editor i can see the org.infinispan.cdi.interceptor.DefaultCacheKey reference..

       

      Any help or direction will be high apreciated.

       

      Cheers,

        • 1. Re: Error while reading file-store after eviction while using infinispan-cdi
          ajcmartins

          So i was playing around and trying to do the same without interceptors:

           

          @Inject

          Cache<String, User> cache;

              

          public User findUser(String id) {

                              if (cache.containsKey(id)) {

                                        return cache.get(id);

                              } else {

                                        User user = new User();

                         user.setId(id);

                                        user.setName("asdad");

                                        cache.put(id, user);

                                        return user;

                              }

              }

           

          and the error is now:

          Caused by: java.lang.ClassNotFoundException: org.infinispan.quickstart.cdi.config.User from [Module "org.jboss.as.clustering.infinispan:main" from local module loader @64b2ad57 (roots: D:\jboss\modules)]

           

          So this is related to the class loader not finding the classes that are being marshalled to disk- maybe more of a jboss issue than infinispan?

          I have been looking into the , but shouldn't it just works with Serializable as well?

          I was also thinking about the storeAsBinary property, but, being a local cache i don't think it would do any good.

           

          Any idea?

          • 2. Re: Error while reading file-store after eviction while using infinispan-cdi
            pmuir

            What's the whole stack trace?

            • 3. Re: Error while reading file-store after eviction while using infinispan-cdi
              ajcmartins

              Hey Pete, thanks for looking.. Well at some point i just gave up using the configurations on the standalone.xml. Tried to load the configuration from a xml file instead and everything started working just fine.

              If you think it can be usefull i can create a new project with the same settings to provide you with the stack trace, but i am pretty happy with it just working at the moment...

               

              Cheers,

              • 4. Re: Error while reading file-store after eviction while using infinispan-cdi
                pferraro

                AS7 doesn't include the infinispan-cdi module by default.  To use this with AS7, you'll need to add the infinispan-cdi jar to the org.infinispan module.

                1. Copy the infinispan-cdi jar to $JBOSS_HOME/modules/org/infinispan/main
                2. Edit $JBOSS_HOME/modules/org/infinispan/main/modules.xml and add the missing <resources-root path="..."/> element.
                • 5. Re: Error while reading file-store after eviction while using infinispan-cdi
                  ajcmartins

                  Hey Paul, i remembered about that and in fact tried to provide JBoss with the module, although incorrectly it seems :/

                   

                  Thank you.