3 Replies Latest reply on Nov 13, 2009 7:05 AM by Ivan Li

    Seam cache provider with ehcache null

    Cateno Viglio Newbie

      Hi every one,

      I'm trying to configure seam/ehcache following the tutorial from jboss page:


      I put the ehcache.1.2.3.jar in project.ear/lib and injected CacheProvider as especified, but the CacheProvider always return null. The documentation doesn't show any aditional configuration for ehcache, just for jboss cache.

      I am probably doing something wrong, it's impossible be so easy :).

      besides put the jar in /lib, i created the following seam component to test:

      public class CacheSeamBean implements java.io.Serializable {
       @In(required=false, create=true) 
       private EntityManager em;
       private Log log;
       private Events events;
       @In CacheProvider cacheProvider;
       Boolean blLoaded = Boolean.FALSE;
       public void buscar() {
        if (!blLoaded){
         List<Parametro> lstParametro = em.createQuery("select p from Parametro p").getResultList();
         for (Parametro parametro : lstParametro){
          cacheProvider.put(parametro.getCodigo(), parametro.getValor());
         blLoaded= Boolean.TRUE;


        • 1. Re: Seam cache provider with ehcache null
          Christian Bauer Master

          It's not that easy, the JBoss Cache provider is hardcoded last time I checked. This website (/examples/wiki) uses EHCache though and you can look at the code to see how that was done.

          Be aware that it's also using the same EHCache instance (with different regions) for Hibernate second-level data caching and HTML page fragment caching. That particular setup depends on the deployment order of persistence unit and Seam, which changed in JBoss 5.x. In other words: If you want to also use EHCache for both and copy the setup 1:1 from the example code, use JBoss 4.2.x.

          • 2. Re: Seam cache provider with ehcache null
            Christian Bauer Master

            Oh, and it looks like what you are trying to do in your code example is not a good idea and you probably don't know much about data caching in Hibernate. Read up on that first before you do anything else.

            • 3. Re: Seam cache provider with ehcache null
              Ivan Li Newbie
                                  "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
                          http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.1.xsd
                          http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
                          http://jboss.com/products/seam/navigation http://jboss.com/products/seam/navigation-2.0.xsd
                          http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
                          http://jboss.com/products/seam/framework http://jboss.com/products/seam/framework-2.0.xsd
                          http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd
                          http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.1.xsd
                          http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.1.xsd">

              I add the <cache:eh-cache-provider> in components.xml, and put ehcache.jar into lib dir, the  it works