DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3947>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3947 The Manifest file included in a Jar created by Jar Task is not found by a JarInputStream. Summary: The Manifest file included in a Jar created by Jar Task is not found by a JarInputStream. Product: Ant Version: 1.4 Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Normal Priority: Other Component: Core tasks AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] When I created a Jar file with a specified manifest file using the Jar Task in Ant, I discovered that you are not able to retrieve the Manifest information using the java.util.jar.JarInputStream class. The reason for this problem is that the Manifest file (META-INF/MANIFEST.MF) is entered as the last element in the JAR file. java.util.jar.JarInputStream only looks at the first JarEntry and checks to see if it is either "META-INF/MANIFEST.MF" or "META-INF/". If the JarEntry is "META-INF", then it checks the next JarEntry. If "META-INF/MANIFEST.MF" is found in this initial check, then the Manifest information is retrievable through the getManifest() method. If the file is not found in this initial check then all calls to the JarInputStream's getManifest method will return null. The problem is also found in Ant 1.3, but only if a manifest file was specified in the Jar task. The manifest is located if a Manifest file is not speicified. In version 1.4, the problem occurs whether or not you specify a Manifest file. How to reproduce: 1) Have class that reads in Jar file and looks for manifest info: JarInputStream jis = new JarInputStream(new FileInputStream(new File("myJar.jar"))); Manifest mf = jis.getManifest(); if (mf == null) { throw new Exception("manifest missing"); } 2) Using ant build jar file with a specified manifiest: <jar basedir="classes" manifest="MYMANIFEST.MF" jarfile="myJar.jar" /> 3) Run program -- will result in the exception being thrown ("manifest missing") The fix for this problem would be to add the MANIFEST.MF file to the Jar file after adding the META-INF directory in the Jar.initZipOutputStream() method instead of in the Jar.finalizeZipOutputStream() method. The Jar specifications do not exactly specify that the MANIFEST.MF file should be located at the beginning of the archive, although the documentation for JDK 1.1 specifies the following: "Archives are signed by creating a "META-INF/" directory at the top level of the path tree." -- see http://java.sun.com/products/jdk/1.1/docs/guide/jar/manifest.html The location of the MANIFEST.MF file only appears to be an issue with JarInputStream, the Jar/Java programs do not have any issues with reading and using the Manifest information.
