I have tried countless methods to get a spark app deployed to Heroku with Maven through the terminal in IntelliJ. Heroku keeps giving me this message and I'm sure it has something do with the Procfile & maybe my pom.xml. It runs fine locally
Heroku logs :
2018-01-24T21:36:14.000000+00:00 app[api]: Build succeeded
2018-01-24T21:36:41.627318+00:00 heroku[web.1]: Starting process with command `./build/install/ctr39/bin/ctr39`
2018-01-24T21:36:43.283296+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2018-01-24T21:36:43.283383+00:00 app[web.1]: bash: ./build/install/ctr39/bin/ctr39: No such file or directory
2018-01-24T21:36:43.346808+00:00 heroku[web.1]: State changed from starting to crashed
2018-01-24T21:36:43.351771+00:00 heroku[web.1]: State changed from crashed to starting
2018-01-24T21:36:43.330552+00:00 heroku[web.1]: Process exited with status 127
2018-01-24T21:36:50.407076+00:00 heroku[web.1]: Starting process with command `./build/install/ctr39/bin/ctr39`
2018-01-24T21:36:52.612695+00:00 heroku[web.1]: State changed from starting to crashed
2018-01-24T21:36:52.595643+00:00 heroku[web.1]: Process exited with status 127
2018-01-24T21:36:52.533525+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2018-01-24T21:36:52.533776+00:00 app[web.1]: bash: ./build/install/ctr39/bin/ctr39: No such file or directory
my Procfile :
web: ./build/install/ctr39/bin/ctr39
I have been copying and manipulating here all day
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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.reach.ctr39</groupId>
<artifactId>ctr39</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ctr39</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core -->
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.7.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.9.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<!-- This tells Maven to include all dependencies -->
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>0.4.4</version>
<configuration>
<jdkVersion>1.8</jdkVersion>
<!-- Use your own application name -->
<appName>ct39</appName>
<processTypes>
<!-- Tell Heroku how to launch your application -->
<!-- You might have to remove the ./ in front -->
<web>java -jar ./target/ctr39-1.0-jar-with-dependencies.jar</web>
</processTypes>
</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>8.5.11.3</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Any idea what I'm doing wrong? It likely has something to do with the ports issue in Spark and I copied the snippet in my main file the docs provided ...
static int getHerokuAssignedPort() {
ProcessBuilder processBuilder = new ProcessBuilder();
if (processBuilder.environment().get("PORT") != null) {
return Integer.parseInt(processBuilder.environment().get("PORT"));
}
return 4567; //return default port if heroku-port isn't set (i.e. on localhost)
}
With the help of Codefinger above pointing me in the right direction...
I updated my POM.XML .. I got rid of web-runner and added
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy-dependencies</goal></goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
and then changed my Prodfile to ...
web: java $JAVA_OPTS -cp target/classes:target/dependency/* com.reach.ctr39.App
I kept the Port function the same from the Spark documents. Thank you guys. Hope this helps someone in the future.
Try using the following Procfile
file:
web: java -jar ./target/ctr39-1.0-jar-with-dependencies.jar
And instead of ProcessBuilder
try:
System.getenv('PORT')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.