1 2 Previous Next 17 Replies Latest reply on Nov 28, 2004 6:04 PM by Dimitris Andreadis

    Persistance service problems.

    infectedrhythms Novice

      I read the wiki it seems I have implemented evrything ok...

      1- When I wrap my Mbean as an XMBean it seems that I loose my Mbeans operations... The JMX console does not see the operations...
      2- It doesnt seem to persist.

      Am using JBoss 4.0.0

      here is my XML configurations and code...

      My Mbeans jboss-service.xml...

      <?xml version="1.0" encoding="UTF-8"?>
      
      <server>
       <mbean code="org.package.TestService" name="package.org:service=TestService" xmbean-dd="">
       <xmbean>
       <description>PersistentServiceExample</description>
       <descriptors>
       <persistence persistPolicy="OnUpdate" persistName="PersistentServiceExample"/>
       <persistence-manager value="org.jboss.mx.persistence.DelegatingPersistenceManager"/>
      
       </descriptors>
       <class>org.jboss.jmx.examples.persistence.PersistentServiceExample</class>
      
       <attribute access="read-write" getMethod="getParam" setMethod="setParam">
       <name>Param</name>
       <type>java.lang.String</type>
       <value>Hello World</value>
       </attribute>
       </xmbean>
       </mbean>
      </server>
      


      jboss-service.xml persistance config...
       <!-- ==================================================================== -->
       <!-- XMBean Persistence -->
       <!-- ==================================================================== -->
       <mbean code="org.jboss.system.pm.AttributePersistenceService"
       name="jboss:service=AttributePersistenceService"
       xmbean-dd="resource:xmdesc/AttributePersistenceService-xmbean.xml">
       <!-- the AttributePersistenceService is persistent, itself -->
      
       <!--
       <attribute name="AttributePersistenceManagerClass">org.jboss.system.pm.XMLAttributePersistenceManager</attribute>
       <attribute name="AttributePersistenceManagerConfig">
       <data-directory>data/xmbean-attrs</data-directory>
       </attribute>
       <attribute name="ApmDestroyOnServiceStop">false</attribute>
       <attribute name="VersionTag"></attribute>
       -->
       </mbean>
      


      Mbean java file...
      package org.package;
      
      import org.jboss.system.ServiceMBeanSupport;
      
      public class TestService extends ServiceMBeanSupport implements
       TestServiceMBean
      {
       String param = "Not initialized.";
      
       public void setParam(String param)
       {
       this.param = param;
       }
      
       public String getParam()
       {
       return(param);
       }
      
       public void printParam()
       {
       log.info("Param value: " + param);
       }
      
       protected void startService() throws Exception
       {
       log.info("Starting service...");
       }
      
       protected void stopService() throws Exception
       {
       log.info("Stopping service...");
       }
      }
      
      


        • 1. Re: Persistance service problems.
          Dimitris Andreadis Master

          You need also to specify your operations in the xmbean descriptor, i.e. the printParam() and (since you extend ServiceMBeanSupport) the lifecycle method create()/start()/stop()/destroy() and the 3 attributes Name/State/StateString.

          You can use the following convenience xml entities: (for an example see
          the following descriptor conf/xmdesc/ClientUserTransaction-xmbean.xml)

           &defaultAttributes;
           ...
           &defaultOperations;
          
          


          If this doesn't work, then just replace with:

          <operation>
           <description>Standard MBean lifecycle method</description>
           <name>create</name>
          </operation>
          <operation>
           <description>The start lifecycle operation</description>
           <name>start</name>
          </operation>
          <operation>
           <description>The stop lifecycle operation</description>
           <name>stop</name>
          </operation>
          <operation>
           <description>The destroy lifecycle operation</description>
           <name>destroy</name>
          </operation>
          <operation>
           <description>The detyped lifecycle operation (for internal use only)</description>
           <name>jbossInternalLifecycle</name>
           <parameter>
           <description>The lifecycle operation</description>
           <name>method</name>
           <type>java.lang.String</type>
           </parameter>
           <return-type>void</return-type>
          </operation>
          
          and
          
          <attribute access="read-only" getMethod="getName">
           <description>The class name of the MBean</description>
           <name>Name</name>
           <type>java.lang.String</type>
          </attribute>
          <attribute access="read-only" getMethod="getState">
           <description>The status of the MBean</description>
           <name>State</name>
           <type>int</type>
          </attribute>
          <attribute access="read-only" getMethod="getStateString">
           <description>The status of the MBean in text form</description>
           <name>StateString</name>
           <type>java.lang.String</type>
          </attribute>
          


          • 2. Re: Persistance service problems.
            infectedrhythms Novice

            Thanks I also managed to put the xml with my jboss-service.xml instead of the external descriptor...

            But it still doesnt seem to persist! :(

            <?xml version="1.0" encoding="UTF-8"?>
            
            <!DOCTYPE mbean PUBLIC
             "-//JBoss//DTD JBOSS XMBEAN 1.1//EN"
             "http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_1.dtd">
            
            
            <server>
             <mbean code="org.package.TestService" name="org.package:service=TestService" xmbean-dd="">
             <xmbean>
             <!-- MBean Info -->
             <description>Test Service</description>
             <descriptors>
             <persistence persistPolicy="OnUpdate" persistName="TestService.ser"/>
             <persistence-manager value="org.jboss.mx.persistence.DelegatingPersistenceManager"/>
             </descriptors>
             <class>org.package.TestService</class>
            
             <!-- Attributes -->
             <attribute access="read-write" getMethod="getParam" setMethod="setParam">
             <description>A parameter</description>
             <name>Param</name>
             <type>java.lang.String</type>
             <descriptors>
             <value value="Hello World"/>
             </descriptors>
             </attribute>
            
             &defaultOperations;
             </xmbean>
             </mbean>
            </server>
            


            and

             <mbean code="org.jboss.system.pm.AttributePersistenceService"
             name="jboss:service=AttributePersistenceService"
             xmbean-dd="resource:xmdesc/AttributePersistenceService-xmbean.xml">
             <!-- the AttributePersistenceService is persistent, itself -->
            
             <!--
             <attribute name="AttributePersistenceManagerClass">org.jboss.system.pm.XMLAttributePersistenceManager</attribute>
             <attribute name="AttributePersistenceManagerConfig">
             <data-directory>data/xmbean-attrs</data-directory>
             </attribute>
             <attribute name="ApmDestroyOnServiceStop">false</attribute>
             <attribute name="VersionTag"></attribute>
             -->
             </mbean>
            


            Thanks

            • 3. Re: Persistance service problems.
              Dimitris Andreadis Master

              Have you tried the demo service from docs/examples/jmx/persistent-service.sar?

              I see you use a persistName "TestService.ser", if you don't specify anything you should get an .xml file inside /data/xmbean-attrs/ as soon as you change the value of "Param" using the jmx-console.

              What are the steps you follow?

              • 4. Re: Persistance service problems.
                infectedrhythms Novice

                Actually yes I have infact I copied the example ;)

                Even the example did not work.

                I run Jboss 4.0.0 as default.

                And then I cut and paste TestService.sar in the deploy folder...

                Here I will provide my code and XML descriptors...

                jboss-service.xml for my Mbean...

                Ass for persisteName I get an exception listed below the code...

                <?xml version="1.0" encoding="UTF-8"?>
                
                <!DOCTYPE mbean PUBLIC
                 "-//JBoss//DTD JBOSS XMBEAN 1.1//EN"
                 "http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_1.dtd">
                
                
                <server>
                 <mbean code="org.package.TestService" name="org.package:service=TestService" xmbean-dd="">
                 <xmbean>
                 <!-- MBean Info -->
                 <description>Test Service</description>
                 <descriptors>
                 <persistence persistPolicy="OnUpdate"/>
                 <persistence-manager value="org.jboss.mx.persistence.DelegatingPersistenceManager"/>
                 </descriptors>
                 <class>org.package.TestService</class>
                
                 <!-- Attributes -->
                 <attribute access="read-write" getMethod="getParam" setMethod="setParam">
                 <description>A parameter</description>
                 <name>Param</name>
                 <type>java.lang.String</type>
                 <descriptors>
                 <value value="Hello World"/>
                 </descriptors>
                 </attribute>
                
                 <operation>
                 <description>Prints the parameter value to the console.</description>
                 <name>printParam</name>
                 </operation>
                
                
                 &defaultAttributes;
                
                 &defaultOperations;
                 </xmbean>
                 </mbean>
                </server>
                


                jboss-service.xml of Jboss, persistence section...

                 <!-- ==================================================================== -->
                 <!-- XMBean Persistence -->
                 <!-- ==================================================================== -->
                 <mbean code="org.jboss.system.pm.AttributePersistenceService"
                 name="jboss:service=AttributePersistenceService"
                 xmbean-dd="resource:xmdesc/AttributePersistenceService-xmbean.xml">
                 <!-- the AttributePersistenceService is persistent, itself -->
                
                 <!--
                 <attribute name="AttributePersistenceManagerClass">org.jboss.system.pm.XMLAttributePersistenceManager</attribute>
                 <attribute name="AttributePersistenceManagerConfig">
                 <data-directory>data/xmbean-attrs</data-directory>
                 </attribute>
                 <attribute name="ApmDestroyOnServiceStop">false</attribute>
                 <attribute name="VersionTag"></attribute>
                 -->
                 </mbean>
                


                My Service's code...

                package org.package;
                
                import org.jboss.system.ServiceMBean;
                
                public interface TestServiceMBean extends ServiceMBean
                {
                 public void setParam(String param);
                 public String getParam();
                
                 public void printParam();
                }
                
                
                
                package org.package;
                
                import java.util.*;
                import org.jboss.system.ServiceMBeanSupport;
                import org.apache.xmlrpc.*;
                
                public class TestService extends ServiceMBeanSupport implements
                 TestServiceMBean
                {
                 String param = "Not initialized.";
                
                 public void setParam(String param)
                 {
                 this.param = param;
                 }
                
                 public String getParam()
                 {
                 return(param);
                 }
                
                 public void printParam()
                 {
                 log.info("Param value: " + param);
                 }
                
                 protected void startService() throws Exception
                 {
                 log.info("Starting service...");
                
                 try
                 {
                 XmlRpcClient xmlrpc = new XmlRpcClient ("https://deesse.trustmarque.ca");
                 Vector params = new Vector ();
                 params.addElement ("some parameter");
                 // this method returns a string
                 Vector result = (Vector) xmlrpc.execute ("system.listMethods", params);
                
                 Iterator it = result.iterator();
                
                 while(it.hasNext())
                 {
                 log.info((String)it.next());
                 }
                
                 }
                 catch(Exception ex)
                 {
                 log.error(ex.toString());
                 }
                 }
                
                 protected void stopService() throws Exception
                 {
                 log.info("Stopping service...");
                 }
                }
                



                The reason I use persiste name is because if I don' t use it Iget the following exception when deploying...

                16:16:40,058 WARN [EntityResolver] Entity is not registered, publicId=-//JBoss/
                /DTD JBOSS XMBEAN 1.1//EN systemId=http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_
                1.dtd
                16:16:40,105 WARN [BasicMBeanRegistry] javax.management.MBeanRegistrationExcept
                ion: preRegister() failed: [ObjectName='org.tmi:service=TestService', Class=org.
                tmi.TestService (org.tmi.TestService@181e7fe)]
                16:16:40,105 INFO [TestService] Registration is not done -> stop
                16:16:40,105 ERROR [MainDeployer] could not create deployment: file:/C:/Programm
                ing/jboss-4.0.0/server/default/deploy/TestService.sar/
                org.jboss.deployment.DeploymentException: - nested throwable: (java.lang.reflect
                .InvocationTargetException)
                at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java
                :139)
                at org.jboss.system.ServiceController.install(ServiceController.java:200
                )
                at sun.reflect.GeneratedMethodAccessor45.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
                sorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
                er.java:141)
                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
                java:242)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
                at $Proxy4.install(Unknown Source)
                at org.jboss.deployment.SARDeployer.create(SARDeployer.java:208)
                at org.jboss.deployment.MainDeployer.create(MainDeployer.java:889)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:745)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:709)
                at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
                sorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
                er.java:141)
                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
                or.java:119)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
                BeanOperationInterceptor.java:131)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
                java:242)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
                at $Proxy8.deploy(Unknown Source)
                at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
                tScanner.java:305)
                at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
                canner.java:481)
                at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
                doScan(AbstractDeploymentScanner.java:204)
                at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
                loop(AbstractDeploymentScanner.java:215)
                at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
                run(AbstractDeploymentScanner.java:194)
                Caused by: java.lang.reflect.InvocationTargetException
                at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.jav
                a:1426)
                at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.jav
                a:1327)
                at org.jboss.mx.server.MBeanServerImpl.createMBean(MBeanServerImpl.java:
                328)
                at org.jboss.system.ServiceCreator.install(ServiceCreator.java:149)
                at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigura
                tor.java:149)
                at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java
                :114)
                ... 33 more
                Caused by: javax.management.MBeanException
                at org.jboss.mx.interceptor.ReflectedDispatcher.handleInvocationExceptio
                ns(ReflectedDispatcher.java:166)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
                er.java:149)
                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
                or.java:119)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
                BeanOperationInterceptor.java:131)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
                java:242)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                at org.jboss.mx.server.MBeanServerImpl$3.run(MBeanServerImpl.java:1397)
                at java.security.AccessController.doPrivileged(Native Method)
                at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.jav
                a:1392)
                ... 38 more
                Caused by: javax.management.MBeanRegistrationException: preRegister() failed: [O
                bjectName='org.tmi:service=TestService', Class=org.tmi.TestService (org.tmi.Test
                Service@181e7fe)]
                at org.jboss.mx.server.registry.BasicMBeanRegistry.invokePreRegister(Bas
                icMBeanRegistry.java:707)
                at org.jboss.mx.server.registry.BasicMBeanRegistry.registerMBean(BasicMB
                eanRegistry.java:197)
                at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
                sorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
                er.java:141)
                ... 48 more
                Caused by: javax.management.MBeanException
                at org.jboss.mx.persistence.DelegatingPersistenceManager.init(Delegating
                PersistenceManager.java:234)
                at org.jboss.mx.persistence.DelegatingPersistenceManager.load(Delegating
                PersistenceManager.java:74)
                at org.jboss.mx.modelmbean.ModelMBeanInvoker.load(ModelMBeanInvoker.java
                :372)
                at org.jboss.mx.modelmbean.ModelMBeanInvoker.init(ModelMBeanInvoker.java
                :485)
                at org.jboss.mx.modelmbean.ModelMBeanInvoker.invokePreRegister(ModelMBea
                nInvoker.java:447)
                at org.jboss.mx.server.AbstractMBeanInvoker.preRegister(AbstractMBeanInv
                oker.java:613)
                at org.jboss.mx.server.registry.BasicMBeanRegistry.invokePreRegister(Bas
                icMBeanRegistry.java:691)
                ... 53 more
                Caused by: java.lang.Exception: must specify a value for: persistName
                ... 60 more

                Thanks


                • 5. Re: Persistance service problems.
                  Dimitris Andreadis Master

                  Try to remove the DOCTYPE and tell me how it goes.

                  It refers to the xmbean descriptor but you've included in the mbean descriptor.

                  • 6. Re: Persistance service problems.
                    infectedrhythms Novice

                    If I remote the descriptor I get an error that the &DefaultAttributes and &DefaultOperations; elements are not defined...

                    May I call you am currently at work, maybe we can resolve this abit quicker ;)

                    • 7. Re: Persistance service problems.
                      infectedrhythms Novice

                      I mean If I remove the doctype here is the actual exception...

                      16:38:12,698 INFO [STDOUT] [Fatal Error] jboss-service.xml:30:23: The entity "d
                      efaultAttributes" was referenced, but not declared.
                      16:38:12,698 ERROR [MainDeployer] Could not initialise deployment: file:/C:/Prog
                      ramming/jboss-4.0.0/server/default/deploy/TestService.sar/
                      org.jboss.deployment.DeploymentException: The entity "defaultAttributes" was ref
                      erenced, but not declared.; - nested throwable: (org.xml.sax.SAXParseException:
                      The entity "defaultAttributes" was referenced, but not declared.)
                      at org.jboss.deployment.SARDeployer.init(SARDeployer.java:176)
                      at org.jboss.deployment.MainDeployer.init(MainDeployer.java:799)
                      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:736)
                      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:709)
                      at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
                      sorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:585)
                      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
                      er.java:141)
                      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                      at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
                      or.java:119)
                      at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                      at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
                      BeanOperationInterceptor.java:131)
                      at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
                      java:242)
                      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
                      at $Proxy8.deploy(Unknown Source)
                      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
                      tScanner.java:305)
                      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
                      canner.java:481)
                      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
                      doScan(AbstractDeploymentScanner.java:204)
                      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
                      loop(AbstractDeploymentScanner.java:215)
                      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
                      run(AbstractDeploymentScanner.java:194)
                      Caused by: org.xml.sax.SAXParseException: The entity "defaultAttributes" was ref
                      erenced, but not declared.
                      at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
                      at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
                      at org.jboss.deployment.SARDeployer.parseDocument(SARDeployer.java:539)
                      at org.jboss.deployment.SARDeployer.init(SARDeployer.java:140)
                      ... 21 more

                      • 8. Re: Persistance service problems.
                        Dimitris Andreadis Master

                        Maybe it's broken on 4.0. I'll do some tests and let you know.

                        • 10. Re: Persistance service problems.
                          infectedrhythms Novice

                          I just tries it under 3.2.6 as well it still complains that persistName is required.

                          • 11. Re: Persistance service problems.
                            Dimitris Andreadis Master

                            Hmm.. It has something to do with jdk5. With 1.4 it seems ok.

                            • 12. Re: Persistance service problems.
                              infectedrhythms Novice

                              ok ill try it tomorow...

                              Even the persistName attribute?

                              • 13. Re: Persistance service problems.
                                Dimitris Andreadis Master

                                Everything works fine on 1.4 (all versions I tried).

                                Something weird is happening with jdk5, and it affects the old ObjectStreamPersistenceManager, too.

                                • 14. Re: Persistance service problems.
                                  infectedrhythms Novice

                                  yeah I tried the sample here at home and it worked fine!

                                  It looks like 1,5 is breaking quite afew thing all around...

                                  1 2 Previous Next