11 Replies Latest reply on Aug 16, 2004 1:18 PM by aegbertjr

    org.jboss.mq.SpyJMSException: Cannot authenticate user

    chuckharris

      I just moved from Java 1.3.1_09 to 1.4.2_04 and am having a problem with sending jms.
      The problem occurs when a client (no jboss) tries to send a JMS message to a queue for an mdb. The exception thrown is:
      org.jboss.mq.SpyJMSException: Cannot authenticate user; - nested throwable: (java.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(SpyConnectionFactory.java:116)
      at gov.ca.boe.afsp.messages.EfilingAsyncObjectMessageClient.send(Unknown Source)
      at gov.ca.boe.afsp.messages.CommandLineWorkcaseInvoker.main(Unknown Source)
      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:169)
      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)
      at org.jboss.mq.Connection.authenticate(Connection.java:876)
      ... 6 more


      This worked fine before the change in Java. How do I get the user to authenticate? I do not specify
      a security setting. The same client can send a message to another provider that is still
      running jboss with Java 1.3.1_09. I did telnet to ip:1099 and that was accessible and showed:
      ¼fsr?java.rmi.MarshalledObject|+?ùfcn>??I?hashlocBytest?[BobjBytesq~?xpêO?our?[B¼=?°Ta?xp%¼fthttp://0.0.0.0:8083/q~q~uq
      ~?+¼fsr org.jnp.server.NamingServer_Stub??xrjava.rmi.server.RemoteStubT¦_+ïße?xr?java.rmi.server.RemoteObject+a¦æ a3??xpw
      9
      UnicastRef2ip?Jai@²+:ä?Çx

      Connection to host lost.


      .How do I get this issue resolved?

        • 1. Re: org.jboss.mq.SpyJMSException: Cannot authenticate user
          chuckharris

          Sorry- I forgot to add that I am running Jboss 3.2.2 on a win2k. The client is running win2k prof server.

          • 2. Re: org.jboss.mq.SpyJMSException: Cannot authenticate user
            genman


            Just a few guesses, but you should use the same JVM on the client side as on the server.

            Also, check that the OILServer port is open. You should be using UIL2 (see the FAQ) anyway.

            • 3. Re: org.jboss.mq.SpyJMSException: Cannot authenticate user
              chuckharris

              I left the other server at 1.3.1.9 to see if it was the version of Java. It appeasrs that 1.4.2_04 is the root cause??? I moved the other server to 1.4 and now the same exception is thrown.
              I ran netstat and:
              TCP CHARRIS-53510:8090 CHARRIS-53510:0 LISTENING
              TCP CHARRIS-53510:8092 CHARRIS-53510:0 LISTENING
              TCP CHARRIS-53510:8093 CHARRIS-53510:0 LISTENING
              also telnet to 8090 from the client to the appserver without a problem. I'll try using uil instead of oil.

              • 4. Re: org.jboss.mq.SpyJMSException: Cannot authenticate user
                chuckharris

                Thanks for the reply.
                I converted to using UIL2
                ejb-jar.xml:

                <resource-ref>
                 <res-ref-name>jms/UIL2ConnectionFactory</res-ref-name>
                 <res-type>javax.jms.UIL2ConnectionFactory</res-type>
                 <res-auth>Container</res-auth>
                </resource-ref>

                jboss.xml:
                <resource-ref>
                 <res-ref-name>jms/UIL2ConnectionFactory</res-ref-name>
                 <jndi-name>queue/MY_Queue</jndi-name>
                </resource-ref>

                but the same exception is thrown, although it does take a few seconds longer to fail than before:
                Logging:

                The provider name from jndi is ip:1099
                09:04:54,380 DEBUG [main] [messages.JMSMessageUtils] *** jndicontext created
                09:04:54,380 DEBUG [main] [messages.JMSMessageUtils] Looking up UILConnectionFactory in JNDI
                09:04:58,847 DEBUG [main] [messages.JMSMessageUtils] *** obj created with jndicontext
                org.jboss.mq.SpyConnectionFactory@7a1576
                org.jboss.mq.SpyJMSException: Cannot authenticate user; - nested throwable:

                (java.net.ConnectException: Connection refus
                ed: 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(SpyConnectionFactory.java:116)
                at messages.AsyncObjectMessageClient.send(Unknown Source)
                at messages.CommandLineWorkcaseInvoker.main(Unknown Source)
                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:169)
                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.uil2.UILServerIL.createConnection(UILServerIL.java:579)
                at org.jboss.mq.il.uil2.UILServerIL.getSocketMgr(UILServerIL.java:500)
                at org.jboss.mq.il.uil2.UILServerIL.authenticate(UILServerIL.java:302)
                at org.jboss.mq.Connection.authenticate(Connection.java:876)
                ... 6 more
                09:05:20,898 ERROR [main] [messages.AsyncObjectMessageClient] jmsex Cannot authenticate user; -
                nested throwable: (java.net.ConnectException: Connection refused: connect)


                Since the uil2 change did not fix the issue, is there a reason (performance or otherwise) not to leave it using uil?
                I can send messages to the queue from the app server to itself. It just fails from the client. Is there a security setting in 1.4.2 that I need to make that I didn't with 1.3.1?



                • 5. Re: org.jboss.mq.SpyJMSException: Cannot authenticate user
                  genman


                  I don't think this is security related, it just happens that the socket fails when doing its handshaking. Perhaps the FAQ has something about Windows and sockets?

                  • 6. Re: org.jboss.mq.SpyJMSException: Cannot authenticate user
                    chuckharris

                    Thanks for helping.
                    I looked through the FAQ and do not see anything about this issue. I have been reading through many topics and saw several about the hosts file. I added ip conputername and computername ip to the server and client. Didn't help (rebooted after changing). The switch to 1.4 also stopped my web server from sending messages to its app server. The web server is not sending messages to the app server. Rather, it processes them. I'll post separately for that. I can telnet to 1099 and 8093 to the app server from the client. I saw another post http://www.jboss.org/index.html?module=bb&op=viewtopic&t=50427
                    about to many anonymous client sockets so I closed Context as soon as it was no longer needed.
                    That did not fix it. I have posted below the code and logging from the client. There is no logging on the
                    server. Thanks for the help in figuring this out.
                    This is the code that is fails:

                    public void send()
                     {
                     try
                     {
                     Logger.debug(s_classname, "send()");
                    QueueConnection qconn = JMSMessageUtils.getQueueConnectionFactory().createQueueConnection();
                     Logger.debug(s_classname, "send() 1"); //this never logs
                     QueueSession session = qconn.createQueueSession(false,QueueSession.AUTO_ACKNOWLEDGE);
                     m_msg = session.createObjectMessage();
                     m_msg.setObject(m_object);
                     JMSMessageUtils.sendAsyncMessage(m_msg,session,m_queue);
                     session.close();
                     qconn.close();
                     Logger.debug(s_classname, "~send()");
                     }
                     catch (JMSException e)
                     {
                     e.printStackTrace();
                     Logger.error(s_classname,"jmsex " + e.getMessage());
                     }
                     catch (Exception e)
                     {
                     e.printStackTrace();
                     Logger.error(s_classname,"generic ex " + e.getMessage());
                     }
                     }


                    public static javax.jms.QueueConnectionFactory getQueueConnectionFactory()
                     throws Exception {
                     if (USE_JNDI)
                     {
                     Logger.debug(s_classname,"getting a QueueConnectionFactory");
                     return(javax.jms.QueueConnectionFactory) jndiLookup(QUEUECONFAC);
                     }
                     else
                     {
                     // return new provider-specific QueueConnectionFactory
                     return null;
                     }
                     }


                    public static Object jndiLookup(String name) throws NamingException
                     {
                     Context jndiContext = null;
                     /* try
                     {
                     jndiContext = new InitialContext();
                     Object o = jndiContext.lookup(name);
                     }
                     catch (NamingException e)
                     {
                     Logger.error(s_classname,"Could not create JNDI context: " +
                     e.getMessage(),e);
                     throw e;
                     }
                     */
                     Logger.debug(s_classname,"*** \n\n\nthe name to look up is " + name);
                     Context ctx = new InitialContext();
                     String jndiName = ctx.lookup(JNDINAME).toString();
                     Logger.debug(s_classname,"*** \n\n\nThe provider name from jndi is " + jndiName.toString());
                     Object obj = null;
                     Hashtable properties = new Hashtable();
                     properties.put(Context.INITIAL_CONTEXT_FACTORY,
                     "org.jnp.interfaces.NamingContextFactory");
                     properties.put(Context.PROVIDER_URL,jndiName);
                     //"168.71.206.252" + ":1099");
                     properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming");
                     //properties.put(Context.SECURITY_AUTHENTICATION,"none");
                     ctx.close();
                     if (jndiContext == null)
                     {
                     try
                     {
                     jndiContext = new InitialContext(properties);
                     Hashtable h = jndiContext.getEnvironment();
                     Logger.debug(s_classname,"*** jndicontext created " + jndiContext.SECURITY_AUTHENTICATION +"\n"
                     + h.toString());
                     }
                     catch (NamingException e)
                     {
                     Logger.error(s_classname,"Could not create JNDI context: " +
                     e.getMessage(),e);
                     throw e;
                     }
                     }
                     try
                     {
                     Logger.debug(s_classname,"Looking up " + name + " in JNDI");
                     obj = jndiContext.lookup(name);
                     Logger.debug(s_classname,"*** obj created with jndicontext\n"
                     + obj.toString() + "'''''");
                     }
                     catch (NamingException e)
                     {
                     Logger.error(s_classname,"JNDI lookup failed: " + e.getMessage(),e );
                     throw e;
                     }
                     jndiContext.close();
                     return obj;
                     }

                    The logging again:
                    08:00:37,261 DEBUG [main] [gov.ca.boe.afsp.messages.EfilingAsyncObjectMessageClient] send()
                    setting up logging for gov.ca.boe.afsp.messages.JMSMessageUtils
                    08:00:37,281 DEBUG [main] [gov.ca.boe.afsp.messages.JMSMessageUtils] getting a QueueConnectionFactory
                    08:00:37,281 DEBUG [main] [gov.ca.boe.afsp.messages.JMSMessageUtils] ***


                    the name to look up is UIL2ConnectionFactory
                    08:00:37,781 DEBUG [main] [gov.ca.boe.afsp.messages.JMSMessageUtils] ***


                    The provider name from jndi is 168.71.206.231:1099
                    08:00:37,781 DEBUG [main] [gov.ca.boe.afsp.messages.JMSMessageUtils] *** jndicontext created java.naming.security.authentication
                    {java.naming.provider.url=168.71.206.231:1099, java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jboss.naming:org.jnp.interfaces}
                    08:00:37,781 DEBUG [main] [gov.ca.boe.afsp.messages.JMSMessageUtils] Looking up UIL2ConnectionFactory in JNDI
                    08:00:38,002 DEBUG [main] [gov.ca.boe.afsp.messages.JMSMessageUtils] *** obj created with jndicontext
                    org.jboss.mq.SpyConnectionFactory@7a1576'''''
                    org.jboss.mq.SpyJMSException: Cannot authenticate user; - nested throwable: (java.net.ConnectException: Connection refus
                    ed: 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(SpyConnectionFactory.java:116)
                    at gov.ca.boe.afsp.messages.EfilingAsyncObjectMessageClient.send(Unknown Source)
                    at gov.ca.boe.afsp.messages.CommandLineWorkcaseInvoker.main(Unknown Source)
                    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:169)
                    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.uil2.UILServerIL.createConnection(UILServerIL.java:579)
                    at org.jboss.mq.il.uil2.UILServerIL.getSocketMgr(UILServerIL.java:500)
                    at org.jboss.mq.il.uil2.UILServerIL.authenticate(UILServerIL.java:302)
                    at org.jboss.mq.Connection.authenticate(Connection.java:876)
                    ... 6 more
                    08:01:00,244 ERROR [main] [gov.ca.boe.afsp.messages.EfilingAsyncObjectMessageClient] jmsex Cannot authenticate user;
                    - nested throwable: (java.net.ConnectException: Connection refused: connect)





                    • 7. Re: org.jboss.mq.SpyJMSException: Cannot authenticate user
                      chuckharris

                      I guess a little more info for the problem. I found an queue example at
                      http://www.jboss.org/wiki/Wiki.jsp?page=QueueExample
                      and changed it from localhost to use the server ip. Run from the server it returned:
                      Creating jndi context - alternatively use a jndi.properties
                      Looking up queue
                      Looking up connection factory
                      Creating connection
                      Creating session
                      Creating sender
                      Creating message
                      Sending message
                      Creating receiver
                      Try to receive message, it will not work
                      You have to start the connection before receiving messages
                      This receive will work
                      Got message: org.jboss.mq.SpyTextMessage {
                      Header {
                      jmsDestination : QUEUE.testQueue
                      jmsDeliveryMode : 2
                      jmsExpiration : 0
                      jmsPriority : 4
                      jmsMessageID : ID:16-10900107639031
                      jmsTimeStamp : 1090010763903
                      jmsCorrelationID: null
                      jmsReplyTo : null
                      jmsType : null
                      jmsRedelivered : false
                      jmsProperties : {}
                      jmsPropertiesReadWrite:false
                      msgReadOnly : true
                      producerClientId: ID:16
                      }
                      Body {
                      text :hello
                      }
                      }

                      Run from the client it failed similarly:
                      Creating jndi context - alternatively use a jndi.properties
                      Looking up queue
                      Looking up connection factory
                      Creating connection
                      Exception in thread "main" org.jboss.mq.SpyJMSException: Cannot authenticate user; - nested throwable: (java.net.Connect
                      Exception: 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(SpyConnectionFactory.java:116)
                      at gov.ca.boe.afsp.messages.Client.main(Client.java:36)
                      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:169)
                      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.uil2.UILServerIL.createConnection(UILServerIL.java:579)
                      at org.jboss.mq.il.uil2.UILServerIL.getSocketMgr(UILServerIL.java:500)
                      at org.jboss.mq.il.uil2.UILServerIL.authenticate(UILServerIL.java:302)
                      at org.jboss.mq.Connection.authenticate(Connection.java:876)
                      ... 5 more

                      JMS was not a problem with 1.3.1_09 and is with 1.4.2_04.
                      Is there something different between the two that I am not seeing? Help.

                      • 8. Re: org.jboss.mq.SpyJMSException: Cannot authenticate user
                        chuckharris

                        And i forgot to include the version of jboss which is 3.2.2 and the os is win2k. Sorry for the oversight.

                        • 9. Re: org.jboss.mq.SpyJMSException: Cannot authenticate user

                          This is a known bug in 3.2.2 - it is one of the reasons 3.2.3 followed very shortly afterwards.

                          You can workaround it with
                          run.bat -Djboss.bind.address=<your-ip-address>

                          • 10. Re: org.jboss.mq.SpyJMSException: Cannot authenticate user
                            chuckharris

                            Thanks for the reply!

                            • 11. Re: org.jboss.mq.SpyJMSException: Cannot authenticate user
                              aegbertjr

                              I am seeing the same exception for clients attempting to call createTopicConnection() (after a successful JNDI lookup) outside the firewall:

                              org.jboss.mq.SpyJMSException: Cannot authenticate user; - nested throwable: (java.net.ConnectException: Connection timed out: connect)


                              Packet sniffing and logs confirm that the clients are trying to connect with the internal IP address that JBoss is running on and they obviously cannot resolve this address.

                              Any suggestions or insight?

                              Running:
                              JBoss 3.2.1 (also seeing the same problem on 3.2.5)
                              Java 1.4.2_04

                              Regards,

                              AE