1 Reply Latest reply on Dec 12, 2005 10:41 AM by Andrew Oliver

    MBeans Question

    De Pauw Frederic Newbie

      Hello again,

      I'm starting coding in JBMS but i'm very new to J2EE and i've a problem with MBeans:

      I've coded an MBEAN called DestinationManagerMBean and DestinationManager for implementation (names arent good). It works fine and contains a hashmap as attribute that i can manipulate via the jmx console.

      Now i would like that another class get the "live" value of this hashtable, so i need it get the MBean. The code in the method is:

      (class tesDestination)
      (DestinationManagerMBean parent as class field)

      public boolean isChanged(MailAddress address){

      this.parent = (DestinationManagerMBean) JBMailJMXUtil.getMBean(new DestinationManager().getServiceName(),DestinationManagerMBean.class);

      if(parent.changes().containsKey(address.getUser())) return true;
      else return false;
      }



      So what i think i do is getting the DestinationManagerMBean and referencing parent with it, then i invoque the DestinationManager method changes() that return the hashmap.
      Tho i get the following exception:

      2005-12-06 15:02:03,328 INFO [STDOUT] Exception in thread "Thread-18"
      2005-12-06 15:02:03,328 INFO [STDOUT] javax.management.RuntimeOperationsException
      2005-12-06 15:02:03,328 INFO [STDOUT] at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:495)
      2005-12-06 15:02:03,328 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:638)
      2005-12-06 15:02:03,328 INFO [STDOUT] at javax.management.MBeanServerInvocationHandler.invoke(Unknown Source)
      2005-12-06 15:02:03,328 INFO [STDOUT] at $Proxy95.changes(Unknown Source)
      2005-12-06 15:02:03,328 INFO [STDOUT] at org.jboss.mail.destinationmanager.testDestination.isChanged(testDestination.java:21)
      2005-12-06 15:02:03,328 INFO [STDOUT] at org.jboss.mail.smtp.handlers.CmdDATA.handleRequest(CmdDATA.java:79)
      2005-12-06 15:02:03,328 INFO [STDOUT] at org.jboss.mail.smtp.handlers.RequireSTARTTLSProxy.handleRequest(RequireSTARTTLSProxy.java:49)
      2005-12-06 15:02:03,328 INFO [STDOUT] at org.jboss.mail.smtp.SMTPProtocolInstance.handleRequest(SMTPProtocolInstance.java:167)
      2005-12-06 15:02:03,328 INFO [STDOUT] at org.jboss.mail.ConnectionHandler.runSocket(ConnectionHandler.java:168)
      2005-12-06 15:02:03,328 INFO [STDOUT] at org.jboss.mail.ConnectionHandler.run(ConnectionHandler.java:73)
      2005-12-06 15:02:03,328 INFO [STDOUT] at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
      2005-12-06 15:02:03,328 INFO [STDOUT] at java.lang.Thread.run(Unknown Source)
      2005-12-06 15:02:03,328 INFO [STDOUT] Caused by: java.lang.IllegalArgumentException: null object name
      2005-12-06 15:02:03,328 INFO [STDOUT] ... 12 more

      Anyone can help pls ?
      Thanks
      Fred

        • 1. Re: MBeans Question
          Andrew Oliver Master

          This is really not a JBMS problem so much as a JBossMX issue, but I'll cut you some slack. your code is wrong:


          this.parent = (DestinationManagerMBean) JBMailJMXUtil.getMBean(new DestinationManager().getServiceName(),DestinationManagerMBean.class);


          getServiceName is apparently null. This isn't how you should do this anyhow. You should use dependency injection or at least an attribute with the objectname passed in. See $JBMS_HOME/server/default/deploy/mail.ear/mail.sar/META-IFN/jboss-service.xml search on "proxy" for details.