6 Replies Latest reply on Jan 28, 2005 9:09 AM by dimitris

    XMBean persistence problem

    rkisilenko2

      Hello! I experience a difficulty with persistence of XMBeans.
      I have modified a XMBean persistence example from the JBoss 4 Application Server Guide for the purpose of studying the problem. Here is the modified jboss-service.xml:

      <?xml version='1.0' encoding='UTF-8' ?>
      
      <!DOCTYPE server PUBLIC
       "-//JBoss//DTD MBean Service 3.2//EN"
       "http://www.jboss.org/j2ee/dtd/jboss-service_3_2.dtd"
      >
      <server>
       <mbean code="org.jboss.chap2.xmbean.JNDIMap" name="chap2.xmbean:service=JNDIMap"
       xmbean-dd="file:/N:\jboss-4.0.1\server\default\deploy\jndimap-xmbean.xml">
       <depends>jboss:service=Naming</depends>
       </mbean>
       <mbean code="org.jboss.chap2.xmbean.JNDIMap" name="chap2.xmbean:service=JNDIMap-1"
       xmbean-dd="file:/N:\jboss-4.0.1\server\default\deploy\jndimap-xmbean.xml">
       <depends>jboss:service=Naming</depends>
       </mbean>
      </server>

      When two MBean instances are used, persistence manager saves and loads them from the same file.
      Is it possible to change MBean persistence file location? I think, creating a duplicate of jndimap-xmbean.xml with different persistence location is not a best solution.

      Further, I have tried to write a modification of an ObjectStreamPersistenceManager. I have not found
      any possibility to distinguish different MBean instances using metadata passed to the PersistenceManager.store(...) method.

      I use XMBean injection mechanism as a workaround. MBean controls persistence location by itself, but I do not like this solution. I think there should be a more simple way.

      Is it possible to use unique persistence locations for different instances of the same XMBean?

        • 1. Re: XMBean persistence problem
          dimitris

          Hi,

          have you seen this:
          http://www.jboss.org/wiki/Wiki.jsp?page=XMBeanAttributePersistenceService

          This is an extension to the XMBean persistence mechanism, with a default implementation that can write to XML files.

          With this persistence manager you can avoid specifying the exact id (that maps to a filename), in which case the ObjectName will be used, so I assume you'll be able to do what you want.

          We probably need to update the xmbean persistence examples in the user guide...

          • 2. Re: XMBean persistence problem
            dimitris

            BTW, it seems like a good idea to have one -xmbean.xml for each class of mbeans. So far, I've only seen people using a separate -xmbean.xml with each instance...

            • 3. Re: XMBean persistence problem
              rkisilenko2

              Dimitris, thank you for reply. XMBeanAttributePersistenceService is exactly what I need. I should be more attentive when searchnig for docs. And of course it is possible to distinguish between different MBean instances in PersistanceManager using ObjectName that is stored in ModelMBeanInfo.

              But there is also a problem with XMBeanAttributePersistenceService. When XMBean is to be written in file, exception occurs:

              java.io.FileNotFoundException: file:\N:\jboss-4.0.1\server\default\data\xmbean-attrs\chap2.xmbean@3Aservice@3DJNDIMap.xml (?????? ???????????? ????)
              at java.io.FileOutputStream.open(Native Method)
              at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
              at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
              at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler(TransformerIdentityImpl.java:235)
              at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:278)
              at org.jboss.system.pm.XMLAttributePersistenceManager.outputXmlFile(XMLAttributePersistenceManager.java:758)
              at org.jboss.system.pm.XMLAttributePersistenceManager.store(XMLAttributePersistenceManager.java:332)
              at org.jboss.mx.persistence.DelegatingPersistenceManager.store(DelegatingPersistenceManager.java:187)
              at org.jboss.mx.modelmbean.ModelMBeanInvoker.store(ModelMBeanInvoker.java:400)
              at org.jboss.mx.interceptor.PersistenceInterceptor.invoke(PersistenceInterceptor.java:76)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.server.AbstractMBeanInvoker.setAttribute(AbstractMBeanInvoker.java:446)
              at org.jboss.mx.server.MBeanServerImpl.setAttribute(MBeanServerImpl.java:591)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.jboss.jmx.connector.invoker.InvokerAdaptorService.invoke(InvokerAdaptorService.java:257)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:122)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
              at org.jboss.invocation.jrmp.server.JRMPProxyFactory.invoke(JRMPProxyFactory.java:164)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
              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:249)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
              at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
              at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
              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:460)
              at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
              at java.lang.Thread.run(Thread.java:595)

              I use JBoss 4.0.1 under Windows 2000.
              I have also tried running JBoss under Unix. There is no such problem under Unix.
              It looks like a bug in DOM impl that is used by JBoss.
              I have changed XMBeanAttributePersistenceService.outputXmlFile method to use StreamResult(java.io.OutputStream) constructor instead of StreamResult(java.io.File). Such workaround works ok. Whether should I report a bug?

              • 4. Re: XMBean persistence problem
                dimitris

                If I remembed I've put the ObjectName in there, for exactly this reason... :)

                I just tried deploying the example from docs/examples/jmx/persistence-service.sar and that works.

                Could you please try the same, to see if there is any issue with your setup?

                Open an issue in JIRA and send your patch, that'd be great!

                • 5. Re: XMBean persistence problem
                  rkisilenko2

                   

                  I just tried deploying the example from docs/examples/jmx/persistence-service.sar and that works.

                  Could you please try the same, to see if there is any issue with your setup?


                  I have just tried the same. I have made a clean install, deployed example from docs/examples/jmx/persistence-service.sar and changed attribute value of example MBean throught web console.

                  Again, it does not work under Win2000.
                  Again, it works under unix.

                  • 6. Re: XMBean persistence problem
                    dimitris

                    It works for me on WinXP!? If it works better with your patch on win2k, just submit a bug report&your patch to JIRA, JBoss AS project, JMX component.

                    Thanks Roman!