Terminate gracefully if krill.properties is not found
Change-Id: Id9764ec9b81cc5c3412d912e8ac6d74cdc284b57
diff --git a/src/main/java/de/ids_mannheim/korap/server/Node.java b/src/main/java/de/ids_mannheim/korap/server/Node.java
index 6267bb9..8b4de0f 100644
--- a/src/main/java/de/ids_mannheim/korap/server/Node.java
+++ b/src/main/java/de/ids_mannheim/korap/server/Node.java
@@ -2,6 +2,7 @@
import java.util.*;
import java.io.*;
+import java.net.URL;
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
@@ -57,9 +58,14 @@
public static HttpServer startServer () {
// Load configuration
+ URL resUrl = Node.class.getClassLoader().getResource("krill.properties");
+ if (resUrl == null) {
+ log.error("Cannot find \"krill.properties\". Please create it "
+ +"using \"krill.properties.info\" as template. Terminating.");
+ System.exit(1);
+ }
try {
- InputStream file = new FileInputStream(Node.class.getClassLoader()
- .getResource("krill.properties").getFile());
+ InputStream file = new FileInputStream(resUrl.getFile());
Properties prop = new Properties();
prop.load(file);