7 Replies Latest reply on Jun 4, 2014 11:49 AM by Elias Ross

    Extending the script plugin

    raylite3 Apprentice

      Hello, I want to create a custom script plugin to monitor metrics from my application. So I created a rhq-plugin.xml (like attached) and deployed it.

       

      But when I try to add my monitor, I see the following exception saying that the resource cannot be imported. Appreciate any pointers, thanks.

       

      java.lang.RuntimeException:[1401462893152] javax.ejb.EJBException:java.lang.RuntimeException: Error adding [ResourceType[id=10639, name=Script, plugin=my-monitor, category=Server]] Resource to inventory as a child of Resource[id=10001, uuid=e8d2ab5f-f5ec-47f9-93aa-359a497c394a, type={Platforms}Windows, key=kanantha, name=kanantha, parent=<null>, version=Windows 6.1] - cause: java.lang.IllegalStateException: Server specified unknown Resource type: ResourceType[id=10639, name=Script, plugin=my-monitor, category=Server] -> java.lang.RuntimeException:Error adding [ResourceType[id=10639, name=Script, plugin=my-monitor, category=Server]] Resource to inventory as a child of Resource[id=10001, uuid=e8d2ab5f-f5ec-47f9-93aa-359a497c394a, type={Platforms}Windows, key=kanantha, name=kanantha, parent=<null>, version=Windows 6.1] - cause: java.lang.IllegalStateException: Server specified unknown Resource type: ResourceType[id=10639, name=Script, plugin=my-monitor, category=Server] -> java.lang.IllegalStateException:Server specified unknown Resource type: ResourceType[id=10639, name=Script, plugin=my-monitor, category=Server]

      --- STACK TRACE FOLLOWS ---

      [1401462893152] javax.ejb.EJBException:java.lang.RuntimeException: Error adding [ResourceType[id=10639, name=Script, plugin=my-monitor, category=Server]] Resource to inventory as a child of Resource[id=10001, uuid=e8d2ab5f-f5ec-47f9-93aa-359a497c394a, type={Platforms}Windows, key=kanantha, name=kanantha, parent=<null>, version=Windows 6.1] - cause: java.lang.IllegalStateException: Server specified unknown Resource type: ResourceType[id=10639, name=Script, plugin=my-monitor, category=Server] -> java.lang.RuntimeException:Error adding [ResourceType[id=10639, name=Script, plugin=my-monitor, category=Server]] Resource to inventory as a child of Resource[id=10001, uuid=e8d2ab5f-f5ec-47f9-93aa-359a497c394a, type={Platforms}Windows, key=kanantha, name=kanantha, parent=<null>, version=Windows 6.1] - cause: java.lang.IllegalStateException: Server specified unknown Resource type: ResourceType[id=10639, name=Script, plugin=my-monitor, category=Server] -> java.lang.IllegalStateException:Server specified unknown Resource type: ResourceType[id=10639, name=Script, plugin=my-monitor, category=Server]

         at Unknown.Throwable_0(http://localhost:7080/coregui/org.rhq.coregui.CoreGUI/565E0854639ECD736C38967C4D7173DE.cache.html@22)

         at Unknown.Exception_0(http://localhost:7080/coregui/org.rhq.coregui.CoreGUI/565E0854639ECD736C38967C4D7173DE.cache.html@15)

         at Unknown.RuntimeException_0(http://localhost:7080/coregui/org.rhq.coregui.CoreGUI/565E0854639ECD736C38967C4D7173DE.cache.html@15)

         at Unknown.instantiate_32(http://localhost:7080/coregui/org.rhq.coregui.CoreGUI/565E0854639ECD736C38967C4D7173DE.cache.html@10)

         at Unknown.$instantiate_0(http://localhost:7080/coregui/org.rhq.coregui.CoreGUI/565E0854639ECD736C38967C4D7173DE.cache.html@35)

         at Unknown.$instantiate(http://localhost:7080/coregui/org.rhq.coregui.CoreGUI/565E0854639ECD736C38967C4D7173DE.cache.html@36)

         at Unknown.$readObject(http://localhost:7080/coregui/org.rhq.coregui.CoreGUI/565E0854639ECD736C38967C4D7173DE.cache.html@119)

         at Unknown.$onResponseReceived(http://localhost:7080/coregui/org.rhq.coregui.CoreGUI/565E0854639ECD736C38967C4D7173DE.cache.html@453)

         at Unknown.onResponseReceived_6(http://localhost:7080/coregui/org.rhq.coregui.CoreGUI/565E0854639ECD736C38967C4D7173DE.cache.html@31)

         at Unknown.$fireOnResponseReceived(http://localhost:7080/coregui/org.rhq.coregui.CoreGUI/565E0854639ECD736C38967C4D7173DE.cache.html@14)

         at Unknown.onReadyStateChange_0(http://localhost:7080/coregui/org.rhq.coregui.CoreGUI/565E0854639ECD736C38967C4D7173DE.cache.html@51)

         at Unknown.<anonymous>(http://localhost:7080/coregui/org.rhq.coregui.CoreGUI/565E0854639ECD736C38967C4D7173DE.cache.html@13)

         at Unknown.apply(http://localhost:7080/coregui/org.rhq.coregui.CoreGUI/565E0854639ECD736C38967C4D7173DE.cache.html@21)

         at Unknown.entry0(http://localhost:7080/coregui/org.rhq.coregui.CoreGUI/565E0854639ECD736C38967C4D7173DE.cache.html@16)

         at Unknown.<anonymous>(http://localhost:7080/coregui/org.rhq.coregui.CoreGUI/565E0854639ECD736C38967C4D7173DE.cache.html@14)

        • 1. Re: Extending the script plugin
          mazz Master

          Go to your server.log and match up that log id of 1401462893152 (search for that ID in server.log) to get the "real" stack trace. That might provide some additional info - both the stack trace and perhaps the messages just above the exception might help narrow the issue.

          • 2. Re: Extending the script plugin
            raylite3 Apprentice

            The root cause says that it is an unknown resource type.

             

            Caused by: java.lang.IllegalStateException: Server specified unknown Resource type: ResourceType[id=10639, name=Script, plugin=my-monitor, category=Server]

              at org.rhq.core.pc.inventory.InventoryManager.manuallyAddResource(InventoryManager.java:806)

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_17]

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_17]

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_17]

              at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_17]

              at org.rhq.enterprise.communications.command.impl.remotepojo.server.RemotePojoInvocationCommandService.execute(RemotePojoInvocationCommandService.java:184) [rhq-enterprise-comm-4.9.0.JON320GA.jar:4.9.0.JON320GA]

              at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source) [:1.7.0_17]

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_17]

              at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_17]

              at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:111) [rt.jar:1.7.0_17]

              at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:45) [rt.jar:1.7.0_17]

              at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:235) [rt.jar:1.7.0_17]

              at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138) [rt.jar:1.7.0_17]

              at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252) [rt.jar:1.7.0_17]

              at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [rt.jar:1.7.0_17]

              at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) [rt.jar:1.7.0_17]

              at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:305) [rt.jar:1.7.0_17]

              at com.sun.proxy.$Proxy0.execute(Unknown Source)

              at org.rhq.enterprise.communications.command.server.CommandProcessor.handleIncomingInvocationRequest(CommandProcessor.java:290) [rhq-enterprise-comm-4.9.0.JON320GA.jar:4.9.0.JON320GA]

              at org.rhq.enterprise.communications.command.server.CommandProcessor.invoke(CommandProcessor.java:184) [rhq-enterprise-comm-4.9.0.JON320GA.jar:4.9.0.JON320GA]

              at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:967) [jboss-remoting-2.5.4.SP5.jar:]

              at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:798) [jboss-remoting-2.5.4.SP5.jar:]

              at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:751) [jboss-remoting-2.5.4.SP5.jar:]

              at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:586) [jboss-remoting-2.5.4.SP5.jar:]

              at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:234) [jboss-remoting-2.5.4.SP5.jar:]

            • 3. Re: Extending the script plugin
              mazz Master

              That stack trace means your agent does not have your new plugin successfully deployed in it. After you upload your new plugin in the server, you have to tell your agents about the new plugin (agents won't download plugins automatically - though I think in the future someone asked for that to happen automatically, but that's an enhancement request that hasn't been implemented yet).

               

              So your agent has to either a) be restarted so its startup initialization will download new plugins or b) invoke the operation on the agent to download plugins or c) from the agent  prompt invoke "plugins update".

               

              Its easiest if you just restart your agents. If you have lots of agents, you can put them in inventory, put them in a compatible group, and run a group operation to tell all of them to update their plugins.

              • 4. Re: Extending the script plugin
                raylite3 Apprentice

                Thanks, I got past that error. But I am seeing a NullPointerException now and I don't get much else from the stack trace. Appreciate any pointers, thanks.

                 

                17:38:20,127 WARN  [org.rhq.coregui.server.gwt.ResourceGWTServiceImpl] (http-/0.0.0.0:7080-1) Sending exception to client: [1401496700127] : org.rhq.core.clientapi.agent.PluginContainerException: Failed to add resource with type [MyCache] and parent resource id [10001]

                  at org.rhq.core.pc.inventory.InventoryManager.manuallyAddResource(InventoryManager.java:979)

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_17]

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_17]

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_17]

                  at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_17]

                  at org.rhq.enterprise.communications.command.impl.remotepojo.server.RemotePojoInvocationCommandService.execute(RemotePojoInvocationCommandService.java:184) [rhq-enterprise-comm-4.9.0.JON320GA.jar:4.9.0.JON320GA]

                  at sun.reflect.GeneratedMethodAccessor52.invoke(Unknown Source) [:1.7.0_17]

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_17]

                  at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_17]

                  at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:111) [rt.jar:1.7.0_17]

                  at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:45) [rt.jar:1.7.0_17]

                  at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:235) [rt.jar:1.7.0_17]

                  at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138) [rt.jar:1.7.0_17]

                  at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252) [rt.jar:1.7.0_17]

                  at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [rt.jar:1.7.0_17]

                  at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) [rt.jar:1.7.0_17]

                  at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:305) [rt.jar:1.7.0_17]

                  at com.sun.proxy.$Proxy0.execute(Unknown Source)

                  at org.rhq.enterprise.communications.command.server.CommandProcessor.handleIncomingInvocationRequest(CommandProcessor.java:290) [rhq-enterprise-comm-4.9.0.JON320GA.jar:4.9.0.JON320GA]

                  at org.rhq.enterprise.communications.command.server.CommandProcessor.invoke(CommandProcessor.java:184) [rhq-enterprise-comm-4.9.0.JON320GA.jar:4.9.0.JON320GA]

                  at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:967) [jboss-remoting-2.5.4.SP5.jar:]

                  at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:798) [jboss-remoting-2.5.4.SP5.jar:]

                  at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:751) [jboss-remoting-2.5.4.SP5.jar:]

                  at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:586) [jboss-remoting-2.5.4.SP5.jar:]

                  at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:234) [jboss-remoting-2.5.4.SP5.jar:]

                Caused by: java.lang.NullPointerException: [Warning] null

                  ... 25 more

                • 5. Re: Extending the script plugin
                  Elias Ross Master

                  I'm guessing the interesting part of the stack trace is later. Also, you might want to look at the agent log file as well.

                  • 6. Re: Extending the script plugin
                    raylite3 Apprentice

                    The agent log was more helpful.

                     

                    The NPE occurs here in ClassLoaderManager.obtainDiscoveryClassLoader(String pluginName, ClassLoader parentClassLoader)

                     

                    String hash = pluginName + '-' + Integer.toHexString(parentClassLoader.hashCode());

                     

                    So the parentClassLoader is null I suppose. Which in turn means I didn't setup something in my plugin descriptor perhaps?

                    • 7. Re: Extending the script plugin
                      Elias Ross Master

                      Is the script plugin deployed? Is it enabled? Do you see the .jar file on the agent side? I don't know much about how this could happen, it does seem like a bug.