tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: WebappClassLoader and MANIFEST.MF in WARs
Date Fri, 14 Nov 2014 20:28:24 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Matt,

On 11/14/14 1:14 PM, Matt Newell wrote:
> Greetings,
> 
> I have a need to get version information for classes that I have
> been packaged in a war, and loaded into Tomcat 7.0.trunk on Windows
> 7. For example:
> 
> 
> System.out.println(this.getClass().getPackage().getImplementationVersion());
>
>  Assuming my.war/META-INF/MANIFEST.MF: Manifest-Version: 1.0 
> Implementation-Version: 1.0
> 
> getImplementationVersion() always returns null.
> 
> If I review the code for WebappClassLoader the reason for this is
> clear. All roads lead to findResourceInternal(File, String), line
> 2983 in 7.x/trunk. This method makes no attempt to load the
> manifest from the war.
> 
> My first instinct was that this is a bug. However, I did a quick
> check using the same scenario using Wildfly 8 and the behavior is
> the same. Given the clarity of the Tomcat code, and that two
> robust, well-tested platforms behave the same, I have to assume
> this is intentional.
> 
> My question is this: why? Is META-INF/MANIFEST.MF not part of the
> war standard? I've googled, but am not enough of a java standards
> wonk to know what docs are authoritative on this topic. I've
> certainly seen examples that use it.

If Tomcat can't/won't do this, you can always load the manifest
manually (context.getResource*) and grab the Implementation-Version
from it.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJUZmXoAAoJEBzwKT+lPKRYpQgP+gPdc9rySB7Fc3/L02PuoQkj
K9W+XLA9K/rCb9hWaS2v8EZajR/S9Vf1EvZtmjvtkoTH5U/w3J+kDfH1K/rmzePZ
aXxJajN487Oo22IF4IKe9YafaAHdUd40hpdXuFug3RrYLSpVC/+mczrq+bvAlbMq
VRCEWokTTNrISpekZ/Kw/iVmFUny7YC4wclCE5jt9ziHPIdPJpR2w4AmvdEkiwEv
3gqAlTyo7YM5Ty7NWaScA3XlB/69bZfrUhRtBuvtT7wC/Yzk42AJ8VF4xYJ+Wg+S
PVNERXGEP+O2eRGED2ShqYHEkaxHYldNbpo1q9ozE8yh9WvToJ0pqv5Gl4Z2WrKr
QX2tPwWuGlqzMiaSWpCf7GfUgeSdo0tEPI9LwzUW74Ra2/NyosG1bsLWIahANJnG
5Hu6isQzUbmetaNpn9/FO6id4vS25yICHNH+2RXgw/ekcTqTrkyCoaD7fF+qKD/S
zikoKVaXTWwK5f2vGzoctp2SLl2PgSj3RhBUs0snxGoDPEz0Vt02xi5f7nXBS09m
3mdLudyP4Z7nD/fKYYu+w9vxc/hx1Y357lQi3ES2GU2dC2YjAqyiF2n8Nw2k3M0v
UJxIb9qCyT7a38buTMRt/zLKoG4UyOy41boB6F6A/2050P6QFWLOhsBOvDW4bQlS
oz32lftds1Y6wlsarMoh
=09hK
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message