Skip to content
Advertisement

Intellij Junit causes java.lang.SecurityException: Invalid signature file digest for Manifest main attributes

I am trying to integrate sendgrid into one of our repo’s that handles emails. But my Junit tests keep throwing the mentioned Exception. I’ve skimmed through most of the posts on here talking about running the jar and issues around cglib and I do have the latest Mockito-all (1.10.19) pulled down. I’m able to build the jar and get it to run after excluding the signature files but my question is how do I get the Junit to work??

Basically all I’m doing is trying to mock the SendGrid class.

private SendGrid mockApiClient = Mockito.mock(SendGrid.class);

Here’s how I’ve included it in the project: (yes thats ivy)

<dependency org="com.sendgrid" name="sendgrid-java" rev="4.6.5" conf="uber-jar->default"/>

The stacktrace of the exception thrown is as follows:

java.lang.SecurityException: Invalid signature file digest for Manifest main attributes

    at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:330)
    at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:263)
    at java.util.jar.JarVerifier.processEntry(JarVerifier.java:318)
    at java.util.jar.JarVerifier.update(JarVerifier.java:230)
    at java.util.jar.JarFile.initializeVerifier(JarFile.java:383)
    at java.util.jar.JarFile.ensureInitialization(JarFile.java:617)
    at java.util.jar.JavaUtilJarAccessImpl.ensureInitialization(JavaUtilJarAccessImpl.java:69)
    at sun.misc.URLClassPath$JarLoader$2.getManifest(URLClassPath.java:991)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:451)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2611)
    at java.lang.Class.getDeclaredFields(Class.java:1944)
    at org.junit.runners.model.TestClass.<init>(TestClass.java:49)
    at org.junit.runners.ParentRunner.<init>(ParentRunner.java:75)
    at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:57)
    at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Advertisement

Answer

This was occurring because I had a fat jar downloaded from a while back. When I removed that, cleared my cache and re-pulled everything I was able to get a jar which did not have those signature files.

Everything now works

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement