1 Reply Latest reply on Apr 30, 2002 12:25 AM by geraldthewes

    Problems getting JMS ConnectionFactory from MBean

    geraldthewes

      I must be missing something stupid.

      I'm trying to implement an mbean, almost exactly like NewMailService in the Documentation, chapter 11,
      but it fails at start up time.

      I'm using Jboss 3.0.0Beta.

      The start/startService method (fails either using a portable mbean,
      or deriving from org.jboss.system.ServiceMBeanSupport
      as described in Chapter 2).


      Here is the code for the method,
      /** The JBoss service start method hook */
      public void startService() throws Exception
      {
      sLog.info("Starting SmtpPollHeartBeat");

      InitialContext iniCtx = new InitialContext();
      Object tmp = iniCtx.lookup("ConnectionFactory"); // Line 110
      QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
      conn = qcf.createQueueConnection();
      que = (Queue) iniCtx.lookup(commandQueName);
      session = conn.createQueueSession(false,
      QueueSession.AUTO_ACKNOWLEDGE);
      sender = session.createSender(que);
      conn.start();
      ...

      Here is the Jboss error:

      19:23:03,160 ERROR [SmtpPollHeartBeat] Starting failed
      javax.naming.NameNotFoundException: ConnectionFactory not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:282)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:365)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:349)
      at javax.naming.InitialContext.lookup(InitialContext.java:350)
      at com.proteusmobile.smx.services.SmtpPollHeartBeat.startService(SmtpPollHeartBeat.java:110)
      at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:160)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)


      Here is the mbean configuration


      <depends optional-attribute-name="JBossMQService">jboss.mq:service=Server


      ...


      jboss.mq.destination:service=Queue,name=smtppoll
      60
      queue/smtppoll


      As far as I can tell I did all the steps the documentation mentions.

      My thoughts are either
      a) Somehow I'm missing a dependency and org.jboss.mq.SpyConnectionFactor is not yet binded in the
      JNDI directory (in which case which dependency should I use - I can't find documentation on it)
      b) Are my JNDI InitialContext configuration right? Again, all the samples I can find seem to use the approach
      I took.


      I'll go read the sources on how some of the bundled in
      mbeans do similar stuff but help would be greatly appreciated.

      Regards,

      -- gerald


        • 1. Re: Problems getting JMS ConnectionFactory from MBean
          geraldthewes

          OK, I seemed to have solved this one. It appeared the
          problem was indeed the dependencies. My descriptor now looks
          like


          jboss.mq.destination:service=Queue,name=smtppoll
          jboss.mq:service=InvocationLayer,type=JVM
          jboss.mq:service=InvocationLayer,type=OIL
          jboss.mq:service=InvocationLayer,type=UIL
          jboss.mq:service=InvocationLayer,type=RMI
          60
          queue/smtppoll



          Pouring through the JBoss source code was the key :-)

          Now back to regular coding....