5 Replies Latest reply: May 10, 2012 1:14 PM by Scott Marlow RSS

Second level cache default persistence in as7

Julio Faerman Novice

Where is the JPA 2LC persisted by default in as7?

 

I see that even after a restart or reinstall the cache still lives, but could not find where....

  • 1. Re: Second level cache default persistence in as7
    Scott Marlow Master

    Which version of AS7 and can you show me the command line that you use to start the AS?

  • 2. Re: Second level cache default persistence in as7
    Julio Faerman Novice

    I am running 7.1.1.Final, from eclipse, standard args (below).

    I have just enabled 2LC and query log, and what i see that EntityManger.find(class,id) doesn't hit the database even after a restart.

     

     

    (vm args)

    -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true "-Dorg.jboss.boot.log.file=/home/jfaerman/dev/jboss-as7/standalone/log/boot.log" "-Dlogging.configuration=file:/home/jfaerman/dev/jboss-as7/standalone/configuration/logging.properties" "-Djboss.home.dir=/home/jfaerman/dev/jboss-as7"

     

    (program args)

    -mp "/home/jfaerman/dev/jboss-as7/modules" -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -b localhost --server-config=standalone.xml

  • 3. Re: Second level cache default persistence in as7
    Scott Marlow Master

    Have you made any modifications to the standalone.xml?  If yes, could you attach it. 

     

    From your description, it doesn't sound likely, but could it be that your using an extended persistence context with an entity that hasn't been saved to the database yet?  But instead the stateful bean instance was passivated and the entity is read from the extended persistence context after restart of the AS?

     

    An extended persistence context and its use might look like:

     

    @Stateful
    @TransactionManagement(TransactionManagementType.BEAN)
    public class ExampleBean {
    
    @PersistenceContext(type = PersistenceContextType.EXTENDED, unitName = "pu")
    EntityManager em;
    
    // The created entity will not be saved to the database until an active JTA transaction is used by this bean instance.
    public void createEntityButDoNotSaveToDBYet() {
          MyEntity myEntity = new MyEntity();
          myEntity.setId(100);
          myEntity.setName("example");
          em.persist(myEntity);
    }
    
    // retrieve the specified entity from the database or from the 'em' extended persistence context (in memory)
    public MyEntity getEntityFromDbOrFromExtendedPersistenceContext(int id) {
         return em.find(MyEntity.class, id);
    }
    
    

     

    Scott

  • 4. Re: Second level cache default persistence in as7
    Julio Faerman Novice

    Actually, i think it is something simpler.

     

    I could not reproduce the issue disconnected from the network.

    Could it be that another developer in my network has the server up and my cache is replicated there?

  • 5. Re: Second level cache default persistence in as7
    Scott Marlow Master

    I wouldn't expect any clustering to occur for the standalone profile.  Have you made any modifications to the standalone.xml (that perhaps could of enabled clustering or are infinispan related?)  If yes, could you attach it. 

     

    Also, enable TRACE logging for  org.jboss.as.jpa, org.hibernate.SQL, org.hibernate.cache.infinispan + org.infinispan (see second level cache troubleshooting notes here ).  Attach the resulting (as7/standalone/log folder) server.log if you would like help looking at it for this question. 

     

    I agree that its probably something simple but I haven't heard of others seeing this, nor could I reproduce.