1 2 Previous Next 18 Replies Latest reply on Apr 25, 2006 10:05 AM by jan sokolowski

    How Can I deploy a Standard MBean on JBoss by using a SAR ?

    Alberto Soleto Newbie

      As long as I now, only Model MBean, and more precisely XMBean, can be deployed by using a *-service.xml file into a SAR. My MBean implementation has to extend ServiceMBeanSupport and my MBean interface has to extend MBeanService.

      Can I deploy a simple Standard MBean (without extending or implementing jboss classes)?

      I read in the Wiki that it is possible, but I don't see how.

      Thanks.

        • 1. Re: How Can I deploy a Standard MBean on JBoss by using a SA
          Alberto Soleto Newbie

          A precision:
          My question is
          "Can I use a SAR for deploying a Standard MBean that uses only standard JMX classes ?".
          I want to use a *-service.xml file to declare my Standard MBean.
          Thanks.

          • 3. Re: How Can I deploy a Standard MBean on JBoss by using a SA
            Alberto Soleto Newbie

            I'm not sure your example answers my question. It shous non standard JMX MBeans.
            I'm trying to deploy a simple Standard MBean on my JBoss by using a SAR file. It's a simple custom class implementing a simple custom interface. There is no org.jboss... heritage or implementation. No MBeanSupport extension or MBeanService implementation. Just a simple Standard MBean.

            I'm affraid the only solution is to embed hand-made deployment code in a servlet context.

            An hybrid alternative shoud be to use the "xmbean-dd" tag in the jboss-service.xml file.

            Thanks.

            • 4. Re: How Can I deploy a Standard MBean on JBoss by using a SA
              Jimmy Wilson Apprentice

               

              "asoleto" wrote:
              As long as I now, only Model MBean, and more precisely XMBean, can be deployed by using a *-service.xml file into a SAR. My MBean implementation has to extend ServiceMBeanSupport and my MBean interface has to extend MBeanService.

              Can I deploy a simple Standard MBean (without extending or implementing jboss classes)?

              Yes, this is possible. Just write your standard implementation and *MBean interface.

              If your question is how do I get start and stop behavior without inheriting JBoss-specific classes, just put start and stop methods on your MBean interface. JBoss will recognize that they exist, and it will call them.

              • 5. Re: How Can I deploy a Standard MBean on JBoss by using a SA
                Alberto Soleto Newbie

                Do you have any example ?
                I mean,
                - I know how to deploy a simple Standard MBean by using xmbeans (jboss-service.xml file with tag xmbeans-dd pointing to my xmbean file describing my MBean interface) from a SAR.
                - I know how to write specific code to deploy a Standard MBean by using JSR-3 calls and call it from a servlet or a servlet context in my SAR.
                - I now how to create jboss specific MBean by using jboss proprietary code and setting the "code" tag.

                BUT I don't know if there is a "magic tag" in the jboss-service.xml file that allows me to deploy a custom Standard MBean without using the xmbean-dd tag. By reading your answer, it seems that it is possible.

                My concern is to use SAR without using xmbean or JBoss specific classes. I want to use just JSR-3.

                Thanks

                • 6. Re: How Can I deploy a Standard MBean on JBoss by using a SA
                  Jimmy Wilson Apprentice

                   

                  "asoleto" wrote:
                  Do you have any example?

                  ...snip...

                  BUT I don't know if there is a "magic tag" in the jboss-service.xml file that allows me to deploy a custom Standard MBean without using the xmbean-dd tag. By reading your answer, it seems that it is possible.

                  My concern is to use SAR without using xmbean or JBoss specific classes. I want to use just JSR-3.


                  Take the JBoss Wiki-provided Hello MBean example *-service.xml descriptor:

                  <?xml version="1.0" encoding="UTF-8"?>
                  
                  <server>
                   <mbean code="com.acme.HelloWorldService" name="acme.com:service=HelloWorld">
                   <attribute name="Message">Hello World</attribute>
                   </mbean>
                  </server>


                  The format of this file does not use the XMBean stuff, and whether or not the MBean is written by extending JBoss classes or not is irrelevant. So long as com.acme.HelloWorldService follows JMX standards, and has a corresponding *MBean interface, this will deploy just fine whether in a SAR or deployed via an XML file alone.

                  Have you actually tried any of this? You questions indicate that you have not.

                  • 7. Re: How Can I deploy a Standard MBean on JBoss by using a SA
                    Alberto Soleto Newbie

                    Thanks for your answer.
                    The example in the Wiki uses JBoss specific API.

                    Every time I try to deploy a simple Standard MBean, I get the same error:

                    org.jboss.deployment.DeploymentException: create operation failed for package file:/D:/apps/appserver/jboss-3.2.5/server/default/deploy/MyTest.sar; - nested throwable: (org.jboss.deployment.DeploymentException: No ClassLoaders found for: test.Mytest; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: test.Mytest))
                    My SAR looks like that:

                    +-- META-INF
                    | +--- jboss.service.xml (similar to the one you provided)
                    | +--- MANIFEST.MF
                    +-- MyTest.jar

                    I also tried to put the jar file inside the META-INF directory but the same exception is thrown all the time. Whatever I do, always the same error.

                    I don't understand. I wonder, if it is so simple, why nobody is able to post a simple example of a Standard MBean deployed within a SAR without using xmbeans ou JBoss classes?

                    Thanks.

                    • 8. Re: How Can I deploy a Standard MBean on JBoss by using a SA
                      Dimitris Andreadis Master

                      The jboss testsuite if full of standard mbean examples not extending jboss classes.

                      And it's a piece of cake to make the http://wiki.jboss.org/wiki/Wiki.jsp?page=ExampleHelloWorldService example, not using jboss classes, i.e.:

                      a) HelloWorldServiceMBean should not extend ServiceMBean
                      b) HelloWorldService should not extend ServiceMBeanSupport

                      Optional
                      c) If you want to receive lifecycle callbacks you should add to HelloWorldServiceMBean interface:
                      void start() throws Exception;
                      void stop();
                      and on HelloWorldService rename startService to start() and stopService() to stop (and make them public).

                      The classloading errors you get are due to bad packaging, so what's in MyTest.jar and what's in you jboss-service.xml?

                      • 9. Re: How Can I deploy a Standard MBean on JBoss by using a SA
                        Alberto Soleto Newbie

                        My Interface:

                        package test;
                        
                        public interface MyTestMBean {
                         public void start() throws Exception;
                         public void stop() throws Exception;
                         public String getMessage();
                         public void setMessage(String message);
                        }


                        Its implementation:
                        package test;
                        
                        public class MyTest implements MyTestMBean {
                         private String message="Not initialized";
                        
                         public void start() throws Exception {
                         System.out.println(">>>>>>> STARTED ! - " + this.getMessage() );
                         }
                         public void stop() {
                         System.out.println(">>>>>>> STOPPED !");
                         }
                         public String getMessage() {
                         return message;
                         }
                         public void setMessage(String message){
                         this.message = message;
                         }
                        }


                        The jboss-service.xml file
                        <?xml version="1.0" encoding="UTF-8"?>
                        
                        <server>
                         <mbean code="test.Mytest" name="test:service=HelloWorld">
                         <attribute name="Message">Hello World</attribute>
                         </mbean>
                        </server>


                        It can't be simpler.

                        I tried:
                        - to put classes tree directly inside the SAR file root dir

                        +-- META-INF
                        | +--- jboss.service.xml (similar to the one you provided)
                        | +--- MANIFEST.MF
                        +-- test
                        +-- MyTestMbean.class
                        +-- MyTest.class

                        - to put classes tree inside a jar file in the SAR file root dir

                        +-- META-INF
                        | +--- jboss.service.xml (similar to the one you provided)
                        | +--- MANIFEST.MF
                        +-- MyTest.jar

                        Always the same error. Notate that the error is not a "NotClassFound" exception, but "No ClassLoader found". This is the reason why I think that JBoss is not able to deploy MBean whitout using JBoss specific classes or XMbean tags.

                        And once again, it is really extrange to listen everybody saying "it works, just try it", but nobody is able to give me a simple working example like the one I wrote.
                        This is like the Loch Ness monster, everybody says that it exists but nobody has never saw it.

                        Thanks for your help.


                        • 10. Re: How Can I deploy a Standard MBean on JBoss by using a SA
                          Jimmy Wilson Apprentice

                           

                          "asoleto" wrote:
                          I tried:
                          - to put classes tree directly inside the SAR file root dir

                          +-- META-INF
                          | +--- jboss.service.xml (similar to the one you provided)
                          | +--- MANIFEST.MF
                          +-- test
                          +-- MyTestMbean.class
                          +-- MyTest.class

                          - to put classes tree inside a jar file in the SAR file root dir

                          +-- META-INF
                          | +--- jboss.service.xml (similar to the one you provided)
                          | +--- MANIFEST.MF
                          +-- MyTest.jar

                          Always the same error. Notate that the error is not a "NotClassFound" exception, but "No ClassLoader found". This is the reason why I think that JBoss is not able to deploy MBean whitout using JBoss specific classes or XMbean tags.

                          ...snip...

                          This is like the Loch Ness monster, everybody says that it exists but nobody has never saw it.


                          Whether there is a Loch Ness monster or not, I can say in this case that I have deployed many, many custom written, non-JBoss dependent MBeans in this manner both with JAR files inside the SAR and class files inside the SAR. I have never had any trouble.

                          Two things look problematic to me in the quoted part of your post. They may / may not be typos, but if they are really what you have, they will cause you trouble.

                          #1: You appear to have named your jboss-service.xml file jboss.service.xml which is not correct. Make sure you really name it correctly. In trying to replicate your problem by doing this, I got a jboss-service.xml not found message type of message so this does not appear to be your issue. I'll assume it is a typo.

                          #2: Could it be that you are not packaging your Java classes correctly? It appears (based on your post) that your Java classes are not in the test subdirectory. That could definately lead to the error you are seeing. Furthermore, it may be that the same thing is happening with your JAR file. That would explain why you have trouble using either method of getting your *.class files inside the SAR.

                          • 11. Re: How Can I deploy a Standard MBean on JBoss by using a SA
                            Alberto Soleto Newbie

                            I mean

                            +-- META-INF
                            | +--- jboss.service.xml (similar to the one you provided)
                            | +--- MANIFEST.MF
                            +-- test
                            | +-- MyTestMbean.class
                            | +-- MyTest.class

                            • 12. Re: How Can I deploy a Standard MBean on JBoss by using a SA
                              Dimitris Andreadis Master

                              I'm so fed up with this thread that I just extended the example with a hellombean2.zip that contains a standard mbean with no JBoss class/interface dependencies.

                              http://wiki.jboss.org/wiki/Wiki.jsp?page=ExampleHelloWorldService

                              • 13. Re: How Can I deploy a Standard MBean on JBoss by using a SA
                                Alberto Soleto Newbie

                                Thanks for your answer, but I do confirm that the file name is well "jboss-service.xml" and that classes are in the test directory.
                                I tried to deploy it in several servers but the problem persists.
                                I put my SAR in this address in order to allow you to test it:
                                http://s58.yousendit.com/d.aspx?id=1B7H7D685VG381DMHJ4O90PCF2

                                Thanks for your feed-back.

                                Can somebody send me a working example ?

                                Thanks.

                                • 14. Re: How Can I deploy a Standard MBean on JBoss by using a SA
                                  Alberto Soleto Newbie

                                  Thank you, Dimitris,

                                  I found the problem in my SAR. It was my fault. I wrote Mytest as class name instead MyTest like a newbee. I read the jboss-service.xml file a hundred times and I never realized my big mistake.

                                  Thanks for your patience to all you.

                                  1 2 Previous Next