4 Replies Latest reply on Mar 31, 2011 7:59 AM by Aslak Knutsen

    Does Arquillian work with TestNG 6?  getting java.lang.ClassNotFoundException: com.google.inject.Inject

    Steven Boscarine Apprentice

      Hello All,

      I am trying to get Arquillian working with a new project & can't seem to get it running with TestNG 6.0.  Am I missing something?

       

      I get java.lang.NoClassDefFoundError: com/google/inject/Inject

       

      Whose dependency is the Google Inject class?  Is it being used by TestNG or Arquillian/Shrinkwrap ?  I noticed TestNG 5.14 imports Guice, but 6 doesn't. 

       

      Out of curiosity, what is Guice doing?  I noticed my simple test passes if I import it.  However, since I am deviating from the official examples, I am just trying to get a sense for what kind of trouble I am getting myself into.

       

      Here's my POM config (pulled from the example in the Arquillian source code):

       

            <dependency>

               <groupId>org.glassfish.extras</groupId>

               <artifactId>glassfish-embedded-all</artifactId>

               <version>3.1</version>

               <scope>provided</scope>

            </dependency>

            <dependency>

               <groupId>org.jboss.arquillian</groupId>

               <artifactId>arquillian-testng</artifactId>

               <version>1.0.0.Alpha5</version>

               <scope>test</scope>

            </dependency>

            <dependency>

               <groupId>org.jboss.arquillian.container</groupId>

               <artifactId>arquillian-glassfish-embedded-3.1</artifactId>

               <version>1.0.0.Alpha5</version>

               <scope>test</scope>

            </dependency>

       

            <!-- fails -->

            <dependency>

               <artifactId>testng</artifactId>

               <groupId>org.testng</groupId>

               <version>6.0.1</version>

               <scope>test</scope>

            </dependency>

       

            <!-- works -->

            <dependency>

               <artifactId>testng</artifactId>

               <groupId>org.testng</groupId>

               <version>5.14</version>

               <scope>test</scope>

            </dependency>

       

            <!-- This combination also works -->

            <dependency>

               <artifactId>testng</artifactId>

               <groupId>org.testng</groupId>

               <version>6.0.1</version>

               <scope>test</scope>

            </dependency>

            <dependency>

               <groupId>com.google.inject</groupId>

               <artifactId>guice</artifactId>

               <version>2.0</version>

               <scope>test</scope>

            </dependency>

       

       

      My test (built from the jboss Java EE 6 archetypes):

       

      @Test(enabled = true)

      public class BasicArquillianTest extends Arquillian {

          //I added log4j as a dependency.

          private final Logger logger = LogManager.getLogger(getClass());

       

          @Deployment

          public static Archive<?> createTestArchive() {

              return ShrinkWrap.create(WebArchive.class, "test.war")

                      .addClasses(Member.class, MemberRegistration.class, MemberRepositoryProducer.class)

                      .addAsManifestResource("test-persistence.xml", "persistence.xml")

                      .addAsWebResource(EmptyAsset.INSTANCE, "beans.xml");

          }

       

          public void test() {

              System.out.println("hello world");

              logger.debug("hola mundo");

          }

      }

       

      Thanks,
      Steven

       

      Stacktrace:

      Mar 30, 2011 4:01:46 PM org.jboss.arquillian.impl.client.container.ContainerRegistryCreator getActivatedConfiguration

      INFO: Could not read active container configuration: null

      Mar 30, 2011 4:01:47 PM com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl findDerbyClient

      INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default.

      Mar 30, 2011 4:01:47 PM org.hibernate.validator.util.Version <clinit>

      INFO: Hibernate Validator null

      Mar 30, 2011 4:01:47 PM org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA

      INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.

      Mar 30, 2011 4:01:48 PM com.sun.enterprise.v3.services.impl.GrizzlyService createNetworkProxy

      INFO: Network listener https-listener on port 0 disabled per domain.xml

      Mar 30, 2011 4:01:48 PM com.sun.enterprise.v3.server.AppServerStartup run

      INFO: GlassFish Server Open Source Edition 3.1 (java_re-private) startup time : Embedded (680ms), startup services(402ms), total(1,082ms)

      Mar 30, 2011 4:01:48 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy$2$1 onReady

      INFO: Grizzly Framework 1.9.31 started in: 108ms - bound to [0.0.0.0:8181]

      Mar 30, 2011 4:01:48 PM org.glassfish.admin.mbeanserver.JMXStartupService$JMXConnectorsStarterThread run

      INFO: JMXStartupService: JMXConnector system is disabled, skipping.

      FAILED CONFIGURATION: @BeforeClass arquillianBeforeClass

      java.lang.NoClassDefFoundError: com/google/inject/Inject

          at org.jboss.arquillian.testng.TestNGDeploymentAppender.createAuxiliaryArchive(TestNGDeploymentAppender.java:55)

          at org.jboss.arquillian.impl.client.deployment.DeploymentGenerator.loadAuxiliaryArchives(DeploymentGenerator.java:194)

          at org.jboss.arquillian.impl.client.deployment.DeploymentGenerator.buildTestableDeployments(DeploymentGenerator.java:138)

          at org.jboss.arquillian.impl.client.deployment.DeploymentGenerator.createTestableDeployments(DeploymentGenerator.java:126)

          at org.jboss.arquillian.impl.client.deployment.DeploymentGenerator.generateDeployment(DeploymentGenerator.java:78)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.arquillian.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)

          at org.jboss.arquillian.impl.core.EventContextImpl.invokeObservers(EventContextImpl.java:98)

          at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:80)

          at org.jboss.arquillian.impl.core.ManagerImpl.fire(ManagerImpl.java:126)

          at org.jboss.arquillian.impl.core.ManagerImpl.fire(ManagerImpl.java:106)

          at org.jboss.arquillian.impl.core.EventImpl.fire(EventImpl.java:67)

          at org.jboss.arquillian.impl.client.ContainerEventController.execute(ContainerEventController.java:68)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.arquillian.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)

          at org.jboss.arquillian.impl.core.EventContextImpl.invokeObservers(EventContextImpl.java:98)

          at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:80)

          at org.jboss.arquillian.impl.TestContextHandler.createClassContext(TestContextHandler.java:68)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.arquillian.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)

          at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:87)

          at org.jboss.arquillian.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:54)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.arquillian.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)

          at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:87)

          at org.jboss.arquillian.impl.core.ManagerImpl.fire(ManagerImpl.java:126)

          at org.jboss.arquillian.impl.core.ManagerImpl.fire(ManagerImpl.java:106)

          at org.jboss.arquillian.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:70)

          at org.jboss.arquillian.testng.Arquillian.arquillianBeforeClass(Arquillian.java:76)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:76)

          at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)

          at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)

          at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:130)

          at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:173)

          at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)

          at org.testng.TestRunner.runWorkers(TestRunner.java:1147)

          at org.testng.TestRunner.privateRun(TestRunner.java:749)

          at org.testng.TestRunner.run(TestRunner.java:600)

          at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)

          at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)

          at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)

          at org.testng.SuiteRunner.run(SuiteRunner.java:223)

          at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)

          at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)

          at org.testng.TestNG.runSuitesSequentially(TestNG.java:1039)

          at org.testng.TestNG.runSuitesLocally(TestNG.java:964)

          at org.testng.TestNG.run(TestNG.java:900)

          at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)

          at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)

          at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)

      Caused by: java.lang.ClassNotFoundException: com.google.inject.Inject

          at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

          at java.security.AccessController.doPrivileged(Native Method)

          at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

          at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

          at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

          ... 66 more