0

I have developed a simple Spark-Web app that runs fine when started through my IDE (IntelliJ). However, when I run the generated .jar (or .war - i have tried creating both) I get a manifest error:

no main manifest attribute, in build/libs/ProjectName-0.1.war

My goal is to run it stand-alone on a test server. I have read through How to deploy a spark Java web app? but it's not specific on how to start the app - I am guessing it's by running:

java -jar ProjectName-0.1.war

which results in the error that brought me here.

EDIT: Using Gradle 2.2.1

Community
  • 1
  • 1
emilio
  • 314
  • 3
  • 16
  • I would say your problem is not related to *Spark* at all, but to a *java* or *maven* issue. You might want to take a look [here](http://stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute) – Mikel Urkia Mar 18 '15 at 16:35
  • Thanks Mikel - I am using Gradle – emilio Mar 18 '15 at 16:55

1 Answers1

0

I have a sample app which you can deploy (https://github.com/mnrasul/sparkjava-testapp).

In my pom, I have the relevant sections for building a fat jar. At the end, there is a way to generate a debian file too. Not sure if I finished that part, but you can certainly work with the fat jar.

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>ca.rasul.sparkjava.testapp.HelloWorld</mainClass>
                        </manifest>
                    </archive>

                </configuration>
                <executions>
                    <execution>
                        <id>assemble-all</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>ca.rasul.sparkjava.testapp.HelloWorld</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>

            <!--building a deb package-->
            <plugin>
                <artifactId>jdeb</artifactId>
                <groupId>org.vafer</groupId>
                <version>1.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>jdeb</goal>
                        </goals>
                        <configuration>
                            <dataSet>
                                <data>
                                    <src>${project.build.directory}/${project.build.finalName}.jar</src>
                                    <type>file</type>
                                    <mapper>
                                        <type>perm</type>
                                        <prefix>/usr/share/jdeb/lib</prefix>
                                    </mapper>
                                </data>
                            </dataSet>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
Nasir
  • 2,984
  • 30
  • 34