加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 无法处理EJB类的业务接口

发布时间:2020-12-15 02:14:33 所属栏目:Java 来源:网络整理
导读:在使用测试参数启动maven时,我得到了上面提到的异常.在创建集成测试部署时,我得到以下内容: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEJB0466: Failed to process business interfaces for EJB class class ..contract.Cont
在使用测试参数启动maven时,我得到了上面提到的异常.在创建集成测试部署时,我得到以下内容:

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配置如下所示:

目标:清洁测试-Parq-wildfly-managed
JRE VM参数:-Djboss.home =“myLocalWildflyDirectory”

JAVA_HOME设置为jdk8.

最后一件事是我的pom,特别是容器“arq-wildfly-managed”的一部分:

...

        <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构建与干净的验证包安装(只是没有包含测试)构建成功.

注意:对于这篇文章,我重命名了包以排除公司专业化.

类似的错误建议纠正ShrinkWrap部署,但我实际上包含了每个包,甚至尝试明确包含接口类.但仍然存在同样的错误.

什么可能导致这个?

解决方法

在Test(ShrinkWrap)中试试这个:

.addAsResource(new StringAsset("org.apache.deltaspike.ProjectStage=IntegrationTest"),"META-INF/apache-deltaspike.properties")

并将您的排除更改为:

@Exclude(exceptIfProjectStage = ProjectStage.IntegrationTest.class)

如果您需要排除其他阶段,请将它们添加到此非常排除的语句中

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读