3

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?

Community
  • 1
  • 1
Mikhail Kopylov
  • 2,008
  • 5
  • 27
  • 58

1 Answers1

5

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")
Dirk Lachowski
  • 3,121
  • 4
  • 40
  • 66