3 Replies Latest reply on Jun 22, 2007 1:20 PM by Ning Zhao

    [TestNG] IncompatibleClassChangeError

    Ning Zhao Apprentice

      I set up the project using seam-gen (1.3.0 Alpha), wrote a very simple test class which extends SeamTest. When I typed "ant test" in a shell, seams that my test class was found. But I got the error output like below and all the tests in the test class were skipped:

      java.lang.IncompatibleClassChangeError: Implementing class
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
      at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
      at org.jboss.seam.deployment.ComponentScanner.handleItem(ComponentScanner.java:59)
      at org.jboss.seam.deployment.Scanner.handleDirectory(Scanner.java:161)
      at org.jboss.seam.deployment.Scanner.handleDirectory(Scanner.java:157)
      at org.jboss.seam.deployment.Scanner.handleDirectory(Scanner.java:157)
      at org.jboss.seam.deployment.Scanner.handleDirectory(Scanner.java:157)
      at org.jboss.seam.deployment.Scanner.handleDirectory(Scanner.java:157)
      at org.jboss.seam.deployment.Scanner.scan(Scanner.java:114)
      at org.jboss.seam.deployment.ComponentScanner.getClasses(ComponentScanner.java:39)
      at org.jboss.seam.init.Initialization.scanForComponents(Initialization.java:616)
      at org.jboss.seam.init.Initialization.init(Initialization.java:486)
      at org.jboss.seam.mock.BaseSeamTest.init(BaseSeamTest.java:843)
      at org.jboss.seam.mock.SeamTest.init(SeamTest.java:39)
      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.MethodHelper.invokeMethod(MethodHelper.java:529)
      at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:311)
      at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:149)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:77)
      at org.testng.TestRunner.privateRun(TestRunner.java:614)
      at org.testng.TestRunner.run(TestRunner.java:505)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:221)
      at org.testng.SuiteRunner.run(SuiteRunner.java:147)
      at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:576)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:539)
      at org.testng.TestNG.run(TestNG.java:316)
      at org.testng.TestNG.privateMain(TestNG.java:666)
      at org.testng.TestNG.main(TestNG.java:608)

      Thanks in advance for any help!

        • 1. Re: [TestNG] IncompatibleClassChangeError
          Ning Zhao Apprentice

          It seems that the embedded ejb which is needed by testng was not started correctly. I did not change the default configuration which was generated by seam-gen. How should I change it to make the embedded container work with testng? For now I'm not mocking any DB or doing integration test, but the simplest unit test could not execute...

          I tried to instantiate a stateful backing bean in the simple test class. Something like this:

          public class FooUseCaseTest extends SeamTest{

          public void testStartOver() throws Exception {
          Foo foo = new FooImpl();
          foo.startOver(); // the field bar is initialized in the startOver() method
          assert foo.bar != null;

          but did not work, error was always the same, like above. The console shows that jboss-seam.jar was found, and jars like jboss-seam-ioc, jboss-seam-remoting, etc. were also found. But I did not see any component initializing. When I was running "ant testexample" under in the seam distribution directory, I did see a lot more console output showing the embedded container was initializing....

          Could anyone please help? Thanks!


          • 2. Re: [TestNG] IncompatibleClassChangeError
            Ning Zhao Apprentice

            When the "extends SeamTest" was removed, the test class worked and the unit tests passed without any problem....But I do want to extend the SeamTest to use the inject/outject testing....Anybody has tried out?

            Thanks in advance for any help!

            • 3. Re: [TestNG] IncompatibleClassChangeError
              Ning Zhao Apprentice

              Well the problem lies in that I'm using JDK 1.6 but the seam core libs were compiled against JDK 1.5. Here is my solution:

              1. Edit the build.xml under the root directory of the Seam distribution (Let me call it $SEAM_HOME). Replace all the 1.5 with 1.6. Save the build.xml

              2. under the root of $SEAM_HOME, run

              $ ant cleanall
              $ ant build

              3. copy the newly compiled jars like jboss-seam.jar, jboss-seam-ui.jar, jboss-seam-ioc.jar....to the /lib directory under my seam project.

              My test class extending SeamTest now works like charm!

              I desparately wanted to get the test classes work because it was too frustrating that the JBoss Server OutOfMemory problem occurred very often. (This was documented in the Seam manual, but no matter how much max memory I assigned to the JVM, the server for testing would eventually crash after 5-6 times of hot redeployment). I do not want to install a JDK 5.0. I tried to recompile _my_ source code with source level 1.5 but this IncompatibleClassError did not go away. Thus came the hack above.

              The ant build log showed that a _lot_ of classes in JDK 5.0 are deprecated _and_ a lot of classes in Seam 1.2.x are deprecated too.

              I also ran the ant testall after the core rebuild. Three tests for the core package failed. These three methods are: testContextManagement, testBijectionInterceptor and textFail

              I'm using Seam 1.3.0 alpha CVS 20070614. Will the bugs in this snapshot be fixed in 1.3.0 beta or GA?