0

I am building a java application as executable jar. To compile and build application I am using ANT build.

Application ran properly still I didn't included 'Mail' dependency jar files.

As per requirement I have used Java Mail API to send email notification.

To do this I have added following Mail dependency jar files:

  • mail-1.4.jar
  • activation.jar

Once I included these dependencies in my ANT build and ran the application it throws following exception:

Exception in thread "main" java.lang.SecurityException: no manifiest section for signature file entry javax/activation/MimeType.class
    at sun.security.util.SignatureFileVerifier.verifySection(SignatureFileVerifier.java:380)
    at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:231)
    at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:176)
    at java.util.jar.JarVerifier.processEntry(JarVerifier.java:245)
    at java.util.jar.JarVerifier.update(JarVerifier.java:199)
    at java.util.jar.JarFile.initializeVerifier(JarFile.java:323)
    at java.util.jar.JarFile.getInputStream(JarFile.java:388)
    at sun.misc.JarIndex.getJarIndex(JarIndex.java:120)
    at sun.misc.URLClassPath$JarLoader$1.run(URLClassPath.java:608)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.misc.URLClassPath$JarLoader.ensureOpen(URLClassPath.java:599)
    at sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:583)
    at sun.misc.URLClassPath$3.run(URLClassPath.java:333)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.misc.URLClassPath.getLoader(URLClassPath.java:322)
    at sun.misc.URLClassPath.getLoader(URLClassPath.java:299)
    at sun.misc.URLClassPath.getResource(URLClassPath.java:168)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
sysvineMM04:MamaBear arun_kumar$ 

Experts Please help me to solve this error.

3
  • possible duplicate of stackoverflow.com/questions/3721405/…
    – Mukul Goel
    Oct 26, 2012 at 8:01
  • @MukulGoel: Not really a duplicate. This question asks how to solve this problem, to which deleting the signatures is one solution. That question asks why deleting the signatures works. Having an answer to that question on the site wouldn't help people looking for an answer to this one. Oct 26, 2012 at 8:03
  • @TomAnderson yup you are right, but that does answer the question. Moreover I Searched the exception and that question was the top result at google. But yea you are right there is a difference
    – Mukul Goel
    Oct 26, 2012 at 8:06

1 Answer 1

1

I assume you're packing all the class files into a single 'uberjar'?

The problem is that the activation library is a signed jar; it includes digital signatures of the class files in its manifest. When you packed the uberjar, you lost those.

The right way to deal with this is to not pack everything into one jar. Leave every library in its own packaging, and distribute them together.

However, if you want to keep using an uberjar, you should be able to fix this by copying the signatures from the activation jar's manifest into the uberjar's manifest. I don't know if there is Ant support for this, i'm afraid.

3
  • Yes, that would be a good option, in the spirit of leaving every library in its own packaging. It's a way of putting everything in one jar without the problems associated with merging jars. Oct 27, 2012 at 10:26
  • @TomAnderson: Thank you Tom. I extracted the archive.jar library and copied all the signatures from META-INF file and pasted into my application's META-INF file. Still there is no luck. Am I doing anything wrong?
    – Arun G
    Oct 29, 2012 at 5:16
  • Firstly, i would look seriously at @BillShannon's suggestion of using One-JAR. It's very simple to use, and solves this problem in a fundamentally better way than an uberjar. Secondly, if you want to chase down the problems with your current approach, could you post the contents of your manifest, and a listing of the other files present in your META-INF? Oct 29, 2012 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.