Hi All,
Please forgive me if this question is uninformed.
I'm trying to create a custom MBean.  I found the section in
the documentation on "Custom MBeans"
(http://www.jboss.org/manual/adv_config.html#custom).
Following the directions, I first implemented my service, sublassing
org.jboss.util.ServiceMBean and org.jboss.util.ServiceMBeanSupport.
I called this class TestService:

package com.experient.toolbox.chuchu;

import javax.management.MalformedObjectNameException;
import javax.management.MBeanServer;
import javax.management.ObjectName;

import org.jboss.logging.Log;
import org.jboss.util.ServiceMBeanSupport;

public class TestService extends ServiceMBeanSupport implements
org.jboss.util.ServiceMBean, TestServiceMBean {
  private Log myLog = new Log("TestService");

  public TestService () {
                System.out.println("Constructing TestService");
  }

  public ObjectName getObjectName (MBeanServer server, ObjectName name)
throws MalformedObjectNameException {
    return new ObjectName(OBJECT_NAME);
  }

  public String getName () {
    return "TestService";
  }

  public void startService () {
                System.out.println("Starting TestService");
  }

  public void stopService () {
    myLog.log ("Stopping TestService");
  }

}

Comparing my class to other services that come with jBoss, I realized I
needed to implement a TestServiceMBean interface:

package com.experient.toolbox.chuchu;

public interface TestServiceMBean {
        public static final String OBJECT_NAME = ":service=TestService";
}

Next, I added the following line to jboss.conf so it would be recognized as
a service:
<MLET CODE = "com.experient.toolbox.chuchu.TestService"
ARCHIVE="experient.jar,jboss.jar" CODEBASE="../lib/ext/"></MLET>

Where experient.jar contains all of my company-proprietary class files,
including the TestService and TestServiceMBean classes
I just described.

Finally, I tried running jBoss with the run.sh command.  It starts up fine,
and even "initializes" my TestService (calls the
constructor), but for the life of me, I cannot get it to call my
"startService" method.  I've also tried adding this
to jboss.dependencies in the form of:
<service name="TestService"></service>
but this has not helped.

I'm running this on Sun 1.2.2/Redhat Linux/jBoss beta 3 (downloaded this
morning).  I'm pretty sure my classpath is set up correctly, since jBoss
is successfully instantiating my TestService object.

I've delved into org.jboss.dependency.DependencyManager a bit, and my
TestService appears to not be starting as a result
of this block of code in DependencyManager.startMBean(ObjectName name):
        try {
            server.invoke(name, "start", new Object[0], new String[0]);
            loaded = true;
        } catch(ReflectionException e) {
            if(e.getTargetException() instanceof NoSuchMethodException) {
                loaded = true;  // This bean doesn't have a start!
            } else {
                System.out.println("Error starting service
'"+name.getCanonicalName()+"': "+e.getTargetException());
            }
        } catch(Throwable t) {
            System.out.println("Error starting service
'"+name.getCanonicalName()+"': "+t);
        }

When jBoss tries to start TestService, the MBeanServer instance 'server'
throws a ReflectionException with a NoSuchMethodException inside.  I've
tried looking at com.sun implementation of the MBeanServer and it's 'invoke'
method, but that's pretty nasty.  Does it try to invoke a method named
"start"?

Can anyone help a newbie out?  Any help would be greatly appreciated.

Thank you,
Adam Rabung
[EMAIL PROTECTED]



--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to