3 Replies Latest reply on Oct 26, 2003 8:18 AM by Adrian Brock

    Still cannot authenticate

    arabin Novice

      My code:

      public class PerformanceTesterSender implements Runnable
      {
      static InitialContext iniCtx = null;
      static QueueConnectionFactory qfact = null;
      //static QueueConnection qconn = null;

      String msg;
      //static CountDown done = new CountDown(1);
      public PerformanceTesterSender (String msg)
      {
      this.msg = msg;
      }

      public void run()
      {
      try
      {
      System.out.println("Sending " + msg);
      sendRecvAsync(msg);
      }
      catch (Throwable ex)
      {
      synchronized (this)
      {
      System.out.println(msg);
      ex.printStackTrace();
      }
      }
      }

      public void sendRecvAsync(String text)
      throws JMSException, NamingException
      {
      QueueSession session = null;
      Queue que = null;
      //Logging.debugInfoLog("Begin sendRecvAsync");
      // Setup the PTP connection, session
      synchronized (this)
      {
      if (iniCtx == null)
      iniCtx = new InitialContext();
      }

      que = (Queue) iniCtx.lookup("queue/testQueue");
      QueueConnection qconn = qfact.createQueueConnection();
      session = qconn.createQueueSession(false,
      QueueSession.AUTO_ACKNOWLEDGE);
      qconn.start();
      // Set the async listener
      QueueReceiver recv = session.createReceiver(que);
      //recv.setMessageListener(new ExListener());
      // Send a text msg
      QueueSender send = session.createSender(que);
      TextMessage tm = session.createTextMessage(text);
      send.send(tm);
      //Logging.debugInfoLog("sendRecvAsync, sent text="
      // + tm.getText());
      send.close();
      //Logging.debugInfoLog("End sendRecvAsync");
      qconn.stop();
      session.close();
      qconn.close();
      }


      public static void main(String args[]) throws Exception
      {
      iniCtx = new InitialContext();
      qfact = (QueueConnectionFactory) iniCtx.lookup("QueueConnectionFactory");
      //qconn = qfact.createQueueConnection();
      for (int ii=0; ii< 300; ii++)
      {
      String msg = "Text Message " + ii + " " + ServiceTimer.getFormattedTime();
      //Logging.debugInfoLog("Sending " + msg);
      PerformanceTesterSender client = new PerformanceTesterSender(msg);
      Thread thr = new Thread (new PerformanceTesterSender(msg));
      thr.start();
      }
      System.out.println("Stop");
      //client.done.acquire();
      //done.acquire();
      //System.exit(0);
      }

      }


      Here is what I have on iteration 288 (the first 287 were OK):

      Sending Text Message 288 05:52:53,987
      Text Message 0 05:52:52,706
      org.jboss.mq.SpyJMSException: Cannot authenticate user; - nested throwable: (jav
      a.net.ConnectException: Connection refused: connect)
      at org.jboss.mq.Connection.authenticate(Connection.java:883)
      at org.jboss.mq.Connection.(Connection.java:238)
      at org.jboss.mq.Connection.(Connection.java:315)
      at org.jboss.mq.SpyConnection.(SpyConnection.java:60)
      at org.jboss.mq.SpyConnectionFactory.createQueueConnection(SpyConnection
      Factory.java:116)
      at com.wrn.teamworks.cms.client.PerformanceTesterSender.sendRecvAsync(Pe
      rformanceTesterSender.java:63)
      at com.wrn.teamworks.cms.client.PerformanceTesterSender.run(PerformanceT
      esterSender.java:37)
      at java.lang.Thread.run(Thread.java:534)
      Caused by: java.net.ConnectException: Connection refused: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
      at java.net.Socket.connect(Socket.java:452)
      at java.net.Socket.connect(Socket.java:402)
      at java.net.Socket.(Socket.java:309)
      at java.net.Socket.(Socket.java:153)
      at javax.net.DefaultSocketFactory.createSocket(DashoA6275)
      at org.jboss.mq.il.oil.OILServerIL.createConnection(OILServerIL.java:563
      )
      at org.jboss.mq.il.oil.OILServerIL.checkConnection(OILServerIL.java:507)

      at org.jboss.mq.il.oil.OILServerIL.authenticate(OILServerIL.java:289)Tex
      t Message 167 05:52:53,144
      Text Message 45 05:52:52,737
      Text Message 57 05:52:52,753

      at org.jboss.mq.Connection.authenticate(Connection.java:876)
      ... 7 more

      Any idea why?