Throw exception when server startup fails #5812
authorPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 30 May 2016 15:12:54 +0000 (17:12 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 30 May 2016 15:22:43 +0000 (17:22 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java
eu.etaxonomy.taxeditor.webapp/src/main/java/eu/etaxonomy/taxeditor/webapp/CDMServer.java

index 92824fc..f77ab90 100644 (file)
@@ -735,7 +735,7 @@ public class RemotingLoginDialog extends Dialog implements ICDMServerError {
 
                     // the following loop is a 'fake' progress monitoring where the progress
                     // bar is advanced by one unit every second until maxUnits -2
-                    while(!CdmStore.getManagedServer().isStarted()) {
+                    while(!CdmStore.getManagedServer().isStarted() && !CdmStore.getManagedServer().isFailed()) {
                         if(serverUnits < maxUnits - 2) {
                             try {
                                 Thread.sleep(1000);
@@ -748,10 +748,10 @@ public class RemotingLoginDialog extends Dialog implements ICDMServerError {
                     Display.getDefault().asyncExec(new Runnable() {
                         @Override
                         public void run() {
-                            hide(false);
-                            updateManagedServerControls();
-                            connect();
-                        }
+                                hide(false);
+                                updateManagedServerControls();
+                                connect();
+                            }
                     });
                 } catch (IOException ioe) {
                     MessagingUtils.errorDialog("Error generating server config file",
index 98e68a5..76ed341 100644 (file)
@@ -106,6 +106,7 @@ public class CDMServer {
         WebAppContext webapp = new WebAppContext();
         webapp.setContextPath(contextPath);
         webapp.setWar(warFile.getAbsolutePath());
+        webapp.setThrowUnavailableOnStartupException(true);
 
         server.setHandler(webapp);
     }
@@ -183,7 +184,13 @@ public class CDMServer {
                     server.start();
                     server.join();
                 } catch (Throwable t) {
-                    cdmServerError.handleError(t);
+                    //wait for 1sec to get the right order of login dialog and error
+                    //message when connection fails
+                    try {
+                        Thread.sleep(1000);
+                    } catch (InterruptedException e) {
+                    }
+                    cdmServerError.handleError(new RuntimeException("Error during CDM server startup", t));
                 }
             }
         };
@@ -204,6 +211,10 @@ public class CDMServer {
         return server.isStarted();
     }
 
+    public boolean isFailed() {
+        return server.isFailed();
+    }
+
     public void stop() throws Exception {
         server.stop();
         server.destroy();