0

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>com.luckypants</groupId>
    <artifactId>LuckyPants</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>LuckyPants</name>

    <properties>
        <tomcat.version>7.0.34</tomcat.version>
        <jersey.version>1.8</jersey.version>
        <target.version>1.7</target.version>
        <appassembler.version>1.8</appassembler.version>
        <source.version>1.7</source.version>
        <mvn.compiler.version>3.0</mvn.compiler.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <!--<dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> 
            <version>${jersey.version}</version> </dependency> -->
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core" -->
            <artifactId>jersey-container-servlet</artifactId>
            <version>2.14</version>
        </dependency>
        <!-- if you are using Jersey client specific features without the server 
            side -->
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.14</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.connectors</groupId>
            <artifactId>jersey-apache-connector</artifactId>
            <version>2.14</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.14</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-core</artifactId>
            <version>${tomcat.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-logging-juli</artifactId>
            <version>${tomcat.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <version>${tomcat.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jasper</artifactId>
            <version>${tomcat.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jasper-el</artifactId>
            <version>${tomcat.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jsp-api</artifactId>
            <version>${tomcat.version}</version>
        </dependency>

    </dependencies>
    <build>
        <finalName>LuckyPants</finalName>
        <plugins>
            <!-- <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> 
                <configuration> <warSourceDirectory>src/main/java/com</warSourceDirectory> 
                <webResources> <resource> <directory>WebContent</directory> </resource> </webResources> 
                </configuration> </plugin> -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.github.jsimone</groupId>
                                    <artifactId>webapp-runner</artifactId>
                                    <version>7.0.40.0</version>
                                    <destFileName>webapp-runner.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>appassembler-maven-plugin</artifactId>
                <version>${appassembler.version}</version>
                <configuration>
                    <assembleDirectory>target</assembleDirectory>
                    <programs>
                        <program>
                            <mainClass>launch.Main</mainClass>
                            <name>webapp</name>
                        </program>
                    </programs>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>assemble</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

The content of my Procfile is web: java %JAVA_OPTS% -cp target\classes;"target\classes\*" Main

but when I run this code in heroku , it gives the following error message

Error: Could not find or load main class launch.Main 2016-07-20T14:22:59.864248+00:00 heroku[run.2063]: State changed from up to complete 2016-07-20T14:23:01.234275+00:00 heroku[web.1]: Process exited with status 1 2016-07-20T14:23:01.248600+00:00 heroku[web.1]: State changed from starting to crashed

But the Main.class is in launch package.

How can I sort this out?

1 Answers1

1

I see several different and conflicting things in your pom.xml and Procfile.

  • You are including webapp-runner, which should probably be run with this command in your Procfile: java -jar target/dependency/webapp-runner.jar yourapp.war

  • You are using appassembler-maven-plugin to build an executable JAR file, with the main class launch.Main

  • You have configured your app to run with the main class Main (no package name) in your Procfile.

In order to properly answer the question, I would have to know how to run your app. You'll need to answer these questions for us:

  • How do you run the app locally?
  • What is your Main class? (if you don't know, it probably means you have a WAR file).

If you are deploying a WAR file, you'll need to run with webapp-runner.

If you are running a Main class, you'll need to use the fully qualified class name in your java command in the Profile (i.e. launch.Main).

codefinger
  • 10,088
  • 7
  • 39
  • 51