gpt4 book ai didi

java - Arquillian Chameleon 容器与 Java 11

转载 作者:行者123 更新时间:2023-12-01 14:28:15 25 4
gpt4 key购买 nike

我们在 Java 11.0.2 (OpenJDK 11) 环境中使用 Chameleon-Container 和 Wildfly 14 启动 Arquillian-Test 时遇到以下问题。我们使用 maven 作为构建工具。

开始测试后,它因以下错误而停止:

[INFO] --- maven-surefire-plugin:2.22.0:test (default-test) @ arquillian-tutorial ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running de.evodion.arquillian.example.GreeterTest
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.581 s <<< FAILURE! - in de.evodion.arquillian.example.GreeterTest
[ERROR] de.evodion.arquillian.example.GreeterTest Time elapsed: 1.579 s <<< ERROR!
java.lang.NoClassDefFoundError: java/sql/Date
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
Caused by: java.lang.ClassNotFoundException: java.sql.Date
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)

在 Java 8 环境中,该设置有效。我们已经将 surefire 插件版本从 3.0.0M3 改回 2.22.0,因为这个插件版本会导致同样的错误。

用于测试此行为的最小 pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.evodion.arquillian.example</groupId>
<artifactId>arquillian-tutorial</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>arquillian-tutorial</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.org.wildfly>14.0.1.Final</version.org.wildfly>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<reuseForks>false</reuseForks>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<jboss.home>${project.build.directory}\wildfly-${version.org.wildfly}</jboss.home>
<module.path>${project.build.directory}\wildfly-${version.org.wildfly}\modules</module.path>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.4.1.Final</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-7.0</artifactId>
<version>1.1.1.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.4.1.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.arquillian.container</groupId>
<artifactId>arquillian-chameleon-junit-container-starter</artifactId>
<version>1.0.0.CR5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
<version>2.1.8.Final</version>
<scope>test</scope>
</dependency>
</dependencies>

与变色龙容器一起使用的 arquillian xml:

<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="chameleon" default="true">
<configuration>
<property name="javaVmArguments">--add-modules java.se</property>
<property name="chameleonTarget">wildfly:14.0.1.Final:managed</property>
<property name="serverConfig">standalone-full.xml</property>
</configuration>
</container>

</arquillian>

我们尝试在 arquillian.xml 文件中使用 wildfly 16,但这会导致同样的错误。我们还尝试使用"new"junit 4.13-beta-2,同样的错误。我们尝试使用 java 11.0.1(OpenJDK) 和候选版本 java 12 (OpenJDK)。在 arquillian.xml 文件中,我们尝试使用

添加 sql 模块
<property name="javaVmArguments">--add-modules java.se,java.sql</property>

仍然没有改善。

最佳答案

遇到同样的问题。据我所知,Arquillian Chameleon 仍然无法在 Java 11(仅 Java 8)上运行。

关于java - Arquillian Chameleon 容器与 Java 11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55117589/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com