3 Replies Latest reply on Nov 1, 2012 4:51 AM by paul.robinson

    Can't connect to a remote container that's not on localhost

    paul.robinson

      Hello,

       

      I'm trying to connect to a remote container (JBoss AS  7.1.0.Alpha2-SNAPSHOT built from master on 21/10/2011) bound to 127.0.0.2. However, from the sure-fire report I can see a failure trying to connect to 127.0.0.1.

       

      First I configured my JBoss instance to bind to 127.0.0.2 by editing "standalone/configuration/standalone.xml" and setting the management and public interfaces to use 127.0.0.2. I then started JBoss with "-b 127.0.0.2" for good measure; not sure if this is also required.

       

      I have a jndi.properties in the root of my test classpath that looks like this:

       

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      java.naming.provider.url=jnp://127.0.0.2:1099
      

       

      I also have an arquillian.xml in the same location that looks like this:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <arquillian xmlns="http://jboss.com/arquillian"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
      
        <!-- Uncomment to have test archives exported to the file system for inspection -->
        <engine>
          <property name="deploymentExportPath">target/exploded-artifact-for-inspection</property>
        </engine>
      
        <!-- Example configuration for a remote JBoss AS 7 instance -->
        <container qualifier="jboss7" default="true">
          <protocol type="jmx-as7">
            <property name="executionType">REMOTE</property>
            <property name="managementAddress ">127.0.0.2</property>
          </protocol>
           <configuration>
              <property name="providerUrl">jnp://127.0.0.2:1099</property>
           </configuration>
        </container>
      
      </arquillian>
      

       

      I am sure that my arquillian.xml is being picked up as I have tried commenting out the 'deploymentExportPath' property and observed that an exploded artifact directory is no longer created.

       

      I've tried various different container configurations in my arquillian.xml that I've read about in forum posting and the Arquillian docs, but I always get the same error, where its trying to connect to 127.0.0.1 rather than 127.0.0.2.

       

      The error I get is as follows:

       

       

      -------------------------------------------------------------------------------
      Test set: org.jboss.narayana.quickstarts.client.ClientTest
      -------------------------------------------------------------------------------
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.35 sec <<< FAILURE!
      org.jboss.narayana.quickstarts.client.ClientTest  Time elapsed: 0 sec  <<< ERROR!
      java.lang.IllegalStateException: Cannot obtain MBeanServerConnection to: service:jmx:rmi:///jndi/rmi://127.0.0.1:1090/jmxrmi
          at org.jboss.as.arquillian.container.MBeanServerConnectionProvider.getConnection(MBeanServerConnectionProvider.java:64)
          at org.jboss.as.arquillian.container.remote.RemoteDeployableContainer.getMBeanServerConnection(RemoteDeployableContainer.java:66)
          at org.jboss.as.arquillian.container.remote.RemoteDeployableContainer.startInternal(RemoteDeployableContainer.java:52)
          at org.jboss.as.arquillian.container.CommonDeployableContainer.start(CommonDeployableContainer.java:88)
          at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$5.perform(ContainerLifecycleController.java:144)
          at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$5.perform(ContainerLifecycleController.java:134)
          at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.forContainer(ContainerLifecycleController.java:182)
          at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.startContainer(ContainerLifecycleController.java:133)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
          at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
          at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createContainerContext(ContainerDeploymentContextHandler.java:57)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:134)
          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)
          at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
          at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$2.perform(ContainerLifecycleController.java:83)
          at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$2.perform(ContainerLifecycleController.java:76)
          at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.forEachContainer(ContainerLifecycleController.java:175)
          at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.startContainers(ContainerLifecycleController.java:75)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
          at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:134)
          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)
          at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
          at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:83)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
          at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
          at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:54)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:134)
          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)
          at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeSuite(EventTestRunnerAdaptor.java:68)
          at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:76)
          at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35)
          at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:146)
          at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
          at $Proxy0.invoke(Unknown Source)
          at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:145)
          at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:87)
          at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
      Caused by: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: 
          java.net.ConnectException: Connection refused]
          at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:338)
          at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
          at org.jboss.as.arquillian.container.MBeanServerConnectionProvider.getConnection(MBeanServerConnectionProvider.java:60)
          ... 69 more
      Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: 
          java.net.ConnectException: Connection refused]
          at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:101)
          at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
          at javax.naming.InitialContext.lookup(InitialContext.java:392)
          at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1886)
          at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1856)
          at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:255)
          ... 71 more
      Caused by: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: 
          java.net.ConnectException: Connection refused
          at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
          at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
          at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
          at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
          at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
          at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
          ... 76 more
      Caused by: java.net.ConnectException: Connection refused
          at java.net.PlainSocketImpl.socketConnect(Native Method)
          at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
          at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
          at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
          at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
          at java.net.Socket.connect(Socket.java:529)
          at java.net.Socket.connect(Socket.java:478)
          at java.net.Socket.<init>(Socket.java:375)
          at java.net.Socket.<init>(Socket.java:189)
          at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
          at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
          at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
          ... 81 more
      

       

      I'm not sure if the problem is that Arquillian is initially trying to contact 127.0.0.1 or if it is making the initial connection to 127.0.0.2 and JBoss is returning back an RMI stub that wants to talk back on 127.0.0.1.

       

      Can you see what I am doing wrong?

       

      Thanks in advance,

       

      Paul.

        • 1. Re: Can't connect to a remote container that's not on localhost
          aslak

          Drop jndi.properties, it's not being used.

           

           

          And try this:

           

           

          <arquillian xmlns="http://jboss.com/arquillian"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
          
          
            <!-- Uncomment to have test archives exported to the file system for inspection -->
            <engine>
              <property name="deploymentExportPath">target/exploded-artifact-for-inspection</property>
            </engine>
          
          
            <!-- Example configuration for a remote JBoss AS 7 instance -->
            <container qualifier="jboss7" default="true">
               <configuration>
                  <property name="managementAddress">127.0.0.2</property>
               </configuration>
            </container>
          
           </arquillian>
          
          
          • 2. Re: Can't connect to a remote container that's not on localhost
            paul.robinson

            Hello,

             

            Thanks for the reply.

             

            I've tried what you suggest, but I'm still getting the same error. Can you suggest anything else for me to try?

             

            Thanks,

             

            Paul.

            • 3. Re: Can't connect to a remote container that's not on localhost
              paul.robinson

              For the benefit of anyone else trying to do this. I can confirm that what Aslak suggested did work when I tried it again today. I don't know what I was doing wrong when I last attempted this.

               

              Paul.