6 Replies Latest reply on Dec 16, 2008 8:16 AM by mazz

    Custom JMX plugin manual add not working

    rafaelri

      Hi all,

      After a few days (and a few code changes) I've been able to connect to a secure Websphere installation and now I am able of manualling adding an Websphere JMX instance to Jopr.
      Now I am trying to add my custom jmx plugin, the problem is even though my plugin has the flag suportsManualAdd=true it is failing with the following message on Jopr web ui:

      An unexpected error occurred in the Agent. Failed to add resource with type [GifeManagement] and parent resource id [502662]. - Cause: org.rhq.core.clientapi.agent.PluginContainerException:The GifeJmx plugin does not support manual addition of 'GifeManagement' resources.
      

      I've double checked the plugin zip file under jopr-agent-2.1.0.GA\plugins directory and indeed the latest version is there.

      I'll paste below the top-most part of my plugin descriptor:
      <plugin name="GifeJmx"
       displayName="Gife JMX Plugin"
       version="1.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="urn:xmlns:rhq-plugin"
       xmlns:c="urn:xmlns:rhq-configuration">
      
       <depends plugin="JMX"/>
      
       <service name="GifeManagement"
       description="GifeManagement"
       discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
       class="org.rhq.plugins.jmx.MBeanResourceComponent"
       supportsManualAdd="true">
      

      On the agent.log file, after I try to add the custom plugin, there is the following exception:
      2008-12-11 09:48:11,991 INFO [WorkerThread#0[10.202.70.173:2531]] (rhq.core.pc.inventory.InventoryManager)- Plugin Warning: discovery component org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent returned no resources when passed a single plugin configuration (the plugin developer probably did not implement support for manually discovered resources).
      2008-12-11 09:48:11,991 ERROR [WorkerThread#0[10.202.70.173:2531]] (rhq.core.pc.inventory.InventoryManager)- Manual add failed for resource of type 'GifeManagement' and parent resource id [502662].
      org.rhq.core.clientapi.agent.PluginContainerException: The GifeJmx plugin does not support manual addition of 'GifeManagement' resources.
       at org.rhq.core.pc.inventory.InventoryManager.manuallyAddResource(InventoryManager.java:401)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:618)
       at org.rhq.enterprise.communications.command.impl.remotepojo.server.RemotePojoInvocationCommandService.execute(RemotePojoInvocationCommandService.java:184)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:618)
       at com.sun.jmx.mbeanserver.StandardMetaDataImpl.invoke(StandardMetaDataImpl.java:428)
       at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:238)
       at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:833)
       at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:802)
       at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:216)
       at $Proxy1.execute(Unknown Source)
       at org.rhq.enterprise.communications.command.server.CommandProcessor.handleIncomingInvocationRequest(CommandProcessor.java:358)
       at org.rhq.enterprise.communications.command.server.CommandProcessor.invoke(CommandProcessor.java:253)
       at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:734)
       at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
       at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:369)
       at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
      
      


      Am I missing any steps? Any flags on the rhq-plugin.xml file?
      In order to keep it simple, I've hardcoded the objectName property of my custom jmx, so, I avoid introducing potential problems related to templating the objectName for now.

      best regards,

        • 1. Re: Custom JMX plugin manual add not working
          mazz

          Do you have this in your descriptor:

          <runs-inside>
           <parent-resource-type name="JMX Server" plugin="JMX" />
          </runs-inside>


          Read this section of the docs, particularly about resource injection:

          http://support.rhq-project.org/display/RHQ/AMPS-Plugin+Extensions#AMPS-PluginExtensions-PluginDescriptorContentThatDealsWithPluginExtensions

          You need to tell the plugin container where your resource is allowed to run (i.e. what are its valid parent resource types). If you made your own WebSphere plugin (with a web sphere [server>) you might want that as your parent, or if you are relying solely on the "JMX Server" resource type to house your resource, you'd use the <runs-inside> I have above.

          Take a look at the Hibernate plugin's descriptor as an example, or the RHQ Server plugin - it does this too (with the runs-inside being things like the JMX Server or JBossAS Server).



          • 2. Re: Custom JMX plugin manual add not working
            rafaelri

            Yep,

            the next line right below what I pasted, I'll paste full since I may have done anything else wrong:

            <?xml version="1.0" encoding="UTF-8" ?>
            
            <plugin name="GifeJmx"
             displayName="Gife JMX Plugin"
             version="1.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns="urn:xmlns:rhq-plugin"
             xmlns:c="urn:xmlns:rhq-configuration">
            
             <depends plugin="JMX"/>
            
             <service name="GifeManagement"
             description="GifeManagement"
             discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
             class="org.rhq.plugins.jmx.MBeanResourceComponent"
             supportsManualAdd="true">
            
             <runs-inside>
             <parent-resource-type name="JMX Server" plugin="JMX"/>
             </runs-inside>
            
             <plugin-configuration>
             <c:simple-property name="objectName" readOnly="true" default="anything.com.br:cell=host051740Cell01,name=PontuacaoManagement,type=PontuacaoManagement,node=host051740Node01,process=server1"/>
             </plugin-configuration>
            
             <operation name="atualizarUltimaPontuacao"
             displayName="atualizarUltimaPontuacao"
             description="atualizarUltimaPontuacao">
             <parameters>
             <c:simple-property name="chave" type="string" required="true"/>
             <c:simple-property name="fila" type="long" required="true"/>
             <c:simple-property name="pontuacao" type="integer" required="true"/>
             </parameters>
             </operation>
             <operation name="obterUltimaPontuacao"
             displayName="obterUltimaPontuacao"
             description="obterUltimaPontuacao">
             <parameters>
             <c:simple-property name="chave" type="string" required="true"/>
             <c:simple-property name="fila" type="long" required="true"/>
             </parameters>
             <results>
             <c:simple-property name="operationResult" type="integer"/>
             </results>
             </operation>
            
             <metric property="NumeroPontuacoes"
             displayName="NumeroPontuacoes"
             defaultOn="true"
             displayType="summary"
             defaultInterval="30000"
             description="Numero Aleatorio"/>
             </service>
            
            
            </plugin>
            


            • 3. Re: Custom JMX plugin manual add not working
              ips

              Hi, are you trying to manually add a JMX Server or an MBean? From the error:

              "Manual add failed for resource of type 'GifeManagement' and parent resource id [502662]. org.rhq.core.clientapi.agent.PluginContainerException: The GifeJmx plugin does not support manual addition of 'GifeManagement' resources."

              it appears you're trying to add an MBean (i.e. resource type 'GifeManagement').

              If this is what you are really trying to do, then you'll need to extend MBeanResourceDiscoveryComponent, override discoverResources(), and add support for manual add.

              On the other hand, if what you're trying to do is manually add a new JMX Server, as I suspect, you should go to the Platform resource's Inventory tab's Child Resources section and choose to manually add a JMX Server resource. When prompted for connection properties for the new resource, enter the Websphere settings.

              -Ian

              • 4. Re: Custom JMX plugin manual add not working
                rafaelri

                Now I am really confused.
                I saw the code for MBeanResourceDiscoveryComponent discoverResources method and could not figure out how I enable support for manual add. Another point that I got confused and I'll now debug MBeanResourceDiscoveryComponent to figure out the reason, shouldnt it be already adding my MBean automagically? Since I've provided the objectname string for lookup...

                • 5. Re: Custom JMX plugin manual add not working
                  mazz

                  You get support for manual add for "free" :)

                  Look in the rhq-plugin.xml for the JMX plugin - note the supportsManualAdd attribute:

                  http://svn.rhq-project.org/repos/rhq/trunk/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml

                  <server name="JMX Server" discovery="JMXDiscoveryComponent" class="JMXServerComponent"
                   description="Generic JMX Server"
                   supportsManualAdd="true" createDeletePolicy="neither">


                  • 6. Re: Custom JMX plugin manual add not working
                    mazz

                    I should be more clear, the above XML snippet is what enables the UI to show "JMX Server" in the drop down of available servers in the platform's Inventory tab (when you go to manually add a child server).