2 Replies Latest reply on Mar 15, 2011 2:59 AM by willemnoorduin

    rhq client beginners question

    willemnoorduin

      I have installed JBoss-Operation Network (JON 2.4.0) on a server, and the accompanying agents on the JBoss-AS nodes. Setup was Okey, and we are receiving data allright. My question is relly about rhq-remote-client. When I first test connectivity, I get:

       

      wnoordui@192.168.0.1:~/rhq/rhq-remoting-cli-3.0.0.GA/scripts$ ./../bin/rhq-cli.sh -u rhqadmin -p rhqadmin

      RHQ - RHQ Enterprise Remote CLI 3.0.0.GA

      Remote server version is: 3.0.1.GA(81e26be20d)

      Login successful

      rhqadmin@localhost:7080$

       

      So this is okay, when I execute the following script:

       

      var criteria = new org.rhq.core.domain.criteria.ResourceCriteria();

      var resource = new org.rhq.core.domain.resource.Resource();

       

      criteria.addFilterResourceTypeName('JBossAS Server')

      criteria.fetchChildResources(true)

       

      resources = ResourceManager.findResourcesByCriteria(criteria)

      resource = resources.get(0)

       

      if (resource.childResources == null) print('no child resources'); else pretty.print(resource.childResources);

       

       

      We get:

       

      rhqadmin@localhost:7080$ exec -f /home/wnoordui/rhq/rhq-remoting-cli-3.0.0.GA/scripts/associations.js

      org.jboss.remoting.CannotConnectException: Can not connect http client invoker. cannot assign instance of java.lang.String to field org.rhq.core.domain.resource.Resource.modifiedBy of type org.rhq.core.domain.auth.Subject in instance of org.rhq.core.domain.resource.Resource. Response: OK/200.

              at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:348)

              at org.jboss.remoting.transport.http.HTTPClientInvoker.transport(HTTPClientInvoker.java:137)

              at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:122)

              at org.jboss.remoting.Client.invoke(Client.java:1634)

              at org.jboss.remoting.Client.invoke(Client.java:548)

              at org.jboss.remoting.Client.invoke(Client.java:536)

              at org.rhq.enterprise.client.RemoteClientProxy.invoke(RemoteClientProxy.java:201)

              at $Proxy18.findResourcesByCriteria(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 sun.reflect.misc.Trampoline.invoke(MethodUtil.java:37)

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      ....

       

      JBoss-Operation Network is installed as out-of-the-box. The only thing I have changed is:

       

      root:/opt/jon-server/jbossas/server/default/conf# vim jboss-service.xml

       

       

       

         And uncomment the attrbute InvokerLocator tag  I did found this by googling). Still not working though. I am just beginning with JON and remoting Client, so I think this is just me. Can anyone say how to configure JON correclty to handle my requsts ?

        • 1. rhq client beginners question
          jayshaughnessy

          Hi,

           

          There are, I think a few issues with the JavaScript in your script.  I'm not sure exactly what's causing the issue but the following script seems to be your intent, and worked for me.  If you have further issues I'd suggest opening up a JON support case.

           

          login rhqadmin rhqadmin

          var criteria = new ResourceCriteria()

          criteria.addFilterResourceTypeName('JBossAS Server')

          criteria.fetchChildResources(true)

          var resources = ResourceManager.findResourcesByCriteria(criteria)

          var resource = resources.get(0)

          if ( resource.getChildResources().isEmpty() ) print('no children'); else pretty.print(resource.getChildResources());

           

          Note the use of method calls to access information. Also, you had some issues in variable declaration (should have been 'var 'resources...' and also there is no need to initialize 'var resource' to a new Resource.

           

          hope this helps

          1 of 1 people found this helpful
          • 2. rhq client beginners question
            willemnoorduin

            Okay, I am getting output now. But when I put thoese command in a file (say /tmp/vies.js) and I add the rhq-cli.sh directory to the PATH variable, I get:

             

            root@zeus:/tmp# rhq-cli.sh -f /tmp/view.js

            Exception in thread "main" org.rhq.enterprise.client.script.CLIScriptException: javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: missing ; before statement (<Unknown source>#1) in <Unknown source> at line number 1

                    at org.rhq.enterprise.client.commands.ScriptCommand.executeScriptFile(ScriptCommand.java:323)

                    at org.rhq.enterprise.client.commands.ScriptCommand.execute(ScriptCommand.java:124)

                    at org.rhq.enterprise.client.ClientMain.processArguments(ClientMain.java:505)

                    at org.rhq.enterprise.client.ClientMain.main(ClientMain.java:106)

            Caused by: javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: missing ; before statement (<Unknown source>#1) in <Unknown source> at line number 1

                    at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:110)

                    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:232)

                    at org.rhq.enterprise.client.commands.ScriptCommand.executeScriptFile(ScriptCommand.java:311)

                    ... 3 more

             

            and (without login rhqadmin rhqadmin, which shouldn't be in the js file, but as parameters to rhq-cli.sh I guess):

             

            root@zeus:/tmp# rhq-cli.sh -u rhqadmin -p rhqadmin -f view.js

            Remote server version is: 3.0.0.GA(8fb6059)

            Login successful

            view.js (No such file or directory)

             

            while:

             

            root@zeus:/tmp# ls view.js

            -rw-r--r-- 1 root root 406 Mar 15 07:30 view.js

             

            I don't know why this is happening, but this could be a SELinux setting. Giving an absolute path, we get:

             

            root@zeus:/tmp# rhq-cli.sh -u rhqadmin -p rhqadmin -f /tmp/view.js

            Remote server version is: 3.0.0.GA(8fb6059)

            Login successful

             

            and:

             

             

            The following questions arises:

             

            1. Why must I put in the absolute path to my script to get rid of the no such file error ? (probably SELinux)
            2. Why don't I see output ?
            3. What is the correct way to source a js script with rhq-cli.sh (such that I can use that in another shell or perl-scvript ?