在使用測試參數啓動maven時,出現上述異常。在創建集成測試部署,我得到如下:無法處理EJB類的業務接口
org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEJB0466: Failed to process business interfaces for EJB class class ..contract.ContractMockService
的有關類看起來是這樣的:
package ..integration.bestand.contract;
import java.time.LocalDate;
import java.util.ArrayList;
import javax.ejb.Local;
import javax.ejb.Stateless;
import org.apache.deltaspike.core.api.exclude.Exclude;
import org.apache.deltaspike.core.api.projectstage.ProjectStage;
...
@Exclude(ifProjectStage = {
ProjectStage.Production.class,
ProjectStage.Staging.class,
..Integration.class,
..Qs.class,
..PatchQs.class
})
@Stateless
@Local(IContractIntService.class)
public class ContractMockService implements IContractIntService {
...
return ContractBuilder.build();
}
}
接口IContractIntService
的樣子:
package ..integration.bestand.contract;
import javax.ejb.Local;
...
@Local
public interface IContractIntService {
public enum State {
SUCCESS,
UNKNOWN_ERROR,
NOT_FOUND;
// TODO: Stati für Fehler hier definieren
}
//Interface comment
Result<State, ContractDTO> retrieveContract(String contractIdentifier);
}
注:接口是在另一個項目,這是通過maven包括。
測試看起來是這樣的:
package ..api.contractregistration.service;
import static org.hamcrest.CoreMatchers.any;
import static org.hamcrest.MatcherAssert.assertThat;
import java.util.logging.Logger;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TestWatcher;
import org.junit.runner.RunWith;
import ..core.test.IntegrationTest;
@RunWith(Arquillian.class)
@Category(IntegrationTest.class)
public class ContractRegistrationIntegrationTest {
protected final Logger log = Logger.getLogger(ContractRegistrationIntegrationTest.class.getCanonicalName());
@Rule
public TestWatcher watcher = new TestWatcher() {
@Override
protected void starting(org.junit.runner.Description description) {
log.info(String.format("---> Starting test: %s", description));
}
@Override
protected void failed(Throwable e, org.junit.runner.Description description) {
log.info(String.format("<--- Test failed: %s", description));
}
@Override
protected void succeeded(org.junit.runner.Description description) {
log.info(String.format("<--- Test succeeded: %s", description));
}
};
@Deployment
public static WebArchive createDeployment() {
WebArchive result = ShrinkWrap.create(WebArchive.class)
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml")
.addPackages(true, "..ejb.portal")
.addPackages(true, "..core")
.deletePackages(true, "..core.config.deltaspike")
.addPackages(true, "..integration")
.addPackages(true, "..api")
.addPackages(true, "org.apache.deltaspike.core")
.addPackages(true, "..ejb.util");
System.out.println("########## TEST DEPLOYMENT########" + result.toString(true));
return result;
}
@Test
public void test() {
String tempPw = "bla"; // result.getDto();
assertThat(tempPw, any(String.class));
}
}
有關此測試的了不起的事情是,我還沒有使用測試裏面MockService
的東西。
Maven配置是這樣的:
目標:clean test -Parq-wildfly-managed
JRE VM參數:-Djboss.home="myLocalWildflyDirectory"
JAVA_HOME
設置爲jdk8。
最後一件事是我的POM,容器 「ARQ-wildfly管理」 的具體部分:
...
<profile>
<!-- An optional Arquillian testing profile that executes tests in your WildFly instance, e.g. for build server -->
<!-- This profile will start a new WildFly instance, and execute the test, shutting it down when done -->
<!-- Run with: mvn clean test -Parq-wildfly-managed -->
<id>arq-wildfly-managed</id>
<dependencies>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.ivi.torino</groupId>
<artifactId>torino-integration-bestand-mock-ejb</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.ivi.torino</groupId>
<artifactId>torino-integration-docservice-mock-ejb</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.ivi.torino</groupId>
<artifactId>torino-integration-bestand-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
...
正常Maven構建與clean verify package install
(包括只是沒有測試)構建成功。
注意:對於本文,我重新命名了軟件包以排除公司專業化。
類似的錯誤提示更正了ShrinkWrap部署,但我實際上包含了每個包,甚至試圖明確包含接口類。但仍然存在同樣的錯誤。
這是什麼原因造成的?
您似乎誤解了Maven的生命週期。如果你通過'mvn clean verify package install'調用maven,那麼幾件事情就是運行double或triple。你簡單需要的是:'mvn clean install'或'mvn clean verify' ..推薦閱讀https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html – khmarbaise
@khmarbaise謝謝你的建議。我可以清楚地說,我不是Maven的專家。我以前使用你提到的運行配置,他們的工作,但我的問題不是針對工作的構建。 '測試'版本正在產生上述錯誤,並讓我無能爲力...... – EngJon
也許你的IContractService由於缺少依賴關係而無法加載。您可能需要在INFO級別的org.jboss.weld.Bootstrap類別下檢查日誌,以確保所有的bean定義都已正確註冊。 – Franck