[jboss-user] [Management, JMX/JBoss] - MBean deployment - EJB3 and call

redCar do-not-reply at jboss.com
Fri May 2 04:07:10 EDT 2008


Hallo,

I try to deploy a MBean with EJB3 annotation on the server and call it from a sessionBean. The MBean looks like:


  | package trail.jmx;
  | 
  | import org.jboss.annotation.ejb.Service;
  | import org.jboss.annotation.ejb.Management;
  | 
  | @Service (objectName="trail:service=calculator")
  | @Management(Calculator.class)
  | public class CalculatorMBean implements Calculator {
  | 
  |    public double calculate (int start, int end, double saving) {
  |     double tmp = Math.pow(1. + growthrate / 12., 12. * (end - start) + 1);
  |     return saving * 12. * (tmp - 1) / growthrate;
  |   }
  | ....
  | 

In My SessionBean I want to call it with:


  |    private Object callXMB_Calculator(String operationName, Object[] params)
  |   {
  |     Object result = null;
  | 
  |     try
  |     {
  |      MBeanServer mbs = (MBeanServer) MBeanServerFactory.findMBeanServer(null).iterator().next();
  |       ObjectName oName = new ObjectName("jboss.j2ee:jar=CalcMBean.jar,name=CalculatorMBean,service=EJB3");
  | 
  |       String[] signature = null;
  |       if (params != null)
  |       {
  |         signature = new String[params.length];
  | 
  |         for (int i = 0; i < params.length; ++i)
  |         {
  |           signature = params.getClass().getName();
  |         }
  |       }
  | 
  |       result = mbs.invoke(oName, operationName, params, signature);
  | 

I call the function like this:


  |     callXMB_Calculator("calculate", new Object[]{1,2,4d});
  | 

But when I call the service-Method, I get a ReflectionException
Caused by: java.lang.IllegalArgumentException: Unable to find operation calculate(java.lang.Integer,java.lang.Integer,java.lang.Double)

When the server ist starting, I get the message:

  | 2008-05-02 09:30:35,281 INFO  [org.jboss.ejb3.JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=CalcMBean.jar,name=CalculatorMBean,service=EJB3 with dependencies:
  | 2008-05-02 09:30:35,468 INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: trail.jmx.CalculatorMBean ejbName: CalculatorMBean
  | 2008-05-02 09:30:35,531 INFO  [STDOUT] Calculator - Creating
  | 

To deploy the service, I have only copied the .jar file into the deploy directory. It contains only the .class files.
With the use of 'old' XMBean' I have no problem, but I would prefere the EJB3 style. What can I do?

Thank you,
Werner Hofmann


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

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



More information about the jboss-user mailing list