4 Replies Latest reply on Dec 10, 2002 7:20 AM by irkabirka

    Authentication and connection to JMS Queue

    boru

      I wish to start using JMS and Message Beans with JBOSS 3.0.0, but I have run into
      authentication problems on what seems to bee a very simple case:

      I want to send a message to a JBOSS queue from a different JVM than JBOSS is running in.

      I start with the JBOSS example program "SendRecvClient" and make the following mods to get an
      initial context, and to change the name of the factory to the current one ("ConnectionFactory").

      I then compile and run against a clean freshly downloaded no mod version of JBoss 3.0.0.

      it fails with the error below.

      it seems to be complaining about not being able to connect to a socket during the creation
      of a queue connection? localhost:1099 is the correct location, right?

      I have looked at the QUickStart guide chapter 11 but there is no discussion of the QueConnection?

      Any help would be appreciated.

      ----------------------------------------------------------


      public void setupPTP()
      throws JMSException, NamingException
      {
      Properties props = new Properties();
      props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
      props.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
      props.setProperty("java.naming.provider.url","localhost:1099");

      InitialContext iniCtx = new InitialContext(props);
      Object tmp = iniCtx.lookup("ConnectionFactory");
      QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
      conn = qcf.createQueueConnection();
      que = (Queue) iniCtx.lookup("queue/testQueue");
      session = conn.createQueueSession(false,
      QueueSession.AUTO_ACKNOWLEDGE);
      conn.start();
      }


      ---------------------------------------------------------



      Begin sendRecvAsync

      org.jboss.mq.SpyJMSException: Cannot authenticate user

      at org.jboss.mq.Connection.authenticate(Connection.java:766)

      at org.jboss.mq.Connection.(Connection.java:233)

      at org.jboss.mq.Connection.(Connection.java:264)

      at org.jboss.mq.SpyConnection.(SpyConnection.java:59)

      at org.jboss.mq.SpyConnectionFactory.createQueueConnection(SpyConnectionFactory.java:96)

      at test.SendRecvClient.setupPTP(SendRecvClient.java:62)

      at test.SendRecvClient.sendRecvAsync(SendRecvClient.java:74)

      at test.SendRecvClient.main(SendRecvClient.java:98)

      linked exception is:

      java.net.SocketException: Option unsupported by protocol: connect

      at java.net.PlainSocketImpl.socketConnect(Native Method)

      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:320)

      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:133)

      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:120)

      at java.net.Socket.(Socket.java:273)

      at java.net.Socket.(Socket.java:127)

      at org.jboss.mq.il.oil.OILServerIL.createConnection(OILServerIL.java:490)

      at org.jboss.mq.il.oil.OILServerIL.checkConnection(OILServerIL.java:478)

      at org.jboss.mq.il.oil.OILServerIL.authenticate(OILServerIL.java:266)

      at org.jboss.mq.Connection.authenticate(Connection.java:759)

      at org.jboss.mq.Connection.(Connection.java:233)

      at org.jboss.mq.Connection.(Connection.java:264)

      at org.jboss.mq.SpyConnection.(SpyConnection.java:59)

      at org.jboss.mq.SpyConnectionFactory.createQueueConnection(SpyConnectionFactory.java:96)

      at test.SendRecvClient.setupPTP(SendRecvClient.java:62)

      at test.SendRecvClient.sendRecvAsync(SendRecvClient.java:74)

      at test.SendRecvClient.main(SendRecvClient.java:98)

      Exception in thread "main"

        • 1. Re: Authentication and connection to JMS Queue
          azawawi

          i have encountered the same problem.
          When i moved JBoss to another machine, it authenticated and worked (but rather very slow). But on the same machine, it simply doesnt authenticate. On the machine that JBoss was running, it threw a "Cannot connect to the ConnectionReceiver/Server" Exception.

          P.S. I am downloading the source code right now to debug the problem. Wish me luck ;-)

          best regards,
          /ahmad

          • 2. Re: Authentication and connection to JMS Queue
            azawawi

            I used the same Java Virtual Machine (1.4 for client and server) and it worked. I think Socket VM compatibility problem.

            Please take a look at http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/

            • 3. Re: Authentication and connection to JMS Queue
              hchirino

              The JVM compatibility issue has been discussed before. Try using the RMI based ConnectionFactory. I think that it should not have the JVM compatablity problems the other ConnectionFactoryies have.

              Regards,
              Hiram

              • 4. Re: Authentication and connection to JMS Queue
                irkabirka

                If you run into the problem:

                org.jboss.mq.SpyJMSException: Cannot authenticate user; - nested throwable: (java.net.SocketException: Option unsupported by protocol: connect)
                bla bla bla
                And U using a similar code like this:
                Properties env = new Properties();
                //env.put("java.naming.rmi.security.manager", "yes");
                //env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming");
                //env.put(Context.SECURITY_PRINCIPAL, "john");
                //env.put(Context.SECURITY_CREDENTIALS, "nidle");
                env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
                env.put(Context.PROVIDER_URL, "localhost:1099");// "jnp://localhost:1099"
                env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");

                context = new InitialContext(env);

                factory = (QueueConnectionFactory)context.lookup("ConnectionFactory");

                QueueConnection conn = factory.createQueueConnection();
                Queue que = (Queue) context.lookup("queue/testQueue");
                QueueSession session = conn.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
                conn.start();

                And the exception thrown at the line marked italic and U also using e.g. jdk1.4.0 on w2k/xp then the I suggest to set your JAVA_HOME environment variable to JAVA_HOME=c:\jdk1.3.0 (or whereever your 1.3 is laying on yr hdd). Nor RMIConnectionFactory nor else didn't give me... salvation ... ;) againts this problem.
                Now it works fine.

                JMS rule, etc. :)
                I hope it helped u to do yr job well