I have the following spring boot jar structure
- bootstrap.yml
- org
- META-INF
  -- MANIFEST.MF
  -- Maven
     -- org.account.core
      -- account-service
       -- pom.properties
       -- pom.xml
Now i want to read my pom file from Util class from within the same jar. The below code always returns empty.
public static String findFilePathInsideJar(String matchingFile) throws IOException {
        String path = null;
        File jarFile = new File(FileUtils.class.getProtectionDomain().getCodeSource().getLocation().getPath());
        if (jarFile.isFile()) {
            JarFile jar = new JarFile(jarFile);
            Enumeration<JarEntry> entries = jar.entries();
            while (entries.hasMoreElements()) {
                String name = entries.nextElement().getName();
                if (name.endsWith(matchingFile)) {
                    path = name;
                    break;
                }
            }
            jar.close();
        }
        return path;
 }
and i call the utility like following
String path = findFilePathInsideJar("pom.xml");
path is always null.
 
    