6 Replies Latest reply on Mar 24, 2004 4:08 PM by sstults

    sample program to test MBean

    alanc_yang

      I deployed the JNDIMap sample MBean from chap2 but not sure how to test it. Can somebody help post sample code that can test the JNDIMap sample MBean?

      Thanks in advance!
      - Alan

        • 1. Re: sample program to test MBean
          alanc_yang

          for instance, how to get something like this to work:

          InitialContext ctx = new InitialContext();
          HashMap map = (HashMap) ctx.lookup ("inmemory/maps/MapTest");

          how to specify the initial context for JBoss JNDI at command line?


          • 2. Re: sample program to test MBean

            Moving your question to the jmx forum.

            The answer to your question is to add a jndi.properties to the classpath
            or define the same properties using -Dproperty=value

            Regards,
            Adrian

            • 3. Re: sample program to test MBean
              alanc_yang

              Yes. But now, running into another problem: the StubNotfoundException was thrown. How do I generated the stub that can work?

              Thanks,
              Alan

              -------------

              C:\user\tutorial\hmap2\tst>java -classpath .\;r:\lib\jboss-jmx.jar;c:\j2sdk1.4.2_03\jre\li
              b\rt.jar;r:\client\jbossall-client.jar;..\build\hmap2.jar -Djava.naming.factory.initial=or
              g.jnp.interfaces.NamingContextFactory TestXMBean1
              test 3
              JNDIMap Class: org.jboss.mx.modelmbean.XMBean
              JNDIMap Operations:
              + void start()
              + void stop()
              + void put(java.lang.Object chap2.xmbean:service=JNDIMap,java.lang.Object chap2.xmbean:se
              rvice=JNDIMap)
              + java.lang.Object get(java.lang.Object chap2.xmbean:service=JNDIMap)
              + java.lang.String getJndiName()
              + void setJndiName(java.lang.String chap2.xmbean:service=JNDIMap)
              + [Ljava.lang.String; getInitialValues()
              + void setInitialValues([Ljava.lang.String; chap2.xmbean:service=JNDIMap)
              Exception in thread "main" java.rmi.StubNotFoundException: Stub class not found: TestXMBean1$Listener_Stub; nested exception is:
              java.lang.ClassNotFoundException: TestXMBean1$Listener_Stub
              at sun.rmi.server.RemoteProxy.getStub(Unknown Source)

              • 4. Re: sample program to test MBean
                alanc_yang

                This was straight from the example provided. It encountered the same problem. Can somebody ploease help?

                Thanks,
                Alan

                -------------------------

                C:\examples>ant -Dchap=chap2 -Dex=xmbean1 run-example
                Buildfile: build.xml

                validate:
                [java] ImplementationTitle: JBoss [WonderLand]
                [java] ImplementationVendor: JBoss.org
                [java] ImplementationVersion: 3.2.3 (build: CVSTag=JBoss_3_2_3 date=200402110851)
                [java] SpecificationTitle: JBoss
                [java] SpecificationVendor: JBoss (http://www.jboss.org/)
                [java] SpecificationVersion: 3.2.3
                [java] JBoss version is: 3.2.3



                fail_if_not_valid:

                init:
                [echo] Using jboss.dist=r:\

                compile:

                run-example:

                prepare:

                chap2-ex1xmbean1-sar:

                run-examplexmbean1:
                [java] JNDIMap Class: org.jboss.mx.modelmbean.XMBean
                [java] JNDIMap Operations:
                [java] + void start()
                [java] + void stop()
                [java] + void put(java.lang.Object chap2.xmbean:service=JNDIMap,java.lang.Object cha
                p2.xmbean:service=JNDIMap)
                [java] + java.lang.Object get(java.lang.Object chap2.xmbean:service=JNDIMap)
                [java] + java.lang.String getJndiName()
                [java] + void setJndiName(java.lang.String chap2.xmbean:service=JNDIMap)
                [java] + [Ljava.lang.String; getInitialValues()
                [java] + void setInitialValues([Ljava.lang.String; chap2.xmbean:service=JNDIMap)
                [java] java.rmi.StubNotFoundException: Stub class not found: org.jboss.chap2.xmbean.T
                estXMBean1$Listener_Stub; nested exception is:
                [java] java.lang.ClassNotFoundException: org.jboss.chap2.xmbean.TestXMBean1$Liste
                ner_Stub
                [java] at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.java:98)
                [java] at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.java:55)
                [java] at sun.rmi.server.UnicastServerRef.setSkeleton(UnicastServerRef.java:179)
                [java] at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:142)

                [java] at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:129)

                [java] at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.ja
                va:275)
                [java] at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.ja
                va:178)
                [java] at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.ja
                va:155)
                [java] at org.jboss.chap2.xmbean.TestXMBean1$Listener.(TestXMBean1.java:28)

                [java] at org.jboss.chap2.xmbean.TestXMBean1.main(TestXMBean1.java:73)
                [java] Caused by: java.lang.ClassNotFoundException: org.jboss.chap2.xmbean.TestXMBean
                1$Listener_Stub
                [java] at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
                [java] at java.security.AccessController.doPrivileged(Native Method)
                [java] at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
                [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
                [java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
                [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
                [java] at sun.rmi.server.RemoteProxy.loadClassFromClass(RemoteProxy.java:191)
                [java] at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.java:93)
                [java] ... 9 more
                [java] Exception in thread "main"

                [java] Java Result: 1

                BUILD SUCCESSFUL
                Total time: 10 seconds

                • 5. Re: sample program to test MBean
                  sstults

                  As much as I hate "me too" posts I'm doing it anyway because I'm having the same problem and I'm feeling like a sucker because I paid for the documentation.

                  It's been a month. Somebody must know the answer.

                  • 6. Re: sample program to test MBean
                    sstults

                    ... and that somebody is me.

                    I solved this by doing an 'ant build-all' before doing 'ant -Dchap=chap2 -Dex=xmbean1 run-example'