I am packaging my application as
mvn package
It creates a jar
file by the name JasperCSVDataSource-1.0-SNAPSHOT.jar
When I try to run the jar file as :
java -jar JasperCSVDataSource-1.0-SNAPSHOT.jar
I get an error saying no main manifest attribute, in target/JasperCSVDataSource-1.0-SNAPSHOT.jar
. To automatically add manifest file in the created JAR
, I updated my pom.xml
by adding the following:
<configuration>
<archive>
<manifest>
<mainClass>com.comp.main.CommandLineRunner</mainClass>
</manifest>
</archive>
</configuration>
The complete pom.xml
looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.comp</groupId>
<artifactId>JasperCSVDataSource</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<archive>
<manifest>
<mainClass>com.suhail.main.CommandLineRunner</mainClass>
</manifest>
</archive>
</configuration>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.8.0</version>
</dependency>
<dependency>
<groupId>ar.com.fdvs</groupId>
<artifactId>DynamicJasper</artifactId>
<version>5.0.11</version>
</dependency>
</dependencies>
</project>
But now when I try to build the file, I get an error saying:
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Malformed POM /Users/tambro/jasper-test/pom.xml: Unrecognised tag: 'configuration' (position: START_TAG seen ...</version>\n \n <configuration>... @12:20) @ /Users/tambro/jasper-test/pom.xml, line 12, column 20
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.tambro:JasperCSVDataSource:1.0-SNAPSHOT (/Users/tambro/jasper-test/pom.xml) has 1 error
[ERROR] Malformed POM /Users/tambro/jasper-test/pom.xml: Unrecognised tag: 'configuration' (position: START_TAG seen ...</version>\n \n <configuration>... @12:20) @ /Users/tambro/jasper-test/pom.xml, line 12, column 20 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException
I could not understand the reason for this. Is this not the correct way of adding manifest file to the jar?