title: Reading manifest file of spring boot application
body: <p>I am working on a multi module Java Spring boot application. The structure looks like below.</p>
  
  <pre><code>module 1 (packaging: pom)
     submodule 1.1 (packaging: jar)
     submodule 1.2 (packaging: jar)
  
  module 2 (packaging: pom)
     submodule 2.1 (packaging: jar)
     submodule 2.2 (packaging: jar)
  
  webapplication (packaging: war)
     use submodule jars as dependencies
  </code></pre>
  
  <p>The <code>webapplication</code> module contains all the <code>REST API</code>s. One of the REST API is supposed to read the <code>MANIFEST.MF</code> file inside the <code>war</code> file and provide some information related to the deployed application.</p>
  
  <p>Following code is being used to read the <code>MANIFEST.MF</code> file. <em>(hand crafted right here)</em></p>
  
  <pre><code> InputStream input = getClass().getClassLoader().getResourceAsStream("META-INF/MANIFEST.MF");
   Manifest manifest = new Manifest(input); //java.util.jar.Manifest
   Attributes attrs = manifest.getMainAttributes();
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>When the application is run with <code>spring-boot:run</code> command, the content I can find in <code>attrs</code> is completely different than what I see in the <code>MANIFEST.MF</code> file inside the war. It must be reading from some other manifest file.</p>
  
  <p><strong>Questions</strong></p>
  
  <ol>
  <li>Am I loading the <code>MANIFEST</code> file in a wrong way? Do I must use <code>servletContext()</code> to load the file?</li>
  <li>Probably the above code is reading from the first jar file found in classpath. What is the best way to locate the manifest file of my deployed war file only? I am yet to try out <code>jcbi-manifests</code> package. Will it solve the problem?</li>
  </ol>