2 Replies Latest reply on Nov 18, 2005 6:42 AM by Dimitris Andreadis

    Error when I want to deploy a JMX Service Object, anyone can

    Alfred Yao Newbie

      Hi,
      Today, following the JBoss TrailBlazer example, I write a MBean Service, use it to calculate y=modulus * x + offset:
      Interface:
      package com.alfred.webpa.mbean.test;

      import org.jboss.annotation.ejb.Management;

      @Management (CalculatorMBean.class)
      public interface Calculator {

      // Attribute
      public void setModulus(double modulus);
      public double getModulus();

      public void setOffset(double offset);
      public double getOffset();

      // The management method
      public double calculate(double x);

      // Life cycle method
      public void create() throws Exception;
      }
      Implementation:
      package com.alfred.webpa.mbean.test;

      import org.jboss.annotation.ejb.Service;

      @Service (objectName="webpa:service=calculator")
      public class CalculatorMBean implements Calculator {
      double modulus;
      public void setModulus(double modulus) {
      this.modulus = modulus;
      }
      public double getModulus() {
      return modulus;
      }

      double offset;
      public void setOffset(double offset) {
      this.offset = offset;
      }
      public double getOffset() {
      return offset;
      }

      public double calculate(double x) {
      double result = modulus * x + offset;
      return result;
      }

      public void create() throws Exception {
      modulus = 1;
      offset = 0;
      System.out.println("MBean:Calculator - create()");
      }
      }
      Compile these two class is OK, and I build them into a jar file: MyFirstEJB3.ejb3, and deploy it into the server/all/deploy directory with on Exception, and I call the MBean as follow in a web app in same JVM:
      try {
      MBeanServer server = MBeanServerLocator.locate();
      Calculator cal = (Calculator) MBeanProxyExt.create(Calculator.class, "webpa:service=calculator", server);
      modulus = cal.getModulus();
      offset = cal.getOffset();
      y = cal.calculate(x);
      } catch (Exception e) {
      e.printStackTrace ();
      }
      But when I perform this invoking, it says the MBean is not registered, why? Anyone can help me? Thanks.
      The exception is:
      18:17:41,562 INFO [STDOUT] java.lang.RuntimeException: Error creating MBeanProxy: webpa:service=calculator
      18:17:41,562 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.init(MBeanProxyExt.java:365)
      18:17:41,562 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.(MBeanProxyExt.java:65)
      18:17:41,562 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.create(MBeanProxyExt.java:344)
      18:17:41,562 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.create(MBeanProxyExt.java:308)
      18:17:41,562 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.create(MBeanProxyExt.java:283)
      18:17:41,562 INFO [STDOUT] at com.alfred.webpa.test.TestAction.doCalculate(TestAction.java:148)
      18:17:41,562 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      18:17:41,562 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      18:17:41,562 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      18:17:41,562 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      18:17:41,562 INFO [STDOUT] at com.alfred.common.struts.action.BaseAction.execute(BaseAction.java:99)
      18:17:41,562 INFO [STDOUT] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
      18:17:41,562 INFO [STDOUT] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
      18:17:41,562 INFO [STDOUT] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
      18:17:41,562 INFO [STDOUT] at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
      18:17:41,562 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      18:17:41,562 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      18:17:41,562 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      18:17:41,593 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      18:17:41,593 INFO [STDOUT] at com.alfred.webpa.common.filter.AuthenticateFilter.doFilter(AuthenticateFilter.java:206)
      18:17:41,593 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      18:17:41,593 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      18:17:41,593 INFO [STDOUT] at com.alfred.webpa.common.filter.EncodeFilter.doFilter(EncodeFilter.java:42)
      18:17:41,593 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      18:17:41,593 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      18:17:41,593 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
      18:17:41,593 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      18:17:41,593 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      18:17:41,593 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      18:17:41,593 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      18:17:41,593 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      18:17:41,593 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
      18:17:41,593 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      18:17:41,593 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      18:17:41,593 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      18:17:41,593 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      18:17:41,593 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      18:17:41,593 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      18:17:41,593 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      18:17:41,593 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      18:17:41,593 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      18:17:41,593 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)
      18:17:41,609 INFO [STDOUT] Caused by: javax.management.InstanceNotFoundException: webpa:service=calculator is not registered.
      18:17:41,609 INFO [STDOUT] at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:508)
      18:17:41,609 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.getMBeanInfo(MBeanServerImpl.java:651)
      18:17:41,609 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.init(MBeanProxyExt.java:357)
      18:17:41,609 INFO [STDOUT] ... 41 more