0
我在我的電腦上用Java sun httpserver庫構建了一個小型的演示服務器。使用sun httpserver的heroku java web服務器部署
現在,我想要公開並將其部署到heroku。
簡單地說,這是我的Main.java類(下圖)。
它正在構建爲Maven項目。
我連接herkou和我的maven項目(代碼位於github上),maven的編譯和運行階段讓我「構建成功」。當我試圖訪問我的服務器,就像我在本地環境(http://localhost:8000/test)中那樣,當我輸入這個URL(我的herkou站點)時:https://shaffa.herokuapp.com:8000/test我現在收到一條消息:「無法加載頁面」。
是否herkou程序自動運行我在Maven項目(我需要因爲我的服務器開始在我的主要方法,它是如此)的主要方法..
如果是的話,還有什麼可能是這個問題?
謝謝!
public class Main {
static MySQLQueryExecutor mySQLQueryExecutor=MySQLQueryExecutor.getInstance();
public static void main(String[] args) throws Exception {
HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0);
server.createContext("/test", new MyHandler());
server.setExecutor(null);
server.start();
System.out.println(server.getAddress());
}
static class MyHandler implements HttpHandler {
public void handle(HttpExchange t) throws IOException {
String response = "This is Get response";
t.sendResponseHeaders(200, response.length());
OutputStream os = t.getResponseBody();
os.write(response.getBytes());
os.close();
}
}
}
建築日誌:
-----> Java app detected
-----> Installing OpenJDK 1.8... done
-----> Installing Maven 3.3.9... done
-----> Executing: mvn -DskipTests clean dependency:list install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my_demo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ my_demo ---
[INFO]
[INFO] --- maven-dependency-plugin:2.8:list (default-cli) @ my_demo ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ my_demo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /tmp/build_0073fd7c9decf8f53d270853eac0864e/Matoy7-ShaffaServer-dd12826/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ my_demo ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ my_demo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /tmp/build_0073fd7c9decf8f53d270853eac0864e/Matoy7-ShaffaServer-dd12826/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ my_demo ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ my_demo ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ my_demo ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /tmp/build_0073fd7c9decf8f53d270853eac0864e/Matoy7-ShaffaServer-dd12826/target/my_demo-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ my_demo ---
[INFO] Installing /tmp/build_0073fd7c9decf8f53d270853eac0864e/Matoy7-ShaffaServer-dd12826/target/my_demo-1.0-SNAPSHOT.jar to /app/tmp/cache/.m2/repository/yotam/my_demo/1.0-SNAPSHOT/my_demo-1.0-SNAPSHOT.jar
[INFO] Installing /tmp/build_0073fd7c9decf8f53d270853eac0864e/Matoy7-ShaffaServer-dd12826/pom.xml to /app/tmp/cache/.m2/repository/yotam/my_demo/1.0-SNAPSHOT/my_demo-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.365 s
[INFO] Finished at: 2017-05-08T16:28:54+00:00
[INFO] Final Memory: 16M/167M
[INFO] ------------------------------------------------------------------------
-----> Discovering process types
Procfile declares types -> (none)
-----> Compressing...
Done: 48M
-----> Launching...
Released v7
https://shaffa.herokuapp.com/ deployed to Heroku
應用程序日誌
2017-05-08T14:17:52.452910+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=shaffa.herokuapp.com request_id=5f365605-2f15-45d7-a043-5aea122ab4b8 fwd="109.64.111.39" dyno= connect= service= status=503 bytes= protocol=https
2017-05-08T16:28:47.000000+00:00 app[api]: Build started by user [email protected]
2017-05-08T16:28:49.000000+00:00 app[api]: Build started by user [email protected]
2017-05-08T16:29:00.835249+00:00 app[api]: Deploy dd12826 by user [email protected]
2017-05-08T16:29:00.835249+00:00 app[api]: Release v7 created by user [email protected]
2017-05-08T16:28:47.000000+00:00 app[api]: Build succeeded
2017-05-08T16:29:03.635910+00:00 app[api]: Deploy dd12826 by user [email protected]
2017-05-08T16:28:49.000000+00:00 app[api]: Build succeeded
2017-05-08T16:29:03.635910+00:00 app[api]: Release v8 created by user [email protected]
2017-05-08T16:29:08.055046+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=shaffa.herokuapp.com request_id=c06affca-0979-4e7c-aafe-69e5296a33c0 fwd="109.64.111.39" dyno= connect= service= status=503 bytes= protocol=https
2017-05-08T16:29:08.706745+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=shaffa.herokuapp.com request_id=f11fe11a-a99a-4f19-bbff-34b0a84fa1f3 fwd="109.64.111.39" dyno= connect= service= status=503 bytes= protocol=https
部署後運行'heroku logs -t',並在此輸出。 – codefinger
另外,你的'Procfile'包含了什麼? – codefinger
在原msg中添加 – Matoy