4 Replies Latest reply on Jul 16, 2003 5:38 AM by jgc195

    set methods not called in SAR file

    jgc195

      Hi all,

      Right then...I'm stuck ;o(

      I've been trying to get a small application running that will start up when jboss does - not exactly rocket science I hear you all cry. Well, I didn't think so either. I won't bore you with the whole story...suffice it to say this has kept me stumped for quite a while now.

      I've boiled the problem down to the following. I've got a TestMBean (Interface) and a Test class. Here they are:

      package com.soe.mbeans;

      public interface TestMBean {
      public void setString(String aString);
      public String getString();
      public void start() throws Exception;
      public void stop() throws Exception;
      }


      package com.soe.mbeans;

      public class Test implements TestMBean {

      private String aString;

      private boolean started = false;

      public void setString(String aString) {
      System.out.println("Got " + aString);
      this.aString = aString;
      }

      public String getString() {
      return aString;
      }

      public void start() throws Exception {
      started = true;
      System.out.println("I have started");
      }

      public void stop() throws Exception {
      started = false;
      System.out.println("I've stopped");
      }
      }


      And my jboss-service.xml looks like this:



      jboss.jca:service=LocalTxDS,name=MSSQLDS
      Mamma Mia



      (Note: I've bunged in the 'depends' to try and postpone execution of the SAR as long as possible)

      If I deploy this SAR with JBoss already started, I get what I expect - two messages in the log, the first saying "Got Mamma Mia" and the second saying "I have started". However, if I start JBoss with the SAR in the deploy directory, I only get one message "I have started". The 'setString' method is not called.

      Any ideas why this is the case?

      Thanks for any advice and ideas! All welcome ;O)

      Jason



      By the way, I'm using Jboss 3.0.3 with tomcat-4.1.12.

        • 1. Re: set methods not called in SAR file
          frito

          The agent is looking for methods matching the MBean attribute naming convention in the interface.

          Try setAString and getAString instead of setString and getString .

          Greetings,
          Frito

          • 2. Re: set methods not called in SAR file
            jgc195

            Hi Frito,

            Thanks for the suggestion. I tried it, but JBoss complained on startup that it could not deploy because "No Attribute found with name: String". According to the JBoss documentation, the setXXX and getXXX methods should refer to whatever the attribute is named in the jboss-service.xml file. So, I believe that if the attribute is name=String, then the methods should be setString and getString.

            Afterall, my original SAR did deploy correctly when JBoss was already running. However, when JBoss was started, the 'setString' method was never called. Anyone any idea as to why this is the case?

            Thanks,

            Jason

            • 3. Re: set methods not called in SAR file
              frito

              I suggest not to use java key words. You can't define an attribute named String.

              Another thing I am missing is the binding and unbinding of your MBean, but I don't think this has something to do with your problem right now.

              Greetings,
              Frito

              • 4. Re: set methods not called in SAR file
                jgc195

                Thanks for the suggestion. I tried a different attribute name, but still no luck. I'm now trying the other flavour of Mbean and extending org.jboss.system.ServiceMBeanSupport, and it seems to be working OK so far.

                Thanks for your help!

                Jason