3

During development, I want to be able to run my arquillian tests while my webapp is open. Both use a different instance of WildFly:

  • My Arquillian tests use a managed (or even embedded) wildfly container
  • To test my webapp manually, I deploy it to WildFly from IntelliJ.

I want to be able to do those 2 actions in parallel, but when I do that, I get:

Address localhost:9990 is already in use.

or

org.jboss.arquillian.container.spi.client.container.LifecycleException: The server is already running! Managed containers do not support connecting to running server instances due to the possible harmful effect of connecting to the wrong server. Please stop server before running or change to another type of container.
To disable this check and allow Arquillian to connect to a running server, set allowConnectingToRunningServer to true in the container configuration

To fix this, I 'd like to change arquillian.xml so the tests are using different ports. How do I do that?

<container qualifier="jboss" default="true">
  <configuration>
    <property name="jbossHome">target/wildfly-${version.org.wildfly}</property>
    <property name="javaVmArguments">-Xms512m -Xmx1024m -XX:MaxPermSize=512m</property>
  </configuration>
</container>
Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120

3 Answers3

4

I think you should add to javaVmArguments property: -Djboss.socket.binding.port-offset=1000 and add new property <property name="managementPort">10990</property>

<container qualifier="jboss" default="true">
  <configuration>
    <property name="jbossHome">target/wildfly-${version.org.wildfly}</property>
    <property name="managementPort">10990</property>
    <property name="javaVmArguments">-Xms512m -Xmx1024m -XX:MaxPermSize=512m -Djboss.socket.binding.port-offset=1000</property>
  </configuration>
</container>
Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
sibnick
  • 3,995
  • 20
  • 20
2

Use WildFly's port offset to offset all ports, not just the management port.

<arquillian xmlns="http://jboss.org/schema/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">

  <container qualifier="wildfly-managed" default="true">
    <configuration>
      <property name="jbossHome">target/wildfly-${version.org.wildfly}</property>
      <!-- Port offset allows running the tests while a WildFly server is already running -->
      <property name="javaVmArguments">-Djboss.socket.binding.port-offset=10000 -Xms512m -Xmx1024m -XX:MaxPermSize=512m</property>
      <property name="managementPort">19990</property>
    </configuration>
  </container>

</arquillian>

Mentioning the new managementPort in arquillian.xml is needed, but the mentioning the HTTP port is not needed. Same applies to JMS ports etc I presume.

The config above presumes the default managementPort is 9990, but I 've seen posts where it's 90 or 9999 too (probably older WildFly versions, this is WildFly 9.0.1.Final). The actual managementPort used is shown in WildFly's log during startup.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
1

I got this kind of error too, because arquillian can't use the runnung Web container as it's already running. So, you just put one more property to "arquillian.xml" inside your src/test/resources with this line

<container qualifier="wildfly-managed" default="true">
        <configuration>
            ...
            <!-- this allow connecting to running server -->
            <property name="allowConnectingToRunningServer">true</property>            

        </configuration>
    </container>