0 Replies Latest reply on Nov 15, 2015 11:53 AM by John Ament

    Class loader error when using ServerSetupTask in Arquillian test

    John Ament Master

      I was recently guided to using ServerSetupTasks in my tests to enable some functionality, specifically I wanted to undeploy an app if it was already deployed.  Since doing that, I've noticed the following classloader error when running tests.

       

      11:37:24,625 WARN  [org.jboss.modules] (Weld Thread Pool -- 1) Failed to define class com.mycompany.integrationtests.utils.UndeployIfDeployedTask in Module "deployment.myapp.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link com/mycompany/integrationtests/utils/UndeployIfDeployedTask (Module "deployment.myapp.war:main" from Service Module Loader)

        at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:437)

        at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:269)

        at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:77)

        at org.jboss.modules.Module.loadModuleClass(Module.java:560)

        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:197)

        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)

        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)

        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)

        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:130)

        at org.jboss.as.weld.WeldModuleResourceLoader.classForName(WeldModuleResourceLoader.java:68)

        at org.jboss.weld.bootstrap.AnnotatedTypeLoader.loadClass(AnnotatedTypeLoader.java:65)

        at org.jboss.weld.bootstrap.AnnotatedTypeLoader.loadAnnotatedType(AnnotatedTypeLoader.java:60)

        at org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.loadAnnotatedType(FastAnnotatedTypeLoader.java:92)

        at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:97)

        at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:65)

        at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:62)

        at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)

        at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)

        at java.util.concurrent.FutureTask.run(FutureTask.java:266)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

        at java.lang.Thread.run(Thread.java:745)

        at org.jboss.threads.JBossThread.run(JBossThread.java:320)

      Caused by: java.lang.NoClassDefFoundError: org/jboss/as/arquillian/api/ServerSetupTask

        at java.lang.ClassLoader.defineClass1(Native Method)

        at java.lang.ClassLoader.defineClass(ClassLoader.java:760)

        at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:353)

        at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:432)

        ... 22 more

      Caused by: java.lang.ClassNotFoundException: org.jboss.as.arquillian.api.ServerSetupTask from [Module "deployment.myapp.war:main" from Service Module Loader]

        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)

        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)

        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)

        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)

        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:130)

        ... 26 more

       

      It seems that its complaining because the underlying dependencies of the task aren't found.  This makes sense since the task should only be executed client side, before deployment.  It doesn't need to exist on the server.  However, the configuration of it doesn't match that use case.  It seems that based on this approach, it may make more sense for server setup tasks to be configured in arquillian.xml or equivalent, instead of on the test runner.