Question

I am trying to run an app on Heroku. I am doing CI on Travis and deploying from it. My code is at https://github.com/santoshkt/cdetsd123

When I went through the logs in heroku, I see following

2014-03-10T03:14:08.180220+00:00 heroku[web.1]: Starting process with command `j
ava $JAVA_OPTS -cp target/classes:target/dependency/* mytest.Main`
2014-03-10T03:14:10.692378+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS:  -Djav
a.rmi.server.useCodebaseOnly=true -Djava.rmi.server.useCodebaseOnly=true
2014-03-10T03:14:11.217814+00:00 app[web.1]: Exception in thread "main" java.lan
g.NoClassDefFoundError: org/eclipse/jetty/server/Handler
2014-03-10T03:14:11.286992+00:00 app[web.1]: Caused by: java.lang.ClassNotFoundE
xception: org.eclipse.jetty.server.Handler
2014-03-10T03:14:11.287150+00:00 app[web.1]:    at java.net.URLClassLoader$1.run
(URLClassLoader.java:217)
2014-03-10T03:14:11.287380+00:00 app[web.1]:    at java.net.URLClassLoader.findC
lass(URLClassLoader.java:205)
2014-03-10T03:14:11.287271+00:00 app[web.1]:    at java.security.AccessControlle
r.doPrivileged(Native Method)
2014-03-10T03:14:11.287380+00:00 app[web.1]:    at java.lang.ClassLoader.loadCla
ss(ClassLoader.java:321)
2014-03-10T03:14:11.287380+00:00 app[web.1]:    at sun.misc.Launcher$AppClassLoa
der.loadClass(Launcher.java:294)
2014-03-10T03:14:11.287645+00:00 app[web.1]:    at java.lang.ClassLoader.loadCla
ss(ClassLoader.java:266)
2014-03-10T03:14:11.296871+00:00 app[web.1]: Could not find the main class: myte
st.Main. Program will exit.

To run this software locally, I use mvn jetty:run command and everything works fine. BTW I'm using maven + jetty in this application. I'm trying to debug this for last 6 hours with no clues. Any help is appreciated.

Was it helpful?

Solution

Instead of using a Main method to start the server, I solved this by changing the Procfile of Heroku using below.

web:    java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.war

Hope this helps anyone facing same issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top