7 Replies Latest reply on Dec 11, 2007 9:46 AM by dmary

    CacheLoader is not notified when a POJO is modified

    dmary

      Hi all,

      I've got a problem with JDBCCacheLoader, as when i change some datas from a POJO, these changes are not reflected on the datastore used (an mysql database)

      Here is my config :

      <?xml version="1.0" encoding="UTF-8"?>
      <server>
      
      
       <mbean code="org.jboss.cache.aop.PojoCache"
       name="jboss.cache:service=MyPojoCache">
       <depends>jboss:service=Naming</depends>
       <depends>jboss:service=TransactionManager</depends>
      
      
       <attribute name="TransactionManagerLookupClass">
       org.jboss.cache.JBossTransactionManagerLookup
       </attribute>
       <attribute name="NodeLockingScheme">OPTIMISTIC</attribute>
       <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
       <attribute name="CacheMode">LOCAL</attribute>
       <attribute name="InitialStateRetrievalTimeout">5000</attribute>
       <attribute name="SyncReplTimeout">10000</attribute>
      
       <attribute name="LockAcquisitionTimeout">15000</attribute>
      
       <attribute name="EvictionPolicyClass">org.jboss.cache.aop.eviction.AopLRUPolicy</attribute>
      
      
       <attribute name="EvictionPolicyConfig">
       <config>
       <attribute name="wakeUpIntervalSeconds">5</attribute>
       <region name="/_default_">
       <attribute name="maxNodes">5000</attribute>
       <attribute name="timeToLiveSeconds">0</attribute>
       </region>
       </config>
       </attribute>
       <attribute name="CacheLoaderConfiguration">
       <config>
       <passivation>false</passivation>
       <preload></preload>
       <shared>false</shared>
      
       <cacheloader>
       <class>org.jboss.cache.loader.JDBCCacheLoader</class>
       <properties>
       cache.jdbc.driver=com.mysql.jdbc.Driver
       cache.jdbc.url=jdbc:mysql://localhost:3306/vcall
       cache.jdbc.user=root
       cache.jdbc.password=*****
       cache.jdbc.table.drop=false
       </properties>
       <async>false</async>
       <fetchPersistentState>false</fetchPersistentState>
       <ignoreModifications>false</ignoreModifications>
       <purgeOnStartup>false</purgeOnStartup>
       </cacheloader>
       </config>
       </attribute>
       </mbean>
      
      </server>
      
      I use JBOSS AS 4.0.5GA and JBossCache 1.4.0.SP1.
      
      Any help will be appreciated.
      


        • 1. Re: CacheLoader is not notified when a POJO is modified
          dmary

          Hi,

          I've got no response so I will precise more detail :) :
          - i'm running with JBoss 4.0.5 GA
          - i've got the JbossCache 1.4.0 SP1 dist

          I've read all tutorials on JBossCache (TreeCache and PojoCache), i've read the wiki (PojoCacheAS405) and I didn't understand why any interceptor is called when I modifity one field of my POJO.

          ->
          I've got 3 POJOs : object A contains object B which also contains object C

          The object A use @InstanceOfPojoCacheable and object B and C use @PojoCacheable


          I've reached the instance of PojoCache throught a Mbean

          MBeanServer server = MBeanServerLocator.locateJBoss();
           try {
           this.cache = (PojoCacheMBean) MBeanProxyExt.create(PojoCacheMBean.class, "jboss.cache:service=MyPojoCache", server);
           this.cache.addTreeCacheListener(new MyCacheListener());
           } catch (MalformedObjectNameException e) {
           e.printStackTrace();
           }



          I put my object in cache with putobject :

          public void putMobileUnit(ObjectA item) {
           try {
           this.cache.putObject(NODE+item.getImei(), item);
           } catch (CacheException e) {
           e.printStackTrace();
           }
           }


          In one hand, reading tutorials, the annotation @InstanceOfPojoCacheable and @PojoCacheable is the only need (i've reached this point) to have AOP worked, in other hand, as it is said on wiki PojoCacheAS405, we need to specify precisly the classes needed to be instrumented/aspectized in jboss-aop.xml and choose between make a Ant script to make a compile-time instrumentation or to do a load time instrumentation.
          Why ? Instrumentation isn't done by only write annotations ?
          What aopc task really do ?

          Thanks a lot for ur responses !!

          • 2. Re: CacheLoader is not notified when a POJO is modified
            dmary

            nobody can explain to me ?

            • 3. Re: CacheLoader is not notified when a POJO is modified
              dmary

              well, I've decided to use aopc precompile time mode, it well create my EAR.
              but when I deploy my ear, now , I've got an error with a stateless EJB :

              Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: notifyObservers
               at org.jboss.aop.ClassAdvisor.attachClass(ClassAdvisor.java:312)
               at org.jboss.aop.AspectManager.initialiseClassAdvisor(AspectManager.java:590)
               at org.jboss.aop.AspectManager.getAdvisor(AspectManager.java:578)
               at com.masternaut.mastervcall.business.bean.MobileUnitBean.<clinit>(MobileUnitBean.java)
               ... 159 more
              Caused by: java.lang.NoSuchMethodException: notifyObservers
               at org.jboss.aop.ClassAdvisor.getMethod(ClassAdvisor.java:323)
               at org.jboss.aop.ClassAdvisor.getMethod(ClassAdvisor.java:331)
               at org.jboss.aop.ClassAdvisor.populateMixinMethods(ClassAdvisor.java:394)
               at org.jboss.aop.ClassAdvisor$1.run(ClassAdvisor.java:290)
               at java.security.AccessController.doPrivileged(Native Method)
               at org.jboss.aop.ClassAdvisor.attachClass(ClassAdvisor.java:271)
              


              anybody knows why I've got this error ?

              • 4. Re: CacheLoader is not notified when a POJO is modified
                dmary

                It happend only on a stateless EJB (with local and remote interface) which have on several methods signature, a POJO use by jbosscache.

                If I do not use aopc task, my project well deploy on Jboss AS

                (Ps : I put AOP 1.5.2)

                • 5. Re: CacheLoader is not notified when a POJO is modified
                  dmary

                  Nobody knows where can the problem for the exception

                  java.lang.NoSuchMethodException: notifyObservers


                  ?

                  I think it could be eventualy one library is needed ..

                  Resume of what have been done :
                  1 - annotation on POJO
                  2 - xml file for create MBean cache with cacheloader in /deploy
                  3 - use of cache in java code
                  4 - creation of jboss-aop.xml for annotation in /deploy
                  5 - creation of jboss-aop.xml for preparing POJO in meta-inf of EAR
                  6 - ant task for aopc the POJOs
                  7 - replace of AOP 1.5.1 by 1.5.2 on my Jboss 4.0.5 AS
                  8 - put library of JBossCache 1.4.1 SP3 in Jboss lib
                  9 - run and crash .. :)

                  • 6. Re: CacheLoader is not notified when a POJO is modified
                    jason.greene

                    The NoSuchMethod typically means that your code was weaved with a different AOP descriptor at compile time, then what was used at run-time. It could also mean a different version of AOP.

                    • 7. Re: CacheLoader is not notified when a POJO is modified
                      dmary

                      well, i've try to do again same deploy, with a fresh install of jboss 4.05 GA, and I found another error, and in searching into forum,
                      I found that someone have got same error
                      (see http://www.jboss.org/index.html?module=bb&op=viewtopic&t=98752&postdays=0&postorder=asc&start=10),
                      and the solution was to put into the classpath of aop task this :

                      <fileset dir="${deploy.dir}/tc5-cluster.sar">
                       <include name="tc5-cluster.aop" />
                       </fileset>
                      


                      thanks jason for the advice!