=== modified file 'dhis-live/src/main/java/org/hisp/dhis/TrayApp.java' --- dhis-live/src/main/java/org/hisp/dhis/TrayApp.java 2010-11-29 15:11:43 +0000 +++ dhis-live/src/main/java/org/hisp/dhis/TrayApp.java 2010-12-06 10:21:18 +0000 @@ -151,16 +151,9 @@ appServer = new WebAppServer(); appServer.init( installDir, this ); + + appServer.start(); - try - { - appServer.start(); - } - catch ( Exception ex ) - { - String message = "Web server failed to start: \n" + ex.toString(); - JOptionPane.showMessageDialog( (JFrame) null, message ); - } } // ------------------------------------------------------------------------- @@ -182,7 +175,8 @@ trayIcon.displayMessage( "Started", "DHIS 2 is running. Your browser will\n be pointed to " + getUrl() + ".", TrayIcon.MessageType.INFO ); trayIcon.setToolTip( "DHIS 2 Server running" ); - trayIcon.setImage( createImage( RUNNING_ICON, "Running icon" ) ); + trayIcon.setImage( createImage( RUNNING_ICON, "Running icon" ) ); + launchBrowser(); } @@ -242,7 +236,7 @@ log.info( "Graceful shutdown..." ); try { - appServer.stop(); + appServer.shutdown(); } catch ( Exception ex ) { === modified file 'dhis-live/src/main/java/org/hisp/dhis/WebAppServer.java' --- dhis-live/src/main/java/org/hisp/dhis/WebAppServer.java 2010-11-29 15:11:43 +0000 +++ dhis-live/src/main/java/org/hisp/dhis/WebAppServer.java 2010-12-06 10:21:18 +0000 @@ -50,7 +50,7 @@ /** * @author Bob Jolliffe */ -public class WebAppServer +public class WebAppServer extends Thread { public static final String DHIS_DIR = "/webapps/dhis"; @@ -87,24 +87,35 @@ } server.setConnectors( new Connector[] { connector } ); - + server.addLifeCycleListener( serverListener ); + + loadDHISContext(installDir+DHIS_DIR); + } + + public void loadDHISContext(String webappPath) + { WebAppContext dhisWebApp = new WebAppContext(); dhisWebApp.setMaxFormContentSize( 5000000 ); - dhisWebApp.setWar( installDir + DHIS_DIR ); - log.info( "Setting DHIS 2 web app context to: " + installDir + DHIS_DIR ); + dhisWebApp.setWar( webappPath ); + log.info( "Setting DHIS 2 web app context to: " + webappPath ); server.setHandler( dhisWebApp ); - server.addLifeCycleListener( serverListener ); } - public void start() - throws Exception + public void run() { - server.start(); - server.join(); + try + { + log.debug("Server thread starting"); + server.start(); + log.debug("Server thread exiting"); + } catch ( Exception ex ) + { + log.error( "Server wouldn't start : " + ex); + } } - public void stop() + public void shutdown() throws Exception { server.stop();