12 Replies Latest reply on May 4, 2009 11:05 PM by tongzhao

    Can't get PojoCache annotations to work on JBoss AS5

    gerbrand

      Hello,

      For the past two days I've spent (wasted) a lot of time to get the PojoCache working on JBoss AS 5.

      I've added the PojoCache libraries to my JBoss server\all\lib directory and added a pojocache-service.xml . I could successfully retrieve the PojoCache.

      No I want to the 'Replicable' annotation working. After some time I figured out AOP needs to be enabled.

      I 've changed the aop.xml in my conf\bootstrap\ directory: enableLoadtimeWeaving=true


      However now when I start JBoss I get the following error. I really don't have a clue why this happens and I'm a little bit frustated, so I hope someone can help.

      Below is the error I get while starting up JBoss:


      14:55:42,359 ERROR [AbstractKernelController] Error installing to Create: name=A
      spectManager state=Configured
      java.lang.NoClassDefFoundError: org/jboss/aop/standalone/PluggableInstrumentor
      at org.jboss.aop.asintegration.core.AspectManagerServiceDelegateJDK5.att
      achTranslator(AspectManagerServiceDelegateJDK5.java:42)
      at org.jboss.aop.asintegration.core.AspectManagerServiceDelegate.create(
      AspectManagerServiceDelegate.java:252)
      at org.jboss.aop.deployers.AbstractAspectManager.create(AbstractAspectMa
      nager.java:89)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(Reflec
      tionUtils.java:59)
      at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(
      ReflectMethodInfoImpl.java:150)
      at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethod
      JoinPoint.java:66)
      at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$Joi
      npointDispatchWrapper.execute(KernelControllerContextAction.java:241)
      at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(Executio
      nWrapper.java:47)
      at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dis
      patchExecutionWrapper(KernelControllerContextAction.java:109)
      at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dis
      patchJoinPoint(KernelControllerContextAction.java:70)
      at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInte
      rnal(LifecycleAction.java:221)
      at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction
      (InstallsAwareAction.java:54)
      at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction
      (InstallsAwareAction.java:42)
      at org.jboss.dependency.plugins.action.SimpleControllerContextAction.sim
      pleInstallAction(SimpleControllerContextAction.java:62)
      at org.jboss.dependency.plugins.action.AccessControllerContextAction.ins
      tall(AccessControllerContextAction.java:71)
      at org.jboss.dependency.plugins.AbstractControllerContextActions.install
      (AbstractControllerContextActions.java:51)
      at org.jboss.dependency.plugins.AbstractControllerContext.install(Abstra
      ctControllerContext.java:348)
      at org.jboss.dependency.plugins.AbstractController.install(AbstractContr
      oller.java:1598)
      at org.jboss.dependency.plugins.AbstractController.incrementState(Abstra
      ctController.java:934)
      at org.jboss.dependency.plugins.AbstractController.resolveContexts(Abstr
      actController.java:1062)
      at org.jboss.dependency.plugins.AbstractController.resolveContexts(Abstr
      actController.java:984)
      at org.jboss.dependency.plugins.AbstractController.install(AbstractContr
      oller.java:774)
      at org.jboss.dependency.plugins.AbstractController.install(AbstractContr
      oller.java:540)
      at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean
      (AbstractKernelDeployer.java:331)
      at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean
      s(AbstractKernelDeployer.java:309)
      at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deploy(Abs
      tractKernelDeployer.java:130)
      at org.jboss.kernel.plugins.deployment.BasicKernelDeployer.deploy(BasicK
      ernelDeployer.java:76)
      at org.jboss.bootstrap.microcontainer.TempBasicXMLDeployer.deploy(TempBa
      sicXMLDeployer.java:91)
      at org.jboss.bootstrap.microcontainer.TempBasicXMLDeployer.deploy(TempBa
      sicXMLDeployer.java:161)
      at org.jboss.bootstrap.microcontainer.ServerImpl.doStart(ServerImpl.java
      :144)
      at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:
      394)
      at org.jboss.Main.boot(Main.java:209)
      at org.jboss.Main$1.run(Main.java:547)
      at java.lang.Thread.run(Thread.java:595)

        • 1. Re: Can't get PojoCache annotations to work on JBoss AS5

          Gerbrand

          You should be added -javaagent switch on JAVA_OPTS in run.sh like this :
          set JAVA_OPTS=-Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dsun.lang.ClassLoader.allowArraySyntax=true -Djboss.platform.mbeanserver -javaagent:deployers/jboss-aop-jboss5.deployer/pluggable-instrumentor.jar

          • 2. Re: Can't get PojoCache annotations to work on JBoss AS5
            gerbrand

            Thanks the reply to my slightly not to nice-written posting! For the moment I've used the Serializable objects - working on something else already. I'll try it out asap.

            • 3. Re: Can't get PojoCache annotations to work on JBoss AS5

               

              "gerbrand" wrote:
              Thanks the reply to my slightly not to nice-written posting! For the moment I've used the Serializable objects - working on something else already. I'll try it out asap.



              congratulate you,, i spend two days for the aop run too .
              now the application is normal start up .
              but how i retrive the pojocache . pls help me.

              i retrive the pojochache as follow
              
              JMXServiceURL url = new JMXServiceURL(
               "service:jmx:rmi://127.0.0.1/jndi/rmi://127.0.0.1:1090/jmxconnector");
               JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
               MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
               ObjectName mbeanName = ObjectName.getInstance("jboss.cache:service=PojoCache");
               // 得到proxy代��直接调用的方�
               PojoCacheJmxWrapperMBean cache = (PojoCacheJmxWrapperMBean)MBeanServerInvocationHandler.newProxyInstance(mbsc, mbeanName,PojoCacheJmxWrapperMBean.class, false);
              
               PojoCache cache2 = cache.getPojoCache();
              
              
              



              but unfortunate i get the error

              
              
              Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
               java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.jboss.cache.pojo.impl.PojoCacheImpl
               at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:157)
               at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
               at javax.management.remote.rmi.RMIConnectionImpl_Stub.getAttribute(Unknown Source)
               at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.getAttribute(RMIConnector.java:857)
               at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:175)
               ... 2 more
              Caused by: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.jboss.cache.pojo.impl.PojoCacheImpl
               at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1309)
               at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
               at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:290)
               at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:139)
               ... 6 more
              Caused by: java.io.NotSerializableException: org.jboss.cache.pojo.impl.PojoCacheImpl
               at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
               at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
               at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:258)
               at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:304)
               at sun.rmi.transport.Transport$1.run(Transport.java:153)
               at java.security.AccessController.doPrivileged(Native Method)
               at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
               at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
               at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
               at java.lang.Thread.run(Thread.java:595)
              
              


              • 4. Re: Can't get PojoCache annotations to work on JBoss AS5
                gerbrand

                Somehow JBoss tries to Serialize the PojoCacheImpl class.

                Caused by: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.jbo
                ss.cache.pojo.impl.PojoCacheImpl


                Do you have a reference to the PojoCache inside the java classes you try to put into the cache? Maybe that's the problem, the class that implements Serializable shouldn't use classes that are not Serializble.
                Best to keep the class reletively simple, by using primive types and types such as Date, BigInteger, String inside the class.

                • 5. Re: Can't get PojoCache annotations to work on JBoss AS5

                   

                  "gerbrand" wrote:
                  Somehow JBoss tries to Serialize the PojoCacheImpl class.

                  Caused by: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.jbo
                  ss.cache.pojo.impl.PojoCacheImpl


                  Do you have a reference to the PojoCache inside the java classes you try to put into the cache? Maybe that's the problem, the class that implements Serializable shouldn't use classes that are not Serializble.
                  Best to keep the class reletively simple, by using primive types and types such as Date, BigInteger, String inside the class.


                  you can look my code upon . i only want to get pojocache from mbean service. when run to

                  MXServiceURL url = new JMXServiceURL(
                   "service:jmx:rmi://127.0.0.1/jndi/rmi://127.0.0.1:1090/jmxconnector");
                   JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
                   MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
                   ObjectName mbeanName = ObjectName.getInstance("jboss.cache:service=PojoCache");
                  
                   PojoCacheJmxWrapperMBean cache = (PojoCacheJmxWrapperMBean)MBeanServerInvocationHandler.newProxyInstance(mbsc, mbeanName,PojoCacheJmxWrapperMBean.class, false);
                  
                   PojoCache cache2 = cache.getPojoCache();

                  throw the error .

                  • 6. Re: Can't get PojoCache annotations to work on JBoss AS5

                    in jboss as 5 ,
                    the manner to get mbeanserver as follows can't use .

                    MBeanServerLocator.getMBeanServer
                    


                    is there other method get the mbean server in the same jvm


                    • 7. Re: Can't get PojoCache annotations to work on JBoss AS5
                      gerbrand

                       

                      "tongzhao" wrote:
                      in jboss as 5 ,
                      the manner to get mbeanserver as follows can't use .

                      MBeanServerLocator.getMBeanServer

                      is there other method get the mbean server in the same jvm


                      The PojoCache I retrieve using the following code:

                       PojoCache cache= getCacheManager().getPojoCache("jboss.cache:service=EJB3SFSBClusteredCache", true);
                       synchronized (this.getClass()) {
                       if (!pojoCacheStarted) {
                       cache.start();
                       pojoCacheStarted=true;
                       }
                       }
                      
                      


                      Using that code I retrieve a standard configured pojocache. The EJB cluster cache. That Cache is used by JBoss for clustered EJB's, I use the cache for my own purpose.

                      You can configure you're own cache too, by creating a PojoCache.xml file, and placing the file in the deploy directory or in your ear.

                      I've created weblog entry on this subject, see:
                      http://www.gerbrand-ict.nl/2009/03/lessons-learnt-using-jboss-500ga-clustering/

                      Considering the hits I get, I'm considering writing a proper tutorial on Clustering.

                      • 8. Re: Can't get PojoCache annotations to work on JBoss AS5

                        i have the pojocache-service.xml in my web-inf.
                        and start normal.

                        but why the error say PojoCacheImpl not serialize.

                        • 9. Re: Can't get PojoCache annotations to work on JBoss AS5
                          gerbrand

                           

                          "tongzhao" wrote:
                          i have the pojocache-service.xml in my web-inf.
                          and start normal.

                          but why the error say PojoCacheImpl not serialize.


                          Not certain if the web-inf is the right location. Eitherway, if you use the pojocache-service.xml, you don't need the mbean server anymore.
                          That code is only needed if you don't use the xml file, and want to programmatically register the pojocache.

                          • 10. Re: Can't get PojoCache annotations to work on JBoss AS5

                            this is my service.xml

                             <mbean code="org.jboss.cache.pojo.jmx.PojoCacheJmxWrapper"
                             name="jboss.cache:service=PojoCache">
                            
                             <depends>jboss:service=Naming</depends>
                             <depends>jboss:service=TransactionManager</depends>
                            
                             <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.JBossTransactionManagerLookup
                             </attribute>
                            
                             <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
                            
                             <attribute name="CacheMode">REPL_SYNC</attribute>
                            
                             <attribute name="UseReplQueue">false</attribute>
                            
                             <attribute name="ReplQueueInterval">0</attribute>
                            
                             <attribute name="ReplQueueMaxElements">0</attribute>
                            
                             <attribute name="ClusterName">JBossCache-Cluster</attribute>
                            
                             <attribute name="ClusterConfig">
                             <config>
                             <UDP mcast_addr="228.10.10.10"
                             mcast_port="45588"
                             tos="8"
                             ucast_recv_buf_size="20000000"
                             ucast_send_buf_size="640000"
                             mcast_recv_buf_size="25000000"
                             mcast_send_buf_size="640000"
                             loopback="false"
                             discard_incompatible_packets="true"
                             max_bundle_size="64000"
                             max_bundle_timeout="30"
                             use_incoming_packet_handler="true"
                             ip_ttl="2"
                             enable_bundling="false"
                             enable_diagnostics="true"
                            
                             use_concurrent_stack="true"
                            
                             thread_naming_pattern="pl"
                            
                             thread_pool.enabled="true"
                             thread_pool.min_threads="1"
                             thread_pool.max_threads="25"
                             thread_pool.keep_alive_time="30000"
                             thread_pool.queue_enabled="true"
                             thread_pool.queue_max_size="10"
                             thread_pool.rejection_policy="Run"
                            
                             oob_thread_pool.enabled="true"
                             oob_thread_pool.min_threads="1"
                             oob_thread_pool.max_threads="4"
                             oob_thread_pool.keep_alive_time="10000"
                             oob_thread_pool.queue_enabled="true"
                             oob_thread_pool.queue_max_size="10"
                             oob_thread_pool.rejection_policy="Run"/>
                            
                             <PING timeout="2000" num_initial_members="3"/>
                             <MERGE2 max_interval="30000" min_interval="10000"/>
                             <FD_SOCK/>
                             <FD timeout="10000" max_tries="5" shun="true"/>
                             <VERIFY_SUSPECT timeout="1500"/>
                             <pbcast.NAKACK max_xmit_size="60000"
                             use_mcast_xmit="false" gc_lag="0"
                             retransmit_timeout="300,600,1200,2400,4800"
                             discard_delivered_msgs="true"/>
                             <UNICAST timeout="300,600,1200,2400,3600"/>
                             <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
                             max_bytes="400000"/>
                             <pbcast.GMS print_local_addr="true" join_timeout="5000"
                             join_retry_timeout="2000" shun="false"
                             view_bundling="true" view_ack_collection_timeout="5000"/>
                             <FRAG2 frag_size="60000"/>
                             <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
                             <!-- <pbcast.STATE_TRANSFER/> -->
                             <pbcast.FLUSH timeout="0"/>
                             </config>
                             </attribute>
                            
                             <attribute name="FetchInMemoryState">true</attribute>
                            
                             <attribute name="StateRetrievalTimeout">15000</attribute>
                            
                             <attribute name="SyncReplTimeout">15000</attribute>
                            
                             <attribute name="LockAcquisitionTimeout">10000</attribute>
                            
                             <attribute name="UseRegionBasedMarshalling">true</attribute>
                             </mbean>
                            
                            


                            because i want to support cluster and stable. so i have my own service.xml

                            • 11. Re: Can't get PojoCache annotations to work on JBoss AS5

                              if stalbe. must usr jta .and jta is bundle with jboss as .

                              • 12. Re: Can't get PojoCache annotations to work on JBoss AS5

                                i can run normal pojocache2.0.0 and jboss 4.2.3.


                                client code must be

                                MBeanServer server = MBeanServerLocator.locateJBoss();
                                 ObjectName on = new ObjectName("jboss.cache:service=PojoCache");
                                
                                 PojoCache cache = PojoCacheFactory.createCache("replSync-service.xml", false);
                                 PojoCacheJmxWrapperMBean wrapper = new PojoCacheJmxWrapper(cache);
                                
                                 server.registerMBean(wrapper, on);
                                 wrapper.create();
                                 wrapper.start();
                                
                                 PojoCache cache_ = wrapper.getPojoCache();