3 Replies Latest reply on Sep 23, 2004 7:57 PM by genman

    Sending messages from JBoss to Joram

    pjrichter

      I'm trying to send a message to a Joram topic and cannot find specific documentation or examples anywhere. So far I've got:

      in jboss-service.xml:

      <!-- Bind the Joram JNDI server -->
       <mbean code="org.jboss.naming.ExternalContext" name="jboss.jndi:service=ExternalContext,jndiName=external/joram/fileMaint">
       <attribute name="JndiName">external/joram/fileMaint</attribute>
       <attribute name="CacheContext">true</attribute>
       <attribute name="Properties">joram.properties</attribute>
       <attribute name="InitialContext">
       javax.naming.InitialContext
       </attribute>
       <attribute name="RemoteAccess">true</attribute>
       </mbean>
      


      in joram.properties
      java.naming.factory.initial=fr.dyade.aaa.jndi2.client.NamingContextFactory
      java.naming.provider.url=joram://localhost:16400


      Here's the code snippet I'm using
      private InitialContext jbosscontext = null;
       private Context joramcontext = null;
       private Connection conn = null;
      
       public String send() throws Exception
       {
       System.out.println();
       System.out.println("Sends messages from JBoss to Joram...");
      
       jbosscontext = new InitialContext();
       Object tmp = jbosscontext.lookup("external/joram/fileMaint");
       joramcontext = (Context)tmp;
      
       TcpConnectionFactory cf = (TcpConnectionFactory) joramcontext.lookup("cf");
      


      I know the context exists and is bound because I can access from outside JBoss. I'm receiving this exception when it tries to retrieve the connection factory context:

      Cause: javax.naming.NameNotFoundException: cf not bound
       at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:303)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
       at org.jboss.jmx.adaptor.control.Server.invokeOpByName(Server.java:234)
      


      Can anyone spot my problem or point me in the right direction?

        • 1. Re: Sending messages from JBoss to Joram
          genman


          I think for

          
           <attribute name="Properties">joram.properties</attribute>
          

          You put in the actual properties that you have in the file, not the filename.

          • 2. Re: Sending messages from JBoss to Joram
            pjrichter

            The documentation (JBoss Admin pg 230) just has a file name. Do you know what the format might be to list the properties?

            I also tried this technique, but keep getting a NoInitialContexException.

            Properties prop = new Properties();
             prop.setProperty("INITIAL_CONTEXT_FACTORY","fr.dyade.aaa.jndi2.client.NamingContextFactory");
             prop.setProperty("PROVIDER_URL","joram://localhost:16400");
             prop.setProperty("OBJECT_FACTORIES","javax.jms.QueueConnectionFactory");
            
             ictx = new InitialContext(prop);
            
             ConnectionFactory cnxF = (TcpConnectionFactory)TcpConnectionFactory.create("localhost", 16010);
             Connection cnx = cnxF.createConnection();
             Session session = cnx.createSession(true, 0);
            
             org.objectweb.joram.client.jms.Queue dest = (org.objectweb.joram.client.jms.Queue) ictx.lookup("MyQueue");
             ictx.close();
            


            • 3. Re: Sending messages from JBoss to Joram
              genman


              I think the docs are wrong, at these ones are...

              http://www.huihoo.com/jboss/online_manual/3.0/ch13s126.html

              "Properties" should be "PropertiesUrl"

              If you have everything done correctly, the JndiView tool in the JMX console should show everything on this remote server. You can also play around with the actual MBean you're creating below, there's a bunch of stuff to use. It'll also show you what attributes are available.

              When it works, I guess you just do
              ConnectionFactory cf =
              new InitialContext().lookup("external/joram/fileMaint/cf");