Reputation: 28868
Simple as that, I am trying to deploy this app https://github.com/pac4j/spark-pac4j-demo to my heroku instance.
I can run it locally with: mvn compile exec:java
But on heroku, there is no maven installed:
2016-04-12T18:34:21.074629+00:00 heroku[web.1]: Starting process with command `mvn compile exec:java`
2016-04-12T18:34:23.303776+00:00 app[web.1]: bash: mvn: command not found
2016-04-12T18:34:23.303620+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
I have no clue how to set all the class paths per hand. I would appreciate some help here.
Upvotes: 0
Views: 1146
Reputation: 10318
You'll first need to vendor your dependencies (i.e. copy them into the target/
directory). You can do so by adding this to your pom.xml
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy-dependencies</goal></goals>
</execution>
</executions>
</plugin>
Then the correct command to run the app will probably be something like java -cp target/classes:target/dependency/* Main
(where Main
should be replaced with your class that contains the public static void main
method).
Here is a sample app using Spark so you can see how this all comes together.
Maven is not a good way to run an application in production. It creates an additional dependency for your app and adds layers of indirection to the process execution.
Upvotes: 1