How to test an EJB with the following structure: EAR + WAR + JAR's?
juliocspires May 30, 2014 4:06 PMHi,
I have the following project structure:
EAR
- WAR
- EJB (JAR) --- Test Here
- Persistence (JAR)
- Entities (JAR)
I want to test the Beans present in EJB (JAR), but I've tried different ways with ShrinkWrap and none worked.
Questions that I have:
1) What is the standard structure for testing the EJB (JAR) (knowing that it depends only on others JAR's, not WAR/EAR) ?
2) What should I use: JavaArchive, WebArchive or EnterpriseArchive?
Scenario:
- JDK 1.8.0_05
- Wildfly-8.0.0.Final
- Arquillian 1.1.4.Final
- Shrinkwrap 2.2.0-alpha-2
@Deployment public static Archive<?> getDeployment() { //Load ALL dependencies File[] files = Maven.configureResolver() .workOffline() .withMavenCentralRepo(false) .withClassPathResolution(true) .loadPomFromFile("pom.xml") .importDependencies(ScopeType.PROVIDED, ScopeType.TEST, ScopeType.RUNTIME, ScopeType.COMPILE) .resolve().withTransitivity().asFile();
//Create EJB JavaArchive ejb = ShrinkWrap.create(JavaArchive.class, "ejb.jar"); ejb.addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml")); //ADD ALL dependencies in EJB (is that correct??) for (File file : files) { ejb.addAsResource(file); } return ejb; }
ERROR:
1A) Why test.war? I'm testing an EJB that has no relationship with .WAR
1B) Caused by: java.util.ServiceConfigurationError: javax.servlet.ServletContainerInitializer: Provider com.sun.faces.config.FacesInitializer not found
Why an error of JSF / Faces?
ERROR [org.jboss.msc.service.fail] MSC000001: Failed to start service jboss.deployment.unit."test.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."test.war".INSTALL: JBAS018733: Failed to process phase INSTALL of deployment "test.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_05]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_05]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_05]
Caused by: java.util.ServiceConfigurationError: javax.servlet.ServletContainerInitializer: Provider com.sun.faces.config.FacesInitializer not found
at java.util.ServiceLoader.fail(ServiceLoader.java:239) [rt.jar:1.8.0_05]
at java.util.ServiceLoader.access$300(ServiceLoader.java:185) [rt.jar:1.8.0_05]
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:372) [rt.jar:1.8.0_05]
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) [rt.jar:1.8.0_05]
at java.util.ServiceLoader$1.next(ServiceLoader.java:480) [rt.jar:1.8.0_05]
at org.wildfly.extension.undertow.deployment.ServletContainerInitializerDeploymentProcessor.deploy(ServletContainerInitializerDeploymentProcessor.java:112)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]
... 5 more