3 Replies Latest reply on Apr 4, 2005 5:40 AM by raja05

    where to define jndi-name for mbean in SAR?

    mikek753

      Hello all,

      My mbean calls class that connects to JMS.
      But, in that class ConnectionFactory can not be bound.
      I don't have any EJB (MDB) no EAR just SAR.

      How I can define and where that my mbean can get context of JMS factory?

      in my code:

      // Get the initial context
      Context context = new InitialContext();
      // Get the connection factory
      TopicConnectionFactory topicFactory =
      (TopicConnectionFactory)context.lookup("ConnectionFactory");

      in jboss-services.xml:



      <resource-ref>
      <res-ref-name>jms/TCF</res-ref-name>
      <jndi-name>ConnectionFactory</jndi-name>
      <res-type>javax.jms.TopicConnectionFactory</res-type>
      </resource-ref>


      MyServer
      jboss.mq.destination:service=Topic,name=MyTopic


      ....


      My mbean doesn't see that ConnectionFactory :-(

      In case of EJB there is jboss.xml where I can define that jndi mapping, but I can't find any info about how to use jboss.xml with SAR.

      Thanks for your help.

        • 1. Re: where to define jndi-name for mbean in SAR?
          dimitris

          You can't use jboss.xml with mbeans. You need to treat this case as if you were writing a stand alone JMS client. You should probably lookup

          "java:/ConnectionFactory"

          for the in-VM factory. Some resources:

          http://www.jboss.org/wiki/Wiki.jsp?page=JBossMQ

          http://docs.jboss.org/admin-devel/Chap6.html#0_pgfId-913324

          • 2. Re: where to define jndi-name for mbean in SAR?
            mikek753

            thank you for reply.
            However, I can't make it work for a while.

            I re-read those resources and didn't find (or missed) info about how to tell JVM about jndi "ConnectionFactory" and where to define it for export.

            There is Global JNDI Namespace :
            ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
            I can see by JNDIView.

            Is that right one "ConnectionFactory" I'm looking for?

            I've tried
            context.lookup("java:/ConnectionFactory")
            but got the same "javax.naming.NameNotFoundException: ConnectionFactory not bound"

            Do I need to do any special to
            Context context = new InitialContext();

            to be able get that resource?
            Any specific setting to conf/jndi.properties ?

            I'm missing some small settings, but which one?

            Thanks.

            • 3. Re: where to define jndi-name for mbean in SAR?
              raja05

              If you have something in the Global NameSpace, you should be looking up context.lookup("ConnectionFactory"). The JNDIView tells u where and how the ConnectionFactory is bound. IF its bound under the "java:" namespace, you need to lookup java:/ConnectionFactory. In all, it depends on what kind of a connectionfactory you are looking at..