1 Reply Latest reply on Sep 3, 2008 4:22 AM by jaikiran

    @Management and JBoss 4.2.1

    bforney

      Hi,

      I'm new to the forums and new to JBoss, but have used Tomcat and Spring before in at a prior employer. Feel free to ask basic questions or make basic comments given my experience level with JBoss.

      I'm trying to deploy a POJO as a JBoss EJB3.0 Service (using the @Service annotation) with a JMX interface (using the @Management annotation). Both of these annotations are JBoss extensions for EJB3.0. The Service is deployed, but the Management annotation doesn't lead to an MBean by the objectName I've specified and hence JMX clients can't find the MBean. I've looked for the MBean in both the JMX console provided on port 8080 and using a JMX connection from a simple Java program. I'd love any help in understanding why the MBean specified by the @Management(objectName=...) isn't appearing the JMX server.

      Here's what I am doing:

      - JBoss v 4.2.1
      - @Service class:

      @Service(objectName="integral7:service=RecordManager")
      @Management(RecordManagerMBean.class)
      @TransactionAttribute(TransactionAttributeType.NEVER)
      public class RecordManager extends NotificationBroadcasterSupport
      implements NotificationListener, RecordManagerMBean {

      [...]

      public static final ObjectName MBEAN_NAME;
      private static final Exception MBEAN_NAME_EXCEPTION;

      static {
      Exception exception = null;
      ObjectName objName = null;

      try {
      // This should always match the objectName value of the
      // @Service annotation
      objName = new ObjectName("integral7:service=RecordManager");
      } catch (final Exception e) {
      exception = e;
      } finally {
      MBEAN_NAME = objName;
      MBEAN_NAME_EXCEPTION = exception;
      }
      }

      [...]

      }

      - @Management class:
      public interface RecordManagerMBean extends NotificationEmitter {

      }

      - Client code:

      private Object invokeRecordManager(
      final String operation,
      final Object... args
      ) {
      try {
      InitialContext ctx = new InitialContext(); // From jndi.properties
      MBeanServerConnection server =
      (MBeanServerConnection) ctx.lookup("jmx/invoker/RMIAdaptor");

      // generate the signature
      List signature = new ArrayList();
      for (final Object arg : args) {
      signature.add(arg.getClass().getName());
      }

      return server.invoke(
      RecordManager.MBEAN_NAME, operation,
      args, signature.toArray(new String[] {})
      );
      } catch (final Exception e) {
      final StringWriter sw = new StringWriter();
      final PrintWriter pw = new PrintWriter(sw, true);

      e.printStackTrace(pw);
      pw.flush();
      sw.flush();

      return e.toString() + ": " + sw.toString();

      }
      }

      - Have read and tried the different methods outlined in:
      http://docs.jboss.org/ejb3/app-server/reference/build/reference/en/html/jboss_extensions.html#d0e263
      http://docs.jboss.org/ejb3/app-server/tutorial/service/service.html

      In essence, I want a singleton object that can be accessed via JMX remotely. Any suggestions and questions are welcomed.

      Brian

        • 1. Re: @Management and JBoss 4.2.1
          jaikiran

          Brian,

          I don't see any obvious issues with the code. I even tried a similar example of my local setup (JBoss-4.2.3 GA) and that worked without any issues. I was able to see the service in the jmx-console and even invoke the method.

          Can you please post the exact code of your service, including all the import statements? Also can you post the console logs of JBoss?

          While posting the logs or code or xml content, remember to wrap it in a code block using the Code button in the message editor window and please hit the Preview button to make sure your post is correctly formatted