1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WildFly 15.0.1.Finalに合わせて WildFly アーキタイプの POM.xml を編集しました

Last updated at Posted at 2019-04-18

WildFly を使って Java EE アプリケーションを作成する際に、WildFly の Maven アーキタイプ を使用される方が多いかと思います。

ですが、このアーキタイプが 8.2.0.Final で 2015 年 1 月から更新されておらず、WildFly 15.0.1.Final で Arquillian を動作させると、例外が発生してうまくいきません。

そこで、8.2.0.Final で作成したサンプルプロジェクトを WildFly の Maven BOM を参照しながら 15.0.1.Final で Arquillian の単体テストが動作するように POM.xml 内の記載を以下のように編集しました(修正した部分のみ記載します)。

<properties>
    <!-- Define the version of the JBoss BOMs we want to import to specify 
        tested stacks. -->
    <version.jboss.bom>15.0.1.Final</version.jboss.bom>

    <!-- maven-compiler-plugin -->
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
</properties>
<dependencyManagement>
    <dependencies>
      <dependency>
          <groupId>org.wildfly.bom</groupId>
          <artifactId>wildfly-javaee8</artifactId>
          <version>${version.jboss.bom}</version>
          <type>pom</type>
          <scope>import</scope>
      </dependency>
      <dependency>
          <groupId>org.wildfly.bom</groupId>
          <artifactId>wildfly-javaee8-with-tools</artifactId>
          <version>${version.jboss.bom}</version>
          <type>pom</type>
          <scope>import</scope>
      </dependency>
      <dependency>
          <groupId>org.wildfly.bom</groupId>
          <artifactId>wildfly-client</artifactId>
          <version>${version.jboss.bom}</version>
          <type>pom</type>
          <scope>import</scope>
      </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>
  <dependency>
      <groupId>javax.enterprise</groupId>
      <artifactId>cdi-api</artifactId>
      <scope>provided</scope>
  </dependency>
  <dependency>
      <groupId>org.jboss.spec.javax.ejb</groupId>
      <artifactId>jboss-ejb-api_3.2_spec</artifactId>
      <scope>provided</scope>
  </dependency>
  <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-jpamodelgen</artifactId>
      <scope>provided</scope>
  </dependency>
    
  <dependency>
    <groupId>org.jboss.spec.javax.annotation</groupId>
    <artifactId>jboss-annotations-api_1.3_spec</artifactId>
    <scope>provided</scope>
  </dependency>
  <dependency>
    <groupId>org.jboss.spec.javax.faces</groupId>
    <artifactId>jboss-jsf-api_2.3_spec</artifactId>
    <scope>provided</scope>
  </dependency>
  <dependency>
    <groupId>org.jboss.spec.javax.ws.rs</groupId>
    <artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
    <scope>provided</scope>
  </dependency>
  <dependency>
    <groupId>org.hibernate.validator</groupId>
    <artifactId>hibernate-validator</artifactId>
    <scope>provided</scope>
  </dependency>
  <dependency>
    <groupId>org.hibernate.validator</groupId>
    <artifactId>hibernate-validator-annotation-processor</artifactId>
    <scope>provided</scope>
  </dependency>
  <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <scope>provided</scope>
  </dependency>
  <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
  </dependency>
  <dependency>
      <groupId>org.jboss.arquillian.junit</groupId>
      <artifactId>arquillian-junit-container</artifactId>
      <scope>test</scope>
  </dependency>
  <dependency>
      <groupId>org.jboss.arquillian.protocol</groupId>
      <artifactId>arquillian-protocol-servlet</artifactId>
      <scope>test</scope>
  </dependency>
</dependencies>
<profiles>
    <profile>
        <id>arq-wildfly-managed</id>
        <dependencies>
            <dependency>
                <groupId>org.wildfly.arquillian</groupId>
                <artifactId>wildfly-arquillian-container-managed</artifactId>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </profile>
    <profile>
        <id>arq-wildfly-remote</id>
        <dependencies>
            <dependency>
                <groupId>org.wildfly.arquillian</groupId>
                <artifactId>wildfly-arquillian-container-remote</artifactId>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </profile>
</profiles>

profile の groupId を org.wildfly から org.wildfly.arquillian に変更する必要がありました。
あとは、src/test/resources 内の arquillian.xml で jbossHome のプロパティ値をご自身の WildFly 15.0.1.Final が展開されているディレクトリパスに設定すれば、動作します。

ご参考まで。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?