1

I tried tons of posts from all around the web by changing my pom file for n number of times. Still I am not able to create a executable jar with all the dependencies. Final jar is missing the main class. But, I can see the same in Manifest.mf file. following is my pom.xml

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sample-service</groupId>
<artifactId>sample-service</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>

<dependencies>

    <dependency>
        <groupId>io.undertow</groupId>
        <artifactId>undertow-core</artifactId>
        <version>1.0.15.Final</version>
    </dependency>
    <dependency>
        <groupId>com.ning</groupId>
        <artifactId>async-http-client</artifactId>
        <version>1.7.5</version>
        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>jcl-over-slf4j</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.6</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.6</version>
    </dependency>
    <dependency>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
        <version>2.5.1</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>1.1.1</version>
    </dependency>
</dependencies>
<build>
    <finalName>sample-service</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.2</version>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.2.1</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <archive>
                    <manifest>
                        <mainClass>com.sample.app.SomeMainServer</mainClass>
                    </manifest>
                </archive>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <source>1.7.0_60</source>
                <target>1.7.0_60</target>
            </configuration>
        </plugin>
    </plugins>
</build>

tried all these mvn package mvn clean install mvn clean compile assembly:single

but no luck, main class is not included in the jar. following is my manifest.mf

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: userName
Build-Jdk: 1.7.0_60
Main-Class: com.sample.app.SomeMainServer
Software Engineer
  • 15,457
  • 7
  • 74
  • 102
user1609085
  • 855
  • 3
  • 17
  • 33

1 Answers1

0

As per request in the comments I post this answer:

The jar is built using the maven-jar-plugin, so you can just specify the main-class to it as per the documentation: http://maven.apache.org/shared/maven-archiver/examples/classpath.html

Gimby
  • 5,095
  • 2
  • 35
  • 47