2

I have to Arquillian test unit in my application and each one has its own Deployment method:

@RunWith(Arquillian.class)
public class CallerTest {
    @EJB
    private CallerPrincipalDemoSessionBean sut;

    @Deployment
    public static WebArchive createTestArchive1() {
        WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test1.war")
                .addClasses(JBossLoginContextFactory.class, CallerPrincipalDemoSessionBean.class)
                .addAsWebInfResource("META-INF/ejb-jar.xml")
                .addAsWebInfResource("META-INF/jboss-ejb3.xml")
                .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
                .addAsResource("users.properties")
                .addAsResource("roles.properties");
        return webArchive;
    }

    ...

and second one:

@RunWith(Arquillian.class)
public class UsersTest {

    @ArquillianResource
    private URL serverUrl;

    @Deployment(testable = false)
    public static Archive createTestArchive2() {
        return ShrinkWrap.create(WebArchive.class, "test2.war")
                .addPackage(User.class.getPackage())
                .addPackage(UserFacade.class.getPackage())
                .addPackage(Users.class.getPackage())
                .addPackage(Credential.class.getPackage())
                .addAsResource("test-persistence.xml", "META-INF/persistence.xml")
                .setWebXML(new File("src/test/resources/test-web.xml"))
                .addAsWebInfResource("META-INF/jboss-web.xml")
                .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
                .addAsResource("users.properties")
                .addAsResource("roles.properties");
    }

    ...

When I remove one of the classes or comment one of "@Deployment" methods mvn test works perfect. But with 2 "@Deployment" method even testing single class with mvn test -Dtest=com.wpic.tmall.rest.UsersTest raise an exception:

ERROR [org.jboss.msc.service.fail] MSC000001: Failed to start service jboss.deployment.unit."test2.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."test2.war".WeldStartService: Failed to start service
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.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: org.jboss.weld.exceptions.DeploymentException: org/jboss/shrinkwrap/api/asset/Asset
    at org.jboss.weld.executor.AbstractExecutorServices.checkForExceptions(AbstractExecutorServices.java:66)
    at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:43)
    at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:51)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer.createClassBeans(ConcurrentBeanDeployer.java:72)
    at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:260)
    at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:351)
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:79)
    at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:92)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    ... 3 more
Caused by: java.lang.NoClassDefFoundError: org/jboss/shrinkwrap/api/asset/Asset
    at java.lang.Class.getDeclaredMethods0(Native Method) [rt.jar:1.8.0_05]
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2688) [rt.jar:1.8.0_05]
    at java.lang.Class.getDeclaredMethods(Class.java:1962) [rt.jar:1.8.0_05]
    at java.lang.Class.getEnclosingMethod(Class.java:1032) [rt.jar:1.8.0_05]
    at org.jboss.weld.util.reflection.Reflections.isNonStaticInnerClass(Reflections.java:388)
    at org.jboss.weld.util.Beans.isTypeManagedBeanOrDecoratorOrInterceptor(Beans.java:486)
    at org.jboss.weld.bootstrap.BeanDeployer.createClassBean(BeanDeployer.java:233)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$2.doWork(ConcurrentBeanDeployer.java:74)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$2.doWork(ConcurrentBeanDeployer.java:72)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_05]
    ... 3 more
Caused by: java.lang.ClassNotFoundException: org.jboss.shrinkwrap.api.asset.Asset from [Module "deployment.test2.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules-1.3.3.Final.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules-1.3.3.Final.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules-1.3.3.Final.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules-1.3.3.Final.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules-1.3.3.Final.jar:1.3.3.Final]
    ... 15 more

I'm using wildfly-arquillian-container-embedded version 8.1.0.Final for container.

user1079877
  • 9,008
  • 4
  • 43
  • 54

1 Answers1

1

Don't have any solutions, but have some small advices:

  • Your best bet is to ignore your IDE for a minute when looking at Arquillian. So firstly: make sure you're launching your tests with maven (not from IDE)
  • Be careful about embedded containers. If I were You, I would switch to the remote or managed container as they are more reliable. And former doesn't incur any startup overhead (of course once it was started)
  • Are you aware of differences between @Deployment(testable = false) and (testable = true)?
  • Make sure you are not missing any needed classes inside your deployment archive. To make it true I like recursive addition via .addPackages(true, "com.company.your_module")
  • If nothing helps then you may try a different remote containers like: JBoss AS 7.1.1, Wildfly 8.0.0

ps. this question looks similar to yours.

Hope it helps a little bit

Community
  • 1
  • 1
G. Demecki
  • 10,145
  • 3
  • 58
  • 58
  • Thanks, but I'm using maven not IDE also I'm using embedded containers because It's possible to run the test with CI tools like "travis-ci.org" (I also have some other remote profile for fast testing). – user1079877 Dec 20 '14 at 18:00
  • Also, I've tested, Arquillian test is really slow, because deployment is slow. Managed test will takes 17 seconds and remote test takes 16 seconds, so there's no need to I setup wildfly and do the configurations just for 1 second. – user1079877 Dec 22 '14 at 06:54
  • @user1079877 but does your measurement also include startup time? If yes, don't count this factor, as with remote it is once per all tests. But time isn't the most important here - I've recommended you `remote/managed` container due to reliability and stability. – G. Demecki Dec 30 '14 at 13:33