From 4f51b7b34c9ac737d42fd4d33c46399c7ba295c6 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Mon, 29 Aug 2016 09:21:11 +0200 Subject: [PATCH] KEYCLOAK-3462 Fix exception not displayed in init from KeycloakServer --- .../services/resources/KeycloakApplication.java | 10 +++++++++- .../java/org/keycloak/testsuite/KeycloakServer.java | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java index 66a643ce13..6cdf52eab2 100644 --- a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java +++ b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java @@ -70,6 +70,8 @@ public class KeycloakApplication extends Application { private static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; + protected boolean embedded = false; + protected Set singletons = new HashSet(); protected Set> classes = new HashSet>(); @@ -78,6 +80,10 @@ public class KeycloakApplication extends Application { public KeycloakApplication(@Context ServletContext context, @Context Dispatcher dispatcher) { try { + if ("true".equals(context.getInitParameter("keycloak.embedded"))) { + embedded = true; + } + loadConfig(context); this.contextPath = context.getContextPath(); @@ -139,7 +145,9 @@ public class KeycloakApplication extends Application { setupScheduledTasks(sessionFactory); } catch (Throwable t) { - exit(1); + if (!embedded) { + exit(1); + } throw t; } } diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/KeycloakServer.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/KeycloakServer.java index 3b8d68b9b2..8806514a70 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/KeycloakServer.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/KeycloakServer.java @@ -309,6 +309,8 @@ public class KeycloakServer { di.setDeploymentName("Keycloak"); di.setDefaultEncoding("UTF-8"); + di.addInitParameter("keycloak.embedded", "true"); + di.setDefaultServletConfig(new DefaultServletConfig(true)); ServletInfo restEasyDispatcher = Servlets.servlet("Keycloak REST Interface", HttpServlet30Dispatcher.class);