1 Reply Latest reply on Sep 5, 2008 10:45 AM by S K

    Connection Refused looking up jmx/rmi/RMIAdaptor on JBoss_4_

    Harley Blumenfeld Newbie

      I am having trouble looking up the jmx/rmi/RMIAdaptor within JBoss 4.2.0 GA GA. I looked all over site and did not find an answer. This did work with JBoss 4.0.3SP1 and the same configuration which makes me scratch my head.

      I have the following policy file and -Djava.security.policy variable pointing to this file in my run.bat script.

      grant {
       permission java.security.AllPermission;
       permission java.util.PropertyPermission "*", "read,write";
       permission java.net.SocketPermission "*", "connect,accept,resolve,listen";
      };


      This following simple example from the Wiki fails with the exception to follow:

      public static void main( String args[] )
       throws Exception
       {
       MBeanServerConnection server;
       Properties prop = new Properties();
       prop.put( Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
       String serverHost = InetAddress.getLocalHost().getHostName();
       prop.put(Context.PROVIDER_URL, serverHost);
       InitialContext initialContext = new InitialContext( prop );
      
       server = ( MBeanServerConnection ) initialContext.lookup( "jmx/rmi/RMIAdaptor" );
       ObjectName on = new ObjectName( "jboss.system:type=Server" );
       Object ver = server.getAttribute( on, "Version" );
       System.out.println( "Version " + ver );
       }
      


      Here is the exception of Connection Refused...

      Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: ST-BLUMENXP and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server ST-BLUMENXP:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server ST-BLUMENXP:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]]
       at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1414)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:594)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at PrintVersion.main(PrintVersion.java:29)
      Caused by: javax.naming.CommunicationException: Failed to connect to server ST-BLUMENXP:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server ST-BLUMENXP: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)
       ... 4 more
      Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server ST-BLUMENXP: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(PlainSocketImpl.java:333)
       at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
       at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
       at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
       at java.net.Socket.connect(Socket.java:519)
       at java.net.Socket.connect(Socket.java:469)
       at java.net.Socket.<init>(Socket.java:366)
       at java.net.Socket.<init>(Socket.java:266)
       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
      

      I took out the jboss code and stepped through in the debugger and it is failing to connect to the socket, almost like it's not listening. However I can telnet to 1099 on my local machine and get a connection, so that is why I am confused about the Connection refused exception.

      At first I thought it was a security problem but it's not even getting that far.

      Any help would be most appriciated.

      Thanks,
      Harley

        • 1. Re: Connection Refused looking up jmx/rmi/RMIAdaptor on JBos
          S K Newbie

          I know it is too late, but nevertheless someone might find it useful.

          My thought:

          Did you start jboss with -b option

          run -b ST-BLUMENXP


          or instead of inet address hostname, you could put localhost.



          I had a similar problem with Connection refused. I think JBoss doesn't allow all host/ip names by default.


          It is only listens on 127/localhost by default and you have to provide -b option to bind on different ip/dns than the default.