3 Replies Latest reply on Apr 9, 2010 10:25 AM by jay shaughnessy

    How to manual add a resource using CLI?

    Steffen Salewski Newbie

      Hello,

       

      I played around a little with the CLI, but when I tried to manual add a resource, I had no success. I tried it this way:

       

      unconnected$ login rhqadmin rhqadmin localhost 7080
      Remote server version is: 1.4.0.B01(0)
      Login successful


      rhqadmin@localhost:7080$ var host = "localhost"

      rhqadmin@localhost:7080$ var port = "80"

      rhqadmin@localhost:7080$ var path = "/"

      rhqadmin@localhost:7080$ var plattformId=10001


      rhqadmin@localhost:7080$ var httpResourceTypeCriteria = new ResourceTypeCriteria()

      rhqadmin@localhost:7080$ httpResourceTypeCriteria.addFilterName("HTTPService")

      rhqadmin@localhost:7080$ var httpResourceType = ResourceTypeManager.findResourceTypesByCriteria(subject, httpResourceTypeCriteria).get(0)


      rhqadmin@localhost:7080$ var configuration = new Configuration()

      rhqadmin@localhost:7080$ dx4adminConfiguration.put(new PropertySimple("url", "http://" + host + ":" + port + path ))


      rhqadmin@localhost:7080$ ResourceFactoryManager.createResource(subject, plattformId, httpResourceType.getId(), "MyServer", null, configuration)

       

      When executing the last command, I get an Exception saying that the plattform does not allow to add a child resource:

       

      [Warning] javax.ejb.EJBException: java.lang.RuntimeException: Error while sending create resource request to agent service
              at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
              at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
              at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
              at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
              at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
              at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
              at $Proxy372.createResource(Unknown Source)
              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:597)
              at org.rhq.enterprise.server.remote.RemoteSafeInvocationHandler.invoke(RemoteSafeInvocationHandler.java:109)
              at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:809)
              at org.jboss.remoting.transport.servlet.ServletServerInvoker.processRequest(ServletServerInvoker.java:232)
              at sun.reflect.GeneratedMethodAccessor181.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
              at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:288)
              at $Proxy391.processRequest(Unknown Source)
              at org.jboss.remoting.transport.servlet.web.ServerInvokerServlet.processRequest(ServerInvokerServlet.java:128)
              at org.jboss.remoting.transport.servlet.web.ServerInvokerServlet.doPost(ServerInvokerServlet.java:157)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.rhq.helpers.rtfilter.filter.RtFilter.doFilter(RtFilter.java:124)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
              at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.RuntimeException: Error while sending create resource request to agent service
              at org.rhq.enterprise.server.resource.ResourceFactoryManagerBean.createResource(ResourceFactoryManagerBean.java:468)
              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:597)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
              at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
              at org.rhq.enterprise.server.common.TransactionInterruptInterceptor.addCheckedActionToTransactionManager(TransactionInterruptInterceptor.java:77)
              at sun.reflect.GeneratedMethodAccessor91.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
              at org.rhq.enterprise.server.authz.RequiredPermissionsInterceptor.checkRequiredPermissions(RequiredPermissionsInterceptor.java:153)
              at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
              at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
              ... 59 more
      Caused by: org.rhq.core.clientapi.agent.PluginContainerException: Component does not support the [org.rhq.core.pluginapi.inventory.CreateChildResourceFacet] int
      erface: ResourceContainer[resource=Resource[id=10001, type=Linux, key=localhost, name=localhost, parent=<null>, version=Linux 2.6.18-92.el5]]
              at org.rhq.core.pc.inventory.ResourceContainer.createResourceComponentProxy(ResourceContainer.java:324)
              at org.rhq.core.pc.util.ComponentUtil.getComponent(ComponentUtil.java:104)
              at org.rhq.core.pc.inventory.ResourceFactoryManager.getCreateChildResourceFacet(ResourceFactoryManager.java:253)
              at org.rhq.core.pc.inventory.ResourceFactoryManager.createResource(ResourceFactoryManager.java:174)
              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:597)
              at org.rhq.enterprise.communications.command.impl.remotepojo.server.RemotePojoInvocationCommandService.execute(RemotePojoInvocationCommandService.java:1
      84)
              at sun.reflect.GeneratedMethodAccessor255.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:93)
              at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:27)
              at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:208)
              at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:120)
              at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:262)
              at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
              at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
              at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:288)
              at $Proxy0.execute(Unknown Source)
              at org.rhq.enterprise.communications.command.server.CommandProcessor.handleIncomingInvocationRequest(CommandProcessor.java:290)
              at org.rhq.enterprise.communications.command.server.CommandProcessor.invoke(CommandProcessor.java:184)
              at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:809)
              at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:608)
              at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:420)
              at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:173)

       

      sun.org.mozilla.javascript.internal.WrappedException: Wrapped javax.ejb.EJBException: [Warning] java.lang.RuntimeException: Error while sending create resource
      request to agent service
      ResourceFactoryManager.createResource(subject, plattformId, httpResourceType.getId(), "MyServer", null, configuration)

      ^

       

      What I do not understand is

      Component does not support the  [org.rhq.core.pluginapi.inventory.CreateChildResourceFacet] interface

       

      because I am adding the resource to the plattform (as I would do using the GUI).


      Any help / hint / example on how to manual add a resource is appreciated.


      Kind regards,

      Steffen