Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

@gosshys

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

事象

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
1
Help us understand the problem. What are the problem?