9 Replies Latest reply: Oct 28, 2011 7:20 AM by Ramesh Reddy RSS

ClassNotFoundException when running test

Pablo Ochoa Newbie

Hello, I'm trying to test some services using Arquillian, however when running them on a managed mode I got the following exception:

 

java.lang.NoClassDefFoundError: org/jboss/arquillian/container/spi/client/protocol/metadata/JMXContext

 

Do I need additional dependencies when testing to avoid this?. This is my pom.xml profile:

 

<profiles>

      <profile>

         <!-- An optional Arquillian testing profile that executes tests

            in your JBoss AS instance -->

         <!-- This profile will start a new JBoss AS instance, and execute the

              test, shutting it down when done -->

         <!-- Run with: mvn clean test -Parq-jbossas-managed -->

         <id>arq-jbossas-managed</id>

          <dependencies>

             <dependency>

               <groupId>org.jboss.as</groupId>

               <artifactId>jboss-as-arquillian-container-managed</artifactId>

               <version>7.0.1.Final</version>

               <scope>test</scope>

            </dependency>

          

           

          </dependencies>

      </profile>

     

       <profile>

         <!-- An optional Arquillian testing profile that executes tests

            in a remote JBoss AS instance -->

         <!-- Run with: mvn clean test -Parq-jbossas-remote -->

         <id>arq-jbossas-remote</id>

         <dependencies>

            <dependency>

               <groupId>org.jboss.as</groupId>

               <artifactId>jboss-as-arquillian-container-remote</artifactId>

               <version>7.0.0.CR1</version>

               <scope>test</scope>

            </dependency>

         </dependencies>

      </profile>

     

   </profiles>

  • 1. Re: ClassNotFoundException when running test
    Aslak Knutsen Master

    You have a older v. of Arquillian Core, use 1.0.0.CR5

  • 2. Re: ClassNotFoundException when running test
    Pablo Ochoa Newbie

    Thanks a lot, I was using 1.0.0.CR1, It worked now, however I got and Exception related to deserialization.

    I'm testing specifically an EJB.

     

    @RunWith(Arquillian.class)

    public class UsuarioServiceTest {

        @Deployment

        public static JavaArchive createTestArchive(){

            return ShrinkWrap.create(JavaArchive.class,"test.jar").

                    addClasses(UsuarioService.class,UsuarioServiceImpl.class,

                               GenericService.class,GenericServiceImpl.class,

                               GenericDao.class,GenericDaoImpl.class,

                               UsuarioDAO.class,UsuarioDAOImpl.class,

                               EntityNotDeletedException.class,

                               EntityNotSavedException.class).

                               addAsManifestResource("test-persistence.xml",

                                                         ArchivePaths.create("persistence.xml"));

           

        }

       

        @EJB

        private UsuarioService usuarioService;

       

        @Test

        public void testEJBInjection(){

            String test="StringPrueba";

            Assert.assertNotNull(usuarioService);

            Assert.assertEquals(test, usuarioService.getTestData());

        }

    }

     

    UsuarioService is a @Local interface, and UsuarioServiceImpl an @Stateless EJB, but when the code reaches the NotNull Assert, I got the following exception:

     

    java.lang.RuntimeException: Could not deserialize object: [B@12e7c6a

    Caused by: java.io.InvalidClassException: org.jboss.arquillian.test.spi.ExceptionProxy; Serializable incompatible with Externalizable

     

    Sorry If these are obvious questions, however I'm just starting using Arquillian.

    Thanks a lot.

  • 3. Re: ClassNotFoundException when running test
    Aslak Knutsen Master

    hmm, that sounds like a bug.

     

    Could file a jira https://issues.jboss.org/browse/ARQ and provide a test project that expose it ?

  • 4. Re: ClassNotFoundException when running test
    Aslak Knutsen Master

    on second note.. i see in your poim that you use 7.0.1.Final for the Managed contianer and 7.0.0.Final for the Remote.

     

    Which profile are you running and which version of the JBoss AS are you running against?

  • 5. Re: ClassNotFoundException when running test
    Pablo Ochoa Newbie

    I'm using the managed profile.

     

    mvn clean test -Parq-jbossas-managed

     

    And just in case this is the complete stack trace of the Exception:

     

    Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 9.142 sec <<< FAILURE!

    testEJBInjection(src.test.java.ec.com.uniseguros.service.test.UsuarioServiceTest)  Time elapsed: 0.452 sec  <<< ERROR!

    java.lang.RuntimeException: Could not deserialize object: [B@187b287

        at org.jboss.arquillian.protocol.jmx.Serializer.toObject(Serializer.java:52)

        at org.jboss.arquillian.protocol.jmx.JMXMethodExecutor.invoke(JMXMethodExecutor.java:69)

        at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:120)

        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.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

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

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

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

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

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

        at org.jboss.arquillian.container.test.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:57)

        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.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

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

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

        at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:130)

        at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createTestContext(ContainerEventController.java:117)

        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.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

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

        at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:82)

        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.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

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

        at org.jboss.arquillian.test.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.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

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

        at org.jboss.arquillian.test.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.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

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

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

        at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111)

        at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:239)

        at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:202)

        at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:290)

        at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:45)

        at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:216)

        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)

        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)

        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)

        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)

        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)

        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)

        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)

        at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:161)

        at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:290)

        at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:45)

        at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:175)

        at org.junit.runners.ParentRunner.run(ParentRunner.java:236)

        at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:123)

        at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35)

        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:115)

        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97)

        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.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)

        at $Proxy0.invoke(Unknown Source)

        at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)

        at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)

        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)

    Caused by: java.io.InvalidClassException: org.jboss.arquillian.test.spi.ExceptionProxy; Serializable incompatible with Externalizable

        at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:579)

        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582)

        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)

        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)

        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)

        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)

        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)

        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)

        at org.jboss.arquillian.protocol.jmx.Serializer.toObject(Serializer.java:48)

        ... 81 more

  • 6. Re: ClassNotFoundException when running test
    Aslak Knutsen Master

    na, not sure. file a bug with a test project..

  • 7. Re: ClassNotFoundException when running test
    Dejan Kitic Newbie

    I have just stumbled into same problem with arquillian CR5 and Jboss 7.0.2, was a bug filed for this/any solution to this issue?

    Cheers,

    D

  • 8. Re: ClassNotFoundException when running test
    Aslak Knutsen Master

    not that i know. Please file on with a example project.

  • 9. Re: ClassNotFoundException when running test
    Ramesh Reddy Master

    I got the same exception, but I was using the bean class as inner class, once I moved it out, the exception went away

     

    Ramesh..