cannot find the reason of such problem. I need to read my MANIFEST.MF file properties and it is always null. This is my maven-jar-plugin in pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Project>ExternalBettingHistoryService</Project>
<Build>${buildVersion}</Build>
</manifestEntries>
</archive>
</configuration>
</plugin>
Here is a class where I read manifest:
@Controller
public class StatusController
{
@Autowired
private ServletContext servletContext;
public void readManifest() throws IOException
{
Properties manifest = new Properties();
try (InputStream inputStream = servletContext.getResourceAsStream("/META-INF/MANIFEST.MF"))
{
manifest.load(inputStream);
}
}
This code permanently causes NullPointerException because servletContext.getResourceAsStream("/META-INF/MANIFEST.MF") returns null.
I build project simply using mvn package. The is a manifest file inside .jar: [jar]/target/classes/META-INF/MANIFEST.MF. This file is valid and exists and looks similar to:
Manifest-Version: 1.0
Implementation-Title: sampleTitle
Implementation-Version: 0.0.1-SNAPSHOT
Build: DEV
Built-By: me
Implementation-Vendor-Id: com.sample.project
Project: ProjectName
Created-By: Apache Maven 3.5.0
Build-Jdk: 1.8.0_144
Implementation-URL: https://projects.spring.io/spring-boot/#/spring-bo
ot-starter-parent/parent-pom/projectname
I tried to run project using:
- spring-boot:run
- java -jar target/my-jar.jar
In both cases inputStream of servletContext.getResourceAsStream("/META-INF/MANIFEST.MF") is null.
What may be wrong?