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.
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.