2 Replies Latest reply on May 16, 2008 12:12 PM by adrian.brock

    Jboss MQ ConnectionFactory being returned null

    prashantsehgal

      Hi,

      My connection factory is setup in my Jboss 4.0.4 server like this:


      <tx-connection-factory>
      <jndi-name>jms/queue/ControlConnectionFactory</jndi-name>
      <use-java-context>false</use-java-context>
      <xa-transaction/>
      <rar-name>jms-ra.rar</rar-name>
      <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
      <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>
      <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider</config-property>
      <max-pool-size>100</max-pool-size>
      </tx-connection-factory>
      



      I'm accessing this from outside of Jboss, using a stand alone client with from it's main method like so:


      public void initializeListener ()
      {
       String url = "lonrs03004:1099";
       Properties props = new Properties();
       props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
       props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
       props.setProperty("java.naming.provider.url", url);
      
       try {
       Context ctx = new InitialContext(props);
       QueueConnectionFactory qConFactory =
       (QueueConnectionFactory) ctx.lookup("jms/queue/ControlConnectionFactory");
      
       if(qConFactory == null) {
       System.out.println("qConFactory is null ");
       System.exit(0);
       }
      }
      



      The connection factory is being returned as null. I read somewhere that this might be because my connection factory is setup using jboss-ra and in such cases standalone clients cant access connection factories. One needs to access them from inside the server.

      a) Is this correct?
      b) If I want to retain my stand-alone client, how should I setup my connection factories?

      Thanks,
      Prashant.

        • 1. Re: Jboss MQ ConnectionFactory being returned null
          prashantsehgal

          Also, if I try to retrieve the default ConnectionFactory from my standalone client, it throws the following exception:

          javax.naming.NameNotFoundException: ConnectionFactory not bound
           at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
           at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
           at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
           at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
           at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
           at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
           at sun.reflect.GeneratedMethodAccessor162.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
           at sun.rmi.transport.Transport$1.run(Transport.java:153)
           at java.security.AccessController.doPrivileged(Native Method)
           at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
           at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
           at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
           at java.lang.Thread.run(Thread.java:595)
           at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
          
           at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
           at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
           at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
           at javax.naming.InitialContext.lookup(InitialContext.java:351)
           at TestReceiver.main(TestReceiver.java:22)
          


          • 2. Re: Jboss MQ ConnectionFactory being returned null

            Read the FAQ linked from the JNDI forum.