5 Replies Latest reply on Oct 8, 2009 11:56 AM by 791266

    SecurityException from junit.framework.JUnit4TestAdapter

      Hi all,
      I have a small code using JUnit 4.4. I get the following error when I run the code. Any idea? Any help is greatly appreciated.
      java.lang.SecurityException: class "junit.framework.JUnit4TestAdapter"'s signer information does not match signer information of other classes in the same package
           at java.lang.ClassLoader.checkCerts(Unknown Source)
           at java.lang.ClassLoader.preDefineClass(Unknown Source)
           at java.lang.ClassLoader.defineClass(Unknown Source)
      My code:
      import static org.junit.Assert.assertTrue;
      import junit.framework.JUnit4TestAdapter;
      import org.junit.Before;
      import org.junit.Test;
      public class MyClass {
           private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(MyClass.class);
           public void setUp() throws Exception {
                System.setProperty("FILENAME", qUnitTestConstants.EnvFile);
           @Test public void success(){
                String name = "name";
           public static junit.framework.Test suite() {
                return new JUnit4TestAdapter(MyClass.class);
        • 1. Re: SecurityException from junit.framework.JUnit4TestAdapter
          Regardless of any code you might have, that error message is saying that the class junit.framework.JUnit4TestAdapter was loaded from a different jar than earlier JUnit classes. And the original JUnit jar was sealed, so loading subsequent JUnit classes from a different jar indicates possible interference with the product.
          • 2. Re: SecurityException from junit.framework.JUnit4TestAdapter
            Could someone perhaps give any help on how to resolve this problem?

            The error I'm getting is:
            class "junit.framework.JUnit4TestAdapter"'s signer information does not match signer information of other classes in the same package

            I searched and found two junit jars on my computer. I tried both, but both result in this error. I have cleaned the project and built it again, but nothing helps. BTW, I get this error when I run an ant file in an effort to build html output of my junit tests.

            Any help would be greatly appreciated because I'm now getting desperate to get these files generated.

            Edited by: jakkals on Apr 16, 2008 1:52 AM

            Edited by: jakkals on Apr 16, 2008 2:16 AM
            • 3. Re: SecurityException from junit.framework.JUnit4TestAdapter
              I got this error also when running a JUnit4 test inside eclipse (3.3). It turned out I had the JUnit3 jar in the classpath and not the JUnit4 jar.

              In eclipse, I added a 'library' to the Classpath tab on the run configuration for the JUnit test and selected Junit and then Junit4. The jar it added to the classpath was \eclipse\plugins\org.junit4_4.3.1\junit.jar
              • 4. Re: SecurityException from junit.framework.JUnit4TestAdapter
                I got the same error with eclipse. The problem was that besides the junit4 library, which was added to the project I started the test from, there are other projects this one depends on which have the junit3 library in their classpath. Although these projects do not export the junit3 library it was included in the classpath in the run configurations (not in the build path of the project though). I deleted all user entries from the run configurations of the test class and added explicitly only those things required. Also the project the test class is contained in needs to be added, BUT "add required projects ...." needs to be OFF.
                • 5. Re: SecurityException from junit.framework.JUnit4TestAdapter


                  Please, don't resurrect old threads. I'm locking this.