aspose file tools
The moose likes Security and the fly likes Jar File and java.lang.SecurityException. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » Security
Reply Bookmark "Jar File and java.lang.SecurityException." Watch "Jar File and java.lang.SecurityException." New topic
Author

Jar File and java.lang.SecurityException.

Sandeep Ghosh
Ranch Hand

Joined: Jan 23, 2002
Posts: 145
Hi Friends,
I have written mail application using Java Mail API. I have packaged my classes , mail.jar and other depended libraries into a JAR file. When I am running this using java -jar Main.class it is giving following exception.
Exception in thread "main" java.lang.SecurityException: no manifiest section for signature file entry javax/mail/search/SearchTerm.class
at sun.security.util.SignatureFileVerifier.verifySection(SignatureFileVerifier.java:262)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:174)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:241)
at java.util.jar.JarVerifier.update(JarVerifier.java:197)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:248)
at java.util.jar.JarFile.getInputStream(JarFile.java:310)
at sun.misc.URLClassPath$4.getInputStream(URLClassPath.java:537)
at sun.misc.Resource.getBytes(Resource.java:60)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:245)
at java.net.URLClassLoader.access$100(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:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
When I am removing all depended libraries from JAR file and included those classpath ,it is giving execption that libraries not found.
Thanks in adv.
Sonu
Martin Lovell
Greenhorn

Joined: Mar 10, 2003
Posts: 5
The mail.jar file contains signature files to sign the jar.
When you extract it to combine it with your classes, remove the files: SUN_MICR.RSA and SUN_MICR.SF from the META-INF folder.
If you use an automated tool to create the combined jar, such as JBuilder, you will need to manually remove these files after the combined jar is created.
From the jar's folder:
mkdir temp
cd temp
jar -xvf ../jarfile.jar
rm META-INF/SUN_MICR.*
jar cvf ../jarfile.jar *
cd ..
rm temp -rf
(replace rm with dos command as needed)
(I just ran into the same problem. A little bit late to help you...but...)
Bob Clark
Greenhorn

Joined: Jul 18, 2004
Posts: 1
But it wasn't too late to help me. Thanks.

Btw, if you have WinRar you can just go into the jar and delete the files through the interface. If you are creating an native executable under jbuilder you need to compile the regular archive first, modify it, then build the native executable.

Thanks for the tip!
Derek Clarkson
Greenhorn

Joined: Mar 04, 2004
Posts: 25
Hello everyone,
Had this same problem and solved it. I'm using JBuilder. I prefer to build single jars for an application which contain all the required classes so that I don't have problems with upgrades and new versions etc and don't have to worry about what be effected and what won't.

When setting up the result jar file for the application, the javamail package must be included in the jar with all classes and resources included. This is because it makes use of dynamic class loading to setup the mail providers.

However the java activation packages must be included using only known classes and resources. Telling Jbuilder to include these packages with all classes causes the signature files to be built as well.

Hope this helps.
Derek
Vicson Victor
Greenhorn

Joined: Dec 06, 2005
Posts: 1
I am new to the forum and I need some help with a similar problem. I am using the jce1_2_1.jar file as part of my build. In windows it works fine and am able to use it in my programs.

But when I try to run the build on my unix box, the build fails and says

" no manifiest section for signature file entry com/sun/crypto/provider/SunJCE_m.class"

Can anyone please help me with this, I tried to remove the 4jcefram.dsa and 4jcefram.sf file from the META-INF folder and ran again. But it does not solve the problem.

Please help.
Haytham Mohtasseb
Greenhorn

Joined: Feb 14, 2007
Posts: 1
Thank you very much.
I changed the JAR making in JBuilder to include only the dependencies not all causing to not calling the signing and it worked.
Harshad Mahajan
Greenhorn

Joined: Sep 15, 2010
Posts: 1
Martin Lovell wrote:The mail.jar file contains signature files to sign the jar.
When you extract it to combine it with your classes, remove the files: SUN_MICR.RSA and SUN_MICR.SF from the META-INF folder.
If you use an automated tool to create the combined jar, such as JBuilder, you will need to manually remove these files after the combined jar is created.
From the jar's folder:
mkdir temp
cd temp
jar -xvf ../jarfile.jar
rm META-INF/SUN_MICR.*
jar cvf ../jarfile.jar *
cd ..
rm temp -rf
(replace rm with dos command as needed)
(I just ran into the same problem. A little bit late to help you...but...)


Thanks.
Your workaround helped me get rid of the securityexception.
However, I would appreciate if someone could explain how this solution cures the problem.

This message was edited 1 time. Last update was at by Harshad Mahajan

miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1254
Martin Lovell wrote:The mail.jar file contains signature files to sign the jar.
When you extract it to combine it with your classes, remove the files: SUN_MICR.RSA and SUN_MICR.SF from the META-INF folder.
(...)

i did that but still get the same error message
anyone can help me please?


java amateur
 
 
subject: Jar File and java.lang.SecurityException.
 
MyEclipse, The Clear Choice

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture