3 Replies Latest reply on Apr 5, 2002 6:59 AM by angelawhelan

    MBean NullPointerException

    angelawhelan

      hi all,
      I wonder if someone can help me. I am new to JBoss/JMX.

      I am using the following MBean from the JBoss groups book :

      package book.jmx.examples;

      public class Hello implements HelloMBean{

      private String name = "";

      public String getName(){
      return name;
      }

      public void setName(String name){
      this.name=name;
      }

      public void print(){
      System.out.println("Hello, " + name + "!!");
      }

      }

      then I try to connect to it via a client application, all goes well in the code until I hit this point in the code :

      pConnector.invoke(name,"setName",new String[] {"David"},null);

      I get the following error :
      java.lang.NullPointerException
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
      at org.jboss.jmx.server.RMIConnectorImpl_Stub.invoke(Unknown Source)
      at org.jboss.jmx.client.RMIClientConnectorImpl.invoke(RMIClientConnectorImpl.java:484)
      at jboss_test.Test.runHelloMBean(Test.java:167)
      at jboss_test.Test.main(Test.java:132)


      Does anyone have any ideas ? This problem is probably a really stupid one, but a bit cryptic for a newbie like me ;)

      Thanks a lot for any help on this !
      A.

        • 1. Re: MBean NullPointerException
          angelawhelan

          oops sorry, the exception I get is actually this one :

          javax.management.ReflectionException: The operation with name setName could not be found
          at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)
          at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
          at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
          at org.jboss.jmx.server.RMIConnectorImpl_Stub.invoke(Unknown Source)
          at org.jboss.jmx.client.RMIClientConnectorImpl.invoke(RMIClientConnectorImpl.java:484)
          at jboss_test.Test.runHelloMBean(Test.java:165)
          at jboss_test.Test.main(Test.java:132)

          • 2. Re: MBean NullPointerException

            It should be

            pConnector.setAttribute(name, new Attribute("Name", "David"));

            Name is an attribute not an operation.
            An attribute is something with one or more of the
            following
            Type getAttribute();
            void setAttribute(Type newValue);

            But

            Type getSomething(Type key)
            is an operation.

            Look at the JMX spec or the JavaBeans spec for more info

            Regards,
            Adrian

            • 3. Re: MBean NullPointerException
              angelawhelan

              Thanks very much for your invaluable help yet again !

              The code is now working :D

              I will go ahead and read the documentation you suggested.

              thanks again :)
              A.