0

So I have this app, that runs like a charm locally, but not on Heroku.

When I look in the log-file after deploying and running, I get the following error:

2019-02-11T20:19:53.000000+00:00 app[api]: Build succeeded
2019-02-11T20:19:56.249701+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -cp target/classes:target/dependency/* com.name.app.Main`
2019-02-11T20:19:57.813257+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2019-02-11T20:19:57.816510+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2019-02-11T20:20:12.984296+00:00 heroku[web.1]: State changed from starting to crashed
2019-02-11T20:20:12.906580+00:00 app[web.1]: Exception in thread "Thread-0" java.lang.NoClassDefFoundError: com/name/my-library/utils/NetworkUtils
2019-02-11T20:20:12.906761+00:00 app[web.1]: at com.name.app.UpdateThread.update(UpdateThread.java:35)
2019-02-11T20:20:12.906837+00:00 app[web.1]: at com.name.app.UpdateThread.run(UpdateThread.java:25)
2019-02-11T20:20:12.906974+00:00 app[web.1]: Caused by: java.lang.ClassNotFoundException: com.name.my-library.utils.NetworkUtils
2019-02-11T20:20:12.907044+00:00 app[web.1]: at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
2019-02-11T20:20:12.907114+00:00 app[web.1]: at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
2019-02-11T20:20:12.907183+00:00 app[web.1]: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
2019-02-11T20:20:12.907312+00:00 app[web.1]: at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
2019-02-11T20:20:12.907318+00:00 app[web.1]: ... 2 more
2019-02-11T20:20:12.968687+00:00 heroku[web.1]: Process exited with status 0

It is clear that it cannot find a class that is being used. Now this class is present, not in the app itself, but in a library that I have released on GitHub. I am using Maven to include the dependency. As I said, the projects runs fine, locally, also using the library on GitHub.

EDIT: Just to let you know. The deployment process is working (in that case I do not get an error concerning the library dependency).

MWB
  • 1,830
  • 1
  • 17
  • 38
  • "Now this class is present, not in the app itself". Is the containing Jar file listed in the application classpath? – LppEdd Feb 11 '19 at 20:44
  • I am not using a jar file. I have it deployed on GitHub and I am using jitpack.io to include the dependency in Maven. – MWB Feb 11 '19 at 20:46
  • The end result will always be a Jar file, with a Manifest (or a command line specified classpath value). Maybe check the jitpack.io logs, if possible – LppEdd Feb 11 '19 at 20:48
  • 1
    Are you copying your dependencies into the app like this https://devcenter.heroku.com/articles/deploying-java#verify-that-your-pom-xml-file-is-set-up-correctly – codefinger Feb 12 '19 at 14:31
  • Thank you codefinger! I did not have the plugin setup correctly (make it an answer and I will accept it) – MWB Feb 12 '19 at 16:09

0 Answers0