Commit af5d059d authored by Romain Bioteau's avatar Romain Bioteau

Fix endless loop when tomcat fails to start

parent 0e6997c9
...@@ -96,7 +96,7 @@ public class BOSWebServerManager { ...@@ -96,7 +96,7 @@ public class BOSWebServerManager {
protected static final String TMP_DIR = ProjectUtil.getBonitaStudioWorkFolder().getAbsolutePath(); protected static final String TMP_DIR = ProjectUtil.getBonitaStudioWorkFolder().getAbsolutePath();
protected final String tomcatInstanceLocation = new File(ResourcesPlugin protected final String tomcatInstanceLocation = new File(ResourcesPlugin
.getWorkspace().getRoot().getLocation().toFile(), "tomcat") .getWorkspace().getRoot().getLocation().toFile(), "tomcat")
.getAbsolutePath(); .getAbsolutePath();
private static final String TOMCAT_LOG_FILE = "tomcat.log"; private static final String TOMCAT_LOG_FILE = "tomcat.log";
private static final int MAX_SERVER_START_TIME = 300000; private static final int MAX_SERVER_START_TIME = 300000;
...@@ -176,7 +176,7 @@ public class BOSWebServerManager { ...@@ -176,7 +176,7 @@ public class BOSWebServerManager {
public synchronized void startServer(final IProgressMonitor monitor) { public synchronized void startServer(final IProgressMonitor monitor) {
if (!serverIsStarted()) { if (!serverIsStarted()) {
BonitaHomeUtil.initBonitaHome(); BonitaHomeUtil.initBonitaHome();
copyTomcatBundleInWorkspace( monitor); copyTomcatBundleInWorkspace(monitor);
monitor.subTask(Messages.startingWebServer); monitor.subTask(Messages.startingWebServer);
if (BonitaStudioLog.isLoggable(IStatus.OK)) { if (BonitaStudioLog.isLoggable(IStatus.OK)) {
BonitaStudioLog.debug("Starting tomcat...", BonitaStudioLog.debug("Starting tomcat...",
...@@ -251,27 +251,13 @@ public class BOSWebServerManager { ...@@ -251,27 +251,13 @@ public class BOSWebServerManager {
} }
private void waitServerRunning(final IProgressMonitor monitor) { private void waitServerRunning(final IProgressMonitor monitor) {
int totalTime = 0; if (tomcat.getServerState() == IServer.STATE_STARTED) {
while (totalTime < MAX_SERVER_START_TIME && tomcat != null BonitaStudioLog.debug("Tomcat server started.",
&& tomcat.getServerState() != IServer.STATE_STARTED) { EnginePlugin.PLUGIN_ID);
try { } else {
Thread.sleep(1000); BonitaStudioLog.debug("Tomcat failed to start. Check the log file for more informations. (bonita.log or catalina.log)",
if (BonitaStudioLog.isLoggable(IStatus.OK)) { EnginePlugin.PLUGIN_ID);
BonitaStudioLog.debug("Tomcat server state: " + tomcat.getServerState(), if (!PlatformUtil.isHeadless()) {
EnginePlugin.PLUGIN_ID);
}
totalTime = totalTime + 1000;
} catch (final InterruptedException e) {
BonitaStudioLog.error(e, EnginePlugin.PLUGIN_ID);
}
}
if (BonitaStudioLog.isLoggable(IStatus.OK)) {
if (tomcat.getServerState() == IServer.STATE_STARTED) {
BonitaStudioLog.debug("Tomcat server started.",
EnginePlugin.PLUGIN_ID);
} else {
BonitaStudioLog.debug("Tomcat failed to start.",
EnginePlugin.PLUGIN_ID);
Display.getDefault().syncExec(new Runnable() { Display.getDefault().syncExec(new Runnable() {
@Override @Override
...@@ -282,8 +268,8 @@ public class BOSWebServerManager { ...@@ -282,8 +268,8 @@ public class BOSWebServerManager {
Messages.cannotStartTomcatMessage); Messages.cannotStartTomcatMessage);
} }
}); });
return;
} }
return;
} }
connectWithRetries(); connectWithRetries();
} }
...@@ -376,7 +362,7 @@ public class BOSWebServerManager { ...@@ -376,7 +362,7 @@ public class BOSWebServerManager {
protected IServer configureServer(final IRuntime runtime, final IServerType sType, final IFile file, final IFolder configurationFolder, protected IServer configureServer(final IRuntime runtime, final IServerType sType, final IFile file, final IFolder configurationFolder,
final IProgressMonitor monitor) final IProgressMonitor monitor)
throws CoreException { throws CoreException {
final IServer server = ServerCore.findServer(BONITA_TOMCAT_SERVER_ID); final IServer server = ServerCore.findServer(BONITA_TOMCAT_SERVER_ID);
IServerWorkingCopy serverWC = null; IServerWorkingCopy serverWC = null;
if (server != null) { if (server != null) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment