7 Replies Latest reply on Feb 7, 2009 5:08 PM by haky

    PojoCache doesn't work with Seam 2.1.0CR1

    tazman

      After moving my application on Seam 2.1.0CR1, I'm unable to get my cached objects from the cache.


      This is what I have in my components.xml:


      <cache:jboss-pojo-cache-provider />




      This is how I inject the cache in my classes, which works:


      @In CacheProvider<PojoCache> cacheProvider;




      A put always works:


      cacheProvider.put("app", "userList", userList);




      However, get returns always null objects:


      Set<User> userList = (Set<User>) cacheProvider.get("app", "userList");




      I have my cache jars in the EAR/lib directory (jboss-cache.jar and jgroups.jar).


      The debugger shows that the cache keeps the objects after the put. So they are not null. Any help would be appreciated.


      Tom

        • 1. Re: PojoCache doesn't work with Seam 2.1.0CR1
          pmuir

          read the migration guide.

          • 2. Re: PojoCache doesn't work with Seam 2.1.0CR1
            tazman

            I'm copying from the seam21migration.txt:



            The use <s:cache /> is unchanged, but you can no longer inject the pojoCache
            component. Instead you should configure JBoss POJO cache as your cache provider 
            in components.xml:
            
            <cache:jboss-pojo-cache-provider />
            
            and inject it using
            
            @In CacheProvider<PojoCache> cacheProvider;
            
            The CacheProvider provides a Map like interface, and the getDelegate() method
            can be used to retrieve the underling cache.




            I followed the migration guide while moving on Seam 2.1.0CR1. What am I doing wrong?


            Tom

            • 3. Re: PojoCache doesn't work with Seam 2.1.0CR1
              pmuir

              Sorry, I was half asleep last night. If you can provide an example to reproduce and open a JIRA issue, we can take a look.

              • 4. Re: PojoCache doesn't work with Seam 2.1.0CR1
                tazman

                Pete, I didn't open a JIRA issue because the following works:



                Set<User> userList = (Set<User>) cacheProvider.getDelegate().get("app", "userList");




                Tom

                • 5. Re: PojoCache doesn't work with Seam 2.1.0CR1
                  pmuir

                  Please still file an issue - obviously doing it through the Seam interface should work!

                  • 6. Re: PojoCache doesn't work with Seam 2.1.0CR1
                    troy.sellers

                    Did this get listed as a bug?
                    I have posted with the same problem using SEAM 2.1.1.GA.


                    Couldn't find this in JIRA.

                    • 7. Re: PojoCache doesn't work with Seam 2.1.0CR1
                      haky
                      Hi,

                      I think JbossPojoCacheProvider get method implementation is wrong. Region parameter ignored and return Node instance :

                      public Object get(String region, String key)
                         {
                            try
                            {
                               return cache.get(getFqn(key));
                            }
                            catch (CacheException e)
                            {
                               throw new IllegalStateException(String.format("Cache throw exception when trying to get %s from region %s.", key, region), e);
                            }
                         }

                      It shoul be like JbossCacheProvider get method :

                      public Object get(String region, String key)
                         {
                            try
                            {
                               Node node = cache.get(getFqn(region));
                               if (node != null)
                               {
                                  return node.get(key);
                               }
                               else
                               {
                                  return null;
                               }
                            }
                            catch (CacheException e)
                            {
                               throw new IllegalStateException(String.format("Cache throw exception when trying to get %s from region %s.", key, region), e);
                            }
                         }

                      I'll also open a jira issue