Java – unable to handle the business interface of EJB classes
When starting Maven with test parameters, I got the exception mentioned above When creating an integration test deployment, I get the following:
org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEJB0466: Failed to process business interfaces for EJB class class ..contract.ContractMockService
The attention class looks like this:
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();
}
}
The interface icontractintservice is as follows:
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);
}
Note: this interface is in another project included through Maven
The test looks like this:
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));
}
}
The remarkable feature about this test is that I didn't even use any mockservice in the test
Maven configuration is as follows:
Objective: cleaning test - PARQ wildfly managed JRE VM parameters: - djboss home =“myLocalWildflyDirectory”
JAVA_ Home is set to jdk8
The last thing is my POM, especially part of the container "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>
...
A normal Maven build and clean validation package installation (just without tests) were built successfully
Note: for this article, I renamed the package to exclude company specialization
Similar errors are recommended to correct the shrinkwrap deployment, but I actually include each package and even try to explicitly include the interface class But the same mistake still exists
What could cause this?
Solution
Try this in test (shrinkwrap):
.addAsResource(new StringAsset("org.apache.deltaspike.ProjectStage=IntegrationTest"),"Meta-INF/apache-deltaspike.properties")
And change your exclusion to:
@Exclude(exceptIfProjectStage = ProjectStage.IntegrationTest.class)
If you need to exclude other phases, add them to this very excluded statement
