0 Replies Latest reply on Jun 28, 2006 9:30 AM by mannef

    How on earth!?

    mannef Newbie

      Hi everybody,

      I'm having a rather exotic problem at the moment. Trying to connect to JBoss MQ from a remote client, I succeed when I don't want to.

      Some test code may make this clearer:


      Properties env = new Properties();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.put(Context.PROVIDER_URL,
      "jnp://mafaws01:1099"
      );
      env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      Context context = new InitialContext(env);

      Queue queue = (Queue)context.lookup("queue/A");
      System.out.println("Found queue: " + queue);
      QueueConnectionFactory connectionFactory = (QueueConnectionFactory)context.lookup("ConnectionFactory");
      System.out.println("Found factory: " + connectionFactory);


      This works fine when JBoss is up and running on the server mafaws01. But to my amazement it also works when I've stopped JBoss! The output below is what I get in that case. Apparently the NamingContext object fails to connect to the naming service but still hands me back the factory and queue registered in the JNDI tree, whereas I would prefer that it fails miserably... By the way, if I change the JNDI names to something not found in JNDI, I don't get a factory and queue.

      006-06-28 15:18:26,996 [main] DEBUG org.jnp.interfaces.NamingContext - Failed to connect to mafaws01:1099
      javax.naming.CommunicationException: Failed to connect to server mafaws01:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server mafaws01:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:269)
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1385)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:594)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      at javax.naming.InitialContext.lookup(Unknown Source)
      at se.rgk.boxer.tests.RemoteJmsTest.main(RemoteJmsTest.java:21)
      Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server mafaws01:1099 [Root exception is java.net.ConnectException: Connection refused: connect]
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:243)
      ... 5 more
      Caused by: java.net.ConnectException: Connection refused: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(Unknown Source)
      at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
      at java.net.PlainSocketImpl.connect(Unknown Source)
      at java.net.SocksSocketImpl.connect(Unknown Source)
      at java.net.Socket.connect(Unknown Source)
      at java.net.Socket.connect(Unknown Source)
      at java.net.Socket.(Unknown Source)
      at java.net.Socket.(Unknown Source)
      at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84)
      at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77)
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:239)
      ... 5 more
      2006-06-28 15:18:27,371 [main] DEBUG org.jboss.mq.referenceable.SpyDestinationObjectFactory - SpyDestinationObjectFactory->getObjectInstance()
      Found queue: QUEUE.A
      2006-06-28 15:18:27,402 [main] DEBUG org.jboss.mq.referenceable.SpyConnectionFactoryObjectFactory - Extracting SpyConnectionFactory from reference
      2006-06-28 15:18:27,480 [main] DEBUG org.jboss.mq.referenceable.SpyConnectionFactoryObjectFactory - The GenericConnectionFactory is: GenericConnectionFactory[server=org.jboss.mq.il.uil2.UILServerIL@8aeb74 connectionProperties={ClientILService=org.jboss.mq.il.uil2.UILClientILService, UIL_TCPNODELAY_KEY=yes, UIL_CHUNKSIZE_KEY=1000000, UIL_CONNECTADDRESS_KEY=null, UIL_CONNECTPORT_KEY=0, UIL_SOTIMEOUT_KEY=120000, UIL_RECEIVE_REPLIES_KEY=No, UIL_ADDRESS_KEY=172.16.11.90, UIL_PORT_KEY=8093, PingPeriod=60000, UIL_BUFFERSIZE_KEY=2048}]
      Found factory: org.jboss.mq.SpyConnectionFactory@d90453


      Are JNDI names and stubs somehow cached locally? Does anybody know how to disable this behaviour? Or is there away of checking whether the connectionFactory is really only a disconnected stub?