1 Reply Latest reply on May 16, 2006 8:12 AM by Dimitris Andreadis

    DeploymentException: java.lang.NoSuchMethodException: <init>

    Alex Titov Newbie

      I tried to create my own MBean, slightly chanched example from JBoss Admin Guide:

      public class My extends ServiceMBeanSupport implements MyMBean {
      
       private String jndiName;
       private HashMap contextMap = new HashMap();
      
       public My(){
      
       }
      
       public String getJndiName()
       {
       return jndiName;
       }
       public void setJndiName(String jndiName)
       throws NamingException
       {
       String oldName = this.jndiName;
       this.jndiName = jndiName;
       if (super.getState() == STARTED) {
       unbind(oldName);
       try {
       rebind();
       } catch(Exception e) {
       NamingException ne = new NamingException("Failed to update jndiName");
       ne.setRootCause(e);
       throw ne;
       }
       }
       }
       public void startService() throws Exception
       {
       rebind();
       }
       public void stopService()
       {
       unbind(jndiName);
       }
       private void rebind() throws NamingException
       {
       InitialContext rootCtx = new InitialContext();
       Name fullName = rootCtx.getNameParser("").parse(jndiName);
       log.info("fullName="+fullName);
       NonSerializableFactory.rebind(fullName, contextMap, true);
       }
       private void unbind(String jndiName)
       {
       try {
       InitialContext rootCtx = new InitialContext();
       rootCtx.unbind(jndiName);
       NonSerializableFactory.unbind(jndiName);
       } catch(NamingException e) {
       log.error("Failed to unbind map", e);
       }
       }
      }
      


      public interface MyMBean extends org.jboss.system.ServiceMBean{
       public String getJndiName();
       public void setJndiName(String jndiName) throws NamingException;
      }
      


      <server>
       <mbean code="mymbean.MyMBean"
       name="chap2.ex1:service=My">
       <attribute name="JndiName">inmemory/maps/MapTest</attribute>
       <depends>jboss:service=Naming</depends>
       </mbean>
      </server>
      


      When I try to deploy application JBoss throws exception:

      ERROR [MainDeployer] Could not create deployment: file:/applictions/jboss/server/default/deploy/MBean.sar
      org.jboss.deployment.DeploymentException: mymbean.MyMBean.<init>(); - nested throwable: (java.lang.NoSuchMethodException: mymbean.MyMBean.<init>())
       at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:178)
       at org.jboss.system.ServiceController.install(ServiceController.java:215)
       at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy4.install(Unknown Source)
       at org.jboss.deployment.SARDeployer.create(SARDeployer.java:232)
       at org.jboss.deployment.MainDeployer.create(MainDeployer.java:935)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:789)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:753)
       at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy6.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:319)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:507)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:192)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:203)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:182)
      Caused by: java.lang.NoSuchMethodException: mymbean.MyMBean.<init>()
       at java.lang.Class.getConstructor0(Class.java:2647)
       at java.lang.Class.getConstructor(Class.java:1629)
       at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:1217)
       at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:271)
       at org.jboss.mx.server.MBeanServerImpl.createMBean(MBeanServerImpl.java:329)
       at org.jboss.system.ServiceCreator.install(ServiceCreator.java:124)
       at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigurator.java:431)
       at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:153)
       ... 33 more
      


      JBoss version is 4.0.3SP1