【问题标题】:Arquillian: use different port(s) for the managed WildFly container than a normal WildFly processArquillian:为托管的 WildFly 容器使用与普通 WildFly 进程不同的端口
【发布时间】:2015-09-14 08:31:18
【问题描述】:

在开发过程中,我希望能够在我的 web 应用程序打开时运行我的 arquillian 测试。两者都使用不同的 WildFly 实例:

  • 我的 Arquillian 测试使用托管(甚至是嵌入式)wildfly 容器
  • 为了手动测试我的 web 应用,我将其从 IntelliJ 部署到 WildFly。

我希望能够并行执行这 2 个操作,但是当我这样做时,我得到:

Address localhost:9990 is already in use.

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

要解决此问题,我想更改arquillian.xml,以便测试使用不同的端口。我该怎么做?

<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>

【问题讨论】:

    标签: wildfly jboss-arquillian


    【解决方案1】:

    我认为您应该添加到javaVmArguments 属性:-Djboss.socket.binding.port-offset=1000 并添加新属性&lt;property name="managementPort"&gt;10990&lt;/property&gt;

    <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>
    

    【讨论】:

    • 我的 webapp 的 html 资源和它的 REST 服务不会也占用端口 8080 吗?
    【解决方案2】:

    使用 WildFly 的 port offset 来偏移所有端口,而不仅仅是管理端口。

    <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>
    

    需要在 arquillian.xml 中提及新的 managementPort,但不需要提及 HTTP 端口。我认为这同样适用于 JMS 端口等。

    上面的配置假定默认的managementPort9990,但我也看到过909999 的帖子(可能是较旧的WildFly 版本,这是WildFly 9.0.1.Final)。实际使用的 managementPort 显示在 WildFly 启动期间的日志中。

    【讨论】:

      【解决方案3】:

      我也遇到了这种错误,因为 arquillian 无法使用 runnung Web 容器,因为它已经在运行。 因此,您只需使用这一行在 src/test/resources 中为“arquillian.xml”添加一个属性

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

      【讨论】:

        猜你喜欢
        • 2014-08-28
        • 2016-09-27
        • 1970-01-01
        • 1970-01-01
        • 2018-01-16
        • 1970-01-01
        • 1970-01-01
        • 2023-03-14
        • 2017-08-07
        相关资源
        最近更新 更多