I am trying to read my own MANIFEST.MF resource in a Java servlet. My position: I have a WAR (with a manifest that I want to read) inside the EAR. There are several other WARs and JARs in the EAR. The path to the class is really long.
I tried several ways to find on the Internet, including StackOverflow.
I can read all MANIFEST.MF files using
this.getClass().getClassLoader().getResources("META-INF/MANIFEST.MF");
and repeat them. However, I do not know which of them - I do not even know the name of the implementation, since this is generated by the assembly. (I can guess the knowledge of the assembly, so I know that the correct manifest exists. However, I cannot guess the production code.)
Sure,
this.getClass().getClassLoader().getResourceAsStream("META-INF/MANIFEST.MF");
returns a completely incorrect manifest from any other jar in the class path.
I also tried
this.getServletContext().getResourceAsStream("META-INF/MANIFEST.MF");
but it returns zero.
How to access the MANIFEST.MF file owned by WAR containing the current servlet?
source share