Reputation: 2078
Using maven get compiled *.war file, which contains:
- META-INF
- - MANIFEST.MF
- WEB-INF
- - classes
- - lib
- - web.xml
Using java.util.jar.Manifest I want to read the manifest file to get application version from there like in https://stackoverflow.com/a/21046257/1728511
But Application.class.getResourceAsStream("/META-INF/manifest.mf")
returns null
.
Application.class.getResource( "" ).getFile()
returns %WAR%/WEB-INF/lib/javax.ws.rs-api-2.0.jar!/javax/ws/rs/core/
Using Spring, I've implemented ApplicationContextAware interface to get ApplicationContext instance.
And applicationContext.getClassLoader().getResourceAsStream( "" )
returns %WAR%/WEB-INF/classes
.
But I don't need WEB-INF
, I need META-INF
directory. How to get it?
Upvotes: 3
Views: 7880
Reputation: 3151
You are mixing cases. Your META-INF
contains a MANIFEST.MF
but you are trying to open a resource stream on manifest.mf
.
You will have to change
Application.class.getResourceAsStream("/META-INF/manifest.mf")
to
Application.class.getResourceAsStream("/META-INF/MANIFEST.MF")
Upvotes: 5