7 Replies Latest reply on Mar 8, 2002 10:13 AM by Matthias Lakämper

    works in windows, linux doesn't: SpyJMSException: Cannot get

    David Leal Newbie

      hi all,

      (I posted this on the new to JBoss forum but, since I had no reply, and I've read the post with the intent to kill that forum, I decided to post it on this forum, too. I apologise if this shouldn't have been done.)

      I set up jboss 2.4.1 on my Debian/unstable machine. The only configuration change I did was to edit jboss.properties and change java.rmi.server.hostname to the ip of my machine.

      Next, I built the jms-hello-sender and jms-hello-receiver examples and they worked fine.

      Next step was to try these examples running on a remote windows 2000 machine. I edited resources/jndi.properties and changed the java.naming.provider.url to the ip of the server. This was where it started failing. I got the following error when I tried to communicate from windows to linux:

      [java] An exception occured while testing HelloSender: org.jboss.mq.SpyJMSException: Cannot get a client ID: Connection refused: connect
      [java] org.jboss.mq.SpyJMSException: Cannot get a client ID: Connection refused: connect
      [java] at org.jboss.mq.Connection.askForAnID(Connection.java:370)
      [java] at org.jboss.mq.Connection.(Connection.java:113)
      [java] at org.jboss.mq.Connection.(Connection.java:135)
      [java] at org.jboss.mq.SpyConnection.(SpyConnection.java:58)
      [java] at org.jboss.mq.SpyConnectionFactory.createQueueConnection(SpyConnectionFactory.java:91)
      [java] at org.jboss.docs.jms.client.HelloSender.(HelloSender.java:71)
      [java] at org.jboss.docs.jms.client.HelloSender.main(HelloSender.java:118)
      [java] linked exception is:
      [java] java.net.ConnectException: Connection refused: connect
      [java] at java.net.PlainSocketImpl.socketConnect(Native Method)
      [java] at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:320)
      [java] at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:133)
      [java] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:120)
      [java] at java.net.Socket.(Socket.java:273)
      [java] at java.net.Socket.(Socket.java:127)
      [java] at org.jboss.mq.il.oil.OILServerIL.createConnection(OILServerIL.java:254)
      [java] at org.jboss.mq.il.oil.OILServerIL.checkConnection(OILServerIL.java:248)
      [java] at org.jboss.mq.il.oil.OILServerIL.getID(OILServerIL.java:95)
      [java] at org.jboss.mq.Connection.askForAnID(Connection.java:367)
      [java] at org.jboss.mq.Connection.(Connection.java:113)
      [java] at org.jboss.mq.Connection.(Connection.java:135)
      [java] at org.jboss.mq.SpyConnection.(SpyConnection.java:58)
      [java] at org.jboss.mq.SpyConnectionFactory.createQueueConnection(SpyConnectionFactory.java:91)
      [java] at org.jboss.docs.jms.client.HelloSender.(HelloSender.java:71)
      [java] at org.jboss.docs.jms.client.HelloSender.main(HelloSender.java:118)


      So I tried to do the reverse. I setup jboss on the windows machine and tried jms-hello-sender. It worked.
      Then I tried jms-hello-receiver and I get this on the server:

      [OILClientIL] Checking socket
      [OILClientIL] ConnectionReceiverOILClient is connecting to: 127.0.0.1:33349
      [OILClientIL] java.net.ConnectException: Connection refused: connect
      [ClientConsumer:ID4] Could not send messages to a receiver.
      java.rmi.RemoteException: Cannot connect to the ConnectionReceiver/Server
      at org.jboss.mq.il.oil.OILClientIL.createConnection(OILClientIL.java:98)
      at org.jboss.mq.il.oil.OILClientIL.checkSocket(OILClientIL.java:84)
      at org.jboss.mq.il.oil.OILClientIL.receive(OILClientIL.java:69)
      at org.jboss.mq.server.ClientConsumer.run(ClientConsumer.java:212)
      at java.lang.Thread.run(Unknown Source)
      [JMSServer] JMSServer->connectionFailure(dc=SpyDistributedConnection:ID4)
      [JMSServer] The connection to client ID4 failed.
      [JMSServer] JMSServer->connectionClosing(dc=SpyDistributedConnection:ID4)
      [ClientConsumer:ID4] ClientConsumer:ID4->close()
      [ClientConsumer:ID4] ClientConsumer:ID4->removeSubscription(subscriberId=-214748
      3648)
      [JMSServer] JMSServer->connectionClosing(dc=SpyDistributedConnection:ID4)


      On the client I get nothing. The example keeps running as if it were waiting for messages.

      So I decided to setup jboss on yet another windows 2000 machine. I used the first w2000 as the client. Both jms-hello-sender and jms-hello-receiver worked without problem!

      Finally, I decided to setup jboss on another linux system and use the client on the first linux machine. Didn't work (same problem).

      So I guess the problem is pretty much about linux here. However I don't know what to do now. I'm using sun's jdk 1.3.1_01 on all machines except one where I switched to IBM jdk 1.3.0 (to see if was a problem with vm's on linux). I also tried running everything as root (to see if it was a permissions problem) but couldn't get it working.

      Anyone has a solution for this?

        • 1. Re: works in windows, linux doesn't: SpyJMSException: Cannot
          Peter Antman Expert

          It sounds as if you are having problem with RMI/dual connecor. The server embeds an IP to connect to, but happend to fetch localhost instead of the real hostname ip.

          There usually are two ways to solve this:

          1. Set java.rmi.server.hostname to the corret hostname. Either on commandline (run.sh )
          -Djava.rmi.server.hostname=YourRealName or (if that still exists) in conf/default/jboss.properties

          2. Use the UIL connection factories (look into documentations) which usally does no suffer from these cinds of problems.

          //Peter

          • 2. Re: works in windows, linux doesn't: SpyJMSException: Cannot
            David Leal Newbie

            Hi Peter,

            none of these approaches work. I get exactly the same error. Do you have any ideas?

            • 3. Re: works in windows, linux doesn't: SpyJMSException: Cannot
              David Leal Newbie

              ok, just so that the solution to the problem be known...

              My hostname wasn't set correctly. In /etc/hosts the hostname must be set correctly for it to work. Incidentally, the other linux machine where I tested this was also using dhcp, so it didn't work either...

              Thanks.

              • 4. Re: works in windows, linux doesn't: SpyJMSException: Cannot
                Kit Kline Newbie

                David.

                Thanks for posting up your solution to your problem. I have the exact same issue and still cannot fix it. Can I clarify:

                The /etc/hosts correction you made was on the server running JBoss and not on the client connecting to it?

                My server /etc/hosts and jboss.properties look good. I have added them in to this post. I would be very grateful if anypone with a working RedHat7.1 JBoss setup could have a look and see if that is where the problem for me is

                etc/hosts:

                127.0.0.1 emperor localhost.localdomain localhost
                192.168.204.15 emperor

                and jboss.properties

                # System properties
                # These will be loaded and set by jBoss
                java.rmi.server.useLocalHostName=true
                java.rmi.server.hostname=emperor
                java.rmi.server.codebase=http://emperor:8080/

                # Deprecated: JDBC Drivers should be specified in jboss.jcml, in JDBCProvider
                #jdbc.drivers=org.hsql.jdbcDriver,org.enhydra.instantdb.jdbc.idbDriver

                #java.security.manager=java.lang.SecurityManager

                # Tomcat session Id generation. Uncomment to make Tomcat initial request faster
                # tomcat.sessionid.randomclass=java.util.Random


                thanks in advance

                • 5. Re: works in windows, linux doesn't: SpyJMSException: Cannot
                  Kit Kline Newbie

                  Follow up to own post in case of use to anyone in future:

                  changed /etc/hosts to:

                  127.0.0.1 localhost.localdomain localhost
                  192.168.204.15 emperor

                  and changed

                  etc/sysconfig/network

                  from

                  NETWORKING=yes
                  HOSTNAME=localhost.localdomain
                  GATEWAY=192.168.204.254

                  to

                  NETWORKING=yes
                  HOSTNAME=emperor
                  GATEWAY=192.168.204.254

                  and rebooted server.

                  All was fine afterwards

                  Cheers

                  Kit

                  • 6. Re: works in windows, linux doesn't: SpyJMSException: Cannot
                    Matthias Lakämper Newbie

                    Hi,

                    i´m testing the examples in Chapter 8. Here the first Example "jms-manual-jndi" works.
                    But when i try to start "jms-hello-subscriber", i receive the following Stacktrace:
                    /*--------------------Messages------------------------------------------------------------------------------------------------------------------
                    jms-hello-subscriber:
                    [echo] Using resources from: D:\JBoss\examples\examples-2.4.4\examples/resources
                    [java] An exception occured while testing HelloPublisher: org.jboss.mq.SpyJMSException: Cannot get a client ID: Option unsupported by protocol: connect
                    [java] org.jboss.mq.SpyJMSException: Cannot get a client ID: Option unsupported by protocol: connect
                    [java] at org.jboss.mq.Connection.askForAnID(Connection.java:439)
                    [java] at org.jboss.mq.Connection.(Connection.java:122)
                    [java] at org.jboss.mq.Connection.(Connection.java:145)
                    [java] at org.jboss.mq.SpyConnection.(SpyConnection.java:58)
                    [java] at org.jboss.mq.SpyConnectionFactory.createTopicConnection(SpyConnectionFactory.java:62)
                    [java] at org.jboss.docs.jms.client.HelloSubscriber.(HelloSubscriber.java:76)
                    [java] at org.jboss.docs.jms.client.HelloSubscriber.main(HelloSubscriber.java:133)
                    [java] linked exception is:
                    [java] java.net.SocketException: Option unsupported by protocol: connect
                    [java] at java.net.PlainSocketImpl.socketConnect(Native Method)
                    [java] at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:320)
                    [java] at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:133)
                    [java] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:120)
                    [java] at java.net.Socket.(Socket.java:273)
                    [java] at java.net.Socket.(Socket.java:127)
                    [java] at org.jboss.mq.il.oil.OILServerIL.createConnection(OILServerIL.java:254)
                    [java] at org.jboss.mq.il.oil.OILServerIL.checkConnection(OILServerIL.java:248)
                    [java] at org.jboss.mq.il.oil.OILServerIL.getID(OILServerIL.java:95)
                    [java] at org.jboss.mq.Connection.askForAnID(Connection.java:434)
                    [java] at org.jboss.mq.Connection.(Connection.java:122)
                    [java] at org.jboss.mq.Connection.(Connection.java:145)
                    [java] at org.jboss.mq.SpyConnection.(SpyConnection.java:58)
                    [java] at org.jboss.mq.SpyConnectionFactory.createTopicConnection(SpyConnectionFactory.java:62)
                    [java] at org.jboss.docs.jms.client.HelloSubscriber.(HelloSubscriber.java:76)
                    [java] at org.jboss.docs.jms.client.HelloSubscriber.main(HelloSubscriber.java:133)

                    BUILD SUCCESSFUL
                    /*--------------------Messages------------------------------------------------------------------------------------------------------------------

                    I am working on a WinNT4.0 workstation. This workstation is in a network with dhcp. The JBoss-Server
                    and the client-Program are running on this workstation. The error raises with Version 2.4.3 and Version 2.4.4.

                    I have tested to change the HOSTS-File, with no success.
                    // HOSTS
                    127.0.0.1 localhost
                    nnn.nnn.nnn.nnn myPcNAME
                    // HOSTS

                    I would be glad to get help,

                    regards Matthias



                    • 7. Re: works in windows, linux doesn't: SpyJMSException: Cannot
                      Matthias Lakämper Newbie

                      Hi again,

                      one more info:

                      i have changed the source to use the RMI-Connection-Factory.
                      With this setting the example works fine. But in the manual it is mentioned, that this Protocol is slow.

                      regards Matthias