users@glassfish.java.net

Extracting information from MANIFEST.MF

From: <glassfish_at_javadesktop.org>
Date: Tue, 17 Mar 2009 12:14:36 PDT

Hi,

I'm trying to find a nice way to display the version number of my web app by other means than simply maintaining a static constant somewhere that I need to update everytime we do a new release. I figured I could use the Implementation-Version of one of the MANIFEST.MF files of one of the jars packaged in my EAR. Here's a brief overview of how my archive is packaged:

my-ear/META-INF/MANIFEST.MF
my-ear/lib/somemodule.jar
my-ear/lib/somemodule.jar!/META-INF/MANIFEST.MF

Both MANIFEST.MF files mentioned above look like this:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: johndoe
Build-Jdk: 1.6.0_12
Implementation-Title: xxxxxx
Implementation-Version: 1.2.8
Implementation-Vendor-Id: yyyyyyy

To get the version number, I'm doing the following: SomeClass.class.getPackage().getImplementationVersion(). SomeClass is a class packaged in the somemodule.jar file. This doesn't seem to work. If I execute the same statement in a test Main class that simply has the somemodule.jar in its classpath, it works. In GlassFish, at runtime, I see that the class loader of SomeClass is the EJBClassLoader. Is there something that the EJBClassLoader does that prevents it from reading the MANIFEST file of my module jar? Am I missing a MANIFEST.MF file somewhere else?

Thanks a lot for your help.
[Message sent by forum member 'ylazzari' (ylazzari)]

http://forums.java.net/jive/thread.jspa?messageID=337514