[jboss-user] [EJB 3.0] - @Management and JBoss 4.2.1

bforney do-not-reply at jboss.com
Sun Aug 31 21:01:46 EDT 2008


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



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4173481#4173481

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4173481



More information about the jboss-user mailing list