5 Replies Latest reply on Apr 1, 2004 1:58 PM by Matthew S. Ring

    MBean to be a topic subscriber, how?

    alanc_yang Newbie

      Trying to be a topic subscriber from MBean, the following encountered exception:

      InitialContext iniCtx = new InitialContext();
      Object tmp = iniCtx.lookup("ConnectionFactory");
      TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;

      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)

      how to subscribe to a topic that MBean can receive the message?

      Thanks a lot for your help.
      Alan

        • 1. Re: MBean to be a topic subscriber, how?
          alanc_yang Newbie

          add something similar to the depolyment descriptor.

          <resource-ref>
          <res-ref-name>jms/QCF</res-ref-name>
          <res-type>javax.jms.ConnectionFactory</res-type>
          <res-auth>Container</res-auth>
          </resource-ref>

          • 2. Re: MBean to be a topic subscriber, how?
            alanc_yang Newbie

            Actually, it still not quite right. If I restart the server, the error would occurred. But if I re-deploy the MBean after the server started, the problem would go away. What could be the issue?

            • 3. Re: MBean to be a topic subscriber, how?
              Adrian Brock Master

              Have you modified jboss's jndi.properties?

              Show the enumeration of the listBindings("") and the context's environment.

              Regards,
              Adrian

              • 4. Re: MBean to be a topic subscriber, how?
                alanc_yang Newbie

                This is the jndi.properties file under /server/default/conf for jboss server that started. Really not sure how to modify for the ConnectionFactory.

                java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                java.naming.provider.url=jnp://localhost:1099
                java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

                Also, the enumeration of listbinding, you mean to view from JMX console? Thank you and sorry about the naiveness.

                Alan

                • 5. 3846641
                  Matthew S. Ring Newbie

                  I wonder if this is an initialization timing problem? Maybe your MBean is being initialized before the ConnectionFactory is ready. Try adding a tag to your jboss-specific xml file for the MBean.

                  Something like this (Sorry, I wasn't sure of the right path/name for the ConnectionFactory, but maybe a dependency on the JMSProviderLoader is good enough):

                  <mbean code="foo.MyMBean"
                   name="fooApp:service=MyMBean">
                   <depends>jboss.mq:service=JMSProviderLoader</depends>
                  </mbean>

                  Good luck!

                  -Matthew S. Ring