Help us understand the problem. What is going on with this article?

heroku用のJavaプロジェクトをforemanで起動しようとしたときにエラーになる件について

More than 5 years have passed since last update.

事象

heroku用のJavaアプリケーションをIDEからではなく、foremanで起動しようとしたときに以下のエラーがでて、はまったのでメモ

最初は、slf4jのライブラリがおかしいのかと思って、googleを漁っていた。
(そこで長時間を費やす)

❯ foreman start web                                                                                                                                ⏎
10:40:10 web.1  | started with pid 28074
10:40:10 web.1  | Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
10:40:10 web.1  |   at Main.<clinit>(Main.java:22)
10:40:10 web.1  | Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
10:40:10 web.1  |   at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
10:40:10 web.1  |   at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
10:40:10 web.1  |   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
10:40:10 web.1  |   at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
10:40:10 web.1  |   ... 1 more
10:40:10 web.1  | exited with code 1
10:40:10 system | sending SIGTERM to all processes

mvn cleanしてみる

mvn cleanするとちょっと改善される

❯ foreman start web
11:13:28 web.1  | started with pid 28215
11:13:28 web.1  | エラー: メイン・クラスMainが見つからなかったかロードできませんでした
11:13:28 web.1  | exited with code 1
11:13:28 system | sending SIGTERM to all processes

mvn clean installする

herokuのGetting Started with Java on Herokuを確認すると、mvn clean installが必要そうだ。

Declare app dependencies

mvn clean install

起動できた。毎回これではまっているような。

❯ foreman start web
11:19:00 web.1  | started with pid 28257
11:19:00 web.1  | 11:19:00.471 [main] INFO  org.eclipse.jetty.util.log initialized Logging initialized @358ms
11:19:00 web.1  | 11:19:00.526 [main] INFO  org.eclipse.jetty.server.Server doStart jetty-9.2.10.v20150310
11:19:00 web.1  | 11:19:00.551 [main] INFO  o.e.j.server.handler.ContextHandler doStart Started o.e.j.s.ServletContextHandler@6093dd95{/,null,AVAILABLE}
11:19:00 web.1  | 11:19:00.583 [main] INFO  o.e.jetty.server.ServerConnector doStart Started ServerConnector@4f7d0008{HTTP/1.1}{0.0.0.0:5000}
11:19:00 web.1  | 11:19:00.583 [main] INFO  org.eclipse.jetty.server.Server doStart Started @475ms
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした