5 Replies Latest reply on Apr 29, 2008 11:18 AM by Jason Greene

    attach()detach() can transaction,but find() can not?

    w j Newbie

      hi all,
      when i use as the follow ,i can rollback the cache:

       clientDao.insertClient(client);
       Client clientCache = clientDao
       .getClientByName(client.getName());
       //insertClientToCache use pojocache.attach(id,client)
       cacheManager.insertClientToCache(clientCache);
       throw new RuntimeException();
      

      or
       clientDao.deleteClientByTid(tid);
       //deleteClientByTid use pojocache.detach(id)
       cacheManager.deleteClientByTid(tid);
       throw new RuntimeException();
      

      they work fine, but when i use pojocache.find(...) to get a pojo,then i modified the name field, it can't rollback,
       clientDao.updateClient(client);
       Client cInCache = cacheManager
       .getClientFromCacheByTid(client.getTid());
       cInCache.setName(client.getName());
       throw new RuntimeException();
      

      when the up is done,clientDao.updateClient rollbacked,but the client in cache ,it's Name field not rollback,

      how can i now to do?Any advice would great appreciate!

        • 1. Re: attach()detach() can transaction,but find() can not?
          w j Newbie

          i've placed jboss-aop.jar to my web/WEB-INF/lib,and copyed one pojocache-aop.xml(from jbosscache-pojo.jar/METE-INF/) to web/WEB-INF/classes,

          • 2. Re: attach()detach() can transaction,but find() can not?
            w j Newbie

            i've read the userguide doc,
            from the Chapter6.Instrumentation , i don't know how i do the below in a web application server, e.g.; tomcat

            The jboss.aop.path system property set to the location of pojocache-aop.xml
            
            A javaagent argument which includes jboss-aop-jdk50.jar
            
            These requirements lead to the following example ant task:
            
            
            <java classname="Foo" fork="yes">
             <jvmarg value="-javaagent:lib/jboss-aop.jar"/>
             <jvmarg value="-Djboss.aop.path=etc/META-INF/pojocache-aop.xml"/>
             <classpath refid="test.classpath"/>
            </java>
            
            There is also a pojo-run command line script in the POJO Cache distribution that passes the proper arguments to the JVM for you.
            
            
            $ pojo-run -classpath myclasses org.foo.Bar
            
            Once the JVM is executed in this manner, any class with the @Replicable annotation will be instrumented when it is loaded.
            


            then in 5.3.AOP Configuration
            POJO Cache supplies a pojocache-aop.xml that is required to be set via a system property: jboss.aop.path during compile- or load-time, or placed in the user's classpath. The file now consists of the interceptor stack specification, as well as annotations for POJO instrumentation. It is listed fully in the Appendix section. Note that the file should not normally need to be modified. Only an advanced use-case would require changes.
            


            so, in web server ,if i placed jbosscache-aop.jar(and other requied jar) to WEB-INF/lib and pojocache-aop.xml to WEB-INF/classes, then pojocache can work fine?
            i've done this,but ,use find() to get a object from cache,i can't rollback the field,
            Have i forgot something important?

            • 3. Re: attach()detach() can transaction,but find() can not?
              Jason Greene Master

              If you are using load-time weaving with tomcat, the JVM arguments still have to be set. You do this by editing the tomcat startup script for your platform.

              • 4. Re: attach()detach() can transaction,but find() can not?
                w j Newbie

                Greet!Thank you very much, jason!
                I've got the correct i want~

                There is a little matter, when i do the below in tomcat#catalina.bat:
                set JAVA_OPTS=-Xms512m -Xmx512m -javaagent:E:/JAVA/workspace/web/ROOT/WEB-INF/lib/jboss-aop-jdk50.jar -Djboss.aop.path="E:/JAVA/workspace/web/ROOT/WEB-INF/pojocache-aop.xml"

                I found when tomcat startup,it required jboss-common-core.jar and other jars , i have to place these jars into my jdk/jre/lib/ext directory, is this i done correct?whether or not have some more effective way?

                thks again!

                • 5. Re: attach()detach() can transaction,but find() can not?
                  Jason Greene Master

                   

                  "wj.king" wrote:

                  I found when tomcat startup,it required jboss-common-core.jar and other jars , i have to place these jars into my jdk/jre/lib/ext directory, is this i done correct?whether or not have some more effective way?
                  thks again!


                  They just need to be on the tomcat classpath, which you can edit. You probably don't want to make them a permanent part of your jvm.