2017-11-11 167 views
0

我在Heroku上傳了JavaServlet項目。當我在瀏覽器上檢查它時,它顯示「應用程序錯誤」並沒有運行。Heroku上的Gradle的JavaServlet項目沒有運行

根據Heroku上的構建日誌,似乎我的項目是正確構建和部署的。

-----> Gradle app detected 
-----> Installing OpenJDK 1.8... done 
-----> Building Gradle app... 
-----> executing ./gradlew stage 
     :clean UP-TO-DATE 
     :copyToLib 
     :compileJava 
     :processResources NO-SOURCE 
     :classes 
     :war 
     :stage 

     BUILD SUCCESSFUL in 15s 
     4 actionable tasks: 3 executed, 1 up-to-date 
-----> Discovering process types 
     Procfile declares types -> web 
-----> Compressing... 
     Done: 76.5M 
-----> Launching... 
     Released v3 
     https://rocky-sands-26639.herokuapp.com/ deployed to Heroku 

我檢查了使用下面的命令運行日誌:

$heroku logs 

然後我得到了下面的錯誤日誌。我該如何解決這個錯誤?

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch 

我介紹了此頁。我用gradle而不是maven。 https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku#using-webapp-runner-to-deploy-war-files

源代碼 https://github.com/fruitwater/heroku-servlet-gradle

+0

一種可能性:看看https://devcenter.heroku.com/articles/heroku-local學習如何在自己的計算機上運行應用程序,正是因爲它會在Heroku中運行。你的應用*上傳*沒問題,但上傳和實際上成功啓動是兩件完全不同的事情。 –

回答

0

您需要添加--port $PORTProcfile。它應該是這樣的:

web: java -jar build/server/webapp-runner-*.jar --port $PORT build/libs/*.war 
+0

感謝您的建議。我更新了像你的Procfile,但錯誤信息沒有改變。 – fruitwater

+0

「heroku日誌」的輸出結果如何?那麼'heroku ps'呢? – codefinger

+0

Heroku的日誌https://gist.githubusercontent.com/fruitwater/becd1ffeef0314dae022bf609f64e26f/raw/cd30c9bcdb72e4bdcbdc0416fe4f365caa2e921d/gistfile1.txt Heroku的PS https://gist.githubusercontent.com/fruitwater/bd91e547c9012726758622a4aa3f0e7a/raw/0db1e922f9036395a05ee57b153d1479afa00e37/heroku%2520ps – fruitwater

相關問題