Index: src/main/java/org/codehaus/cargo/deployer/jetty/DeployerServlet.java =================================================================== --- src/main/java/org/codehaus/cargo/deployer/jetty/DeployerServlet.java (revision 3107) +++ src/main/java/org/codehaus/cargo/deployer/jetty/DeployerServlet.java (working copy) @@ -31,6 +31,9 @@ import java.lang.reflect.Method; import java.net.URI; import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -123,7 +126,20 @@ break; } } - + + // if the default server classes array are initialized (not null) then this block prepends + // the "-org.eclipse.jetty.server.handler.ContextHandler" pattern to the array making + // visible the class for the deployer webapp + // + // see the following link for more information + // http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading#Setting_Server_Classes + String[] defaultServerClasses = this.context.getServerClasses(); + if (defaultServerClasses != null) { + List extendedServerClasses = new ArrayList(Arrays.asList(defaultServerClasses)); + extendedServerClasses.add(0, "-org.eclipse.jetty.server.handler.ContextHandler"); + this.context.setServerClasses(extendedServerClasses.toArray(new String[0])); + } + Log.debug("Started the CARGO Jetty deployer servlet with context " + this.context); } @@ -138,46 +154,35 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String[] serverClasses = this.context.getServerClasses(); + String contextPath = request.getParameter("path"); + String warURL = request.getParameter("war"); - try - { - this.context.setServerClasses(null); + String command = request.getServletPath(); - String contextPath = request.getParameter("path"); - String warURL = request.getParameter("war"); - - String command = request.getServletPath(); - - if (command.equals("/deploy")) - { - deploy(response, contextPath, warURL); - } - else if (command.equals("/undeploy")) - { - undeploy(response, contextPath); - } - else if (command.equals("/stop")) - { - stop(response, contextPath); - } - else if (command.equals("/start")) - { - start(response, contextPath); - } - else if (command.equals("/reload")) - { - reload(response, contextPath); - } - else - { - response.sendError(400, "Command " + command + " is unknown"); - } + if (command.equals("/deploy")) + { + deploy(response, contextPath, warURL); } - finally + else if (command.equals("/undeploy")) { - this.context.setServerClasses(serverClasses); + undeploy(response, contextPath); } + else if (command.equals("/stop")) + { + stop(response, contextPath); + } + else if (command.equals("/start")) + { + start(response, contextPath); + } + else if (command.equals("/reload")) + { + reload(response, contextPath); + } + else + { + response.sendError(400, "Command " + command + " is unknown"); + } } /** @@ -191,26 +196,15 @@ protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String[] serverClasses = this.context.getServerClasses(); - - try + String command = request.getServletPath(); + if (command.equals("/deploy")) { - this.context.setServerClasses(null); - - String command = request.getServletPath(); - if (command.equals("/deploy")) - { - String contextPath = request.getParameter("path"); - deployArchive(request, response, contextPath); - } - else - { - sendError(response, "Command " + command + " is not reconized with PUT"); - } + String contextPath = request.getParameter("path"); + deployArchive(request, response, contextPath); } - finally + else { - this.context.setServerClasses(serverClasses); + sendError(response, "Command " + command + " is not reconized with PUT"); } } @@ -260,22 +254,6 @@ inputStream.close(); outputStream.flush(); outputStream.close(); - - WebAppContext webappcontext = new WebAppContext(); - webappcontext.setContextPath(contextPath); - webappcontext.setWar(webappLocation); - webappcontext.setDefaultsDescriptor(configHome + "/etc/webdefault.xml"); - chc.addHandler(webappcontext); - try - { - webappcontext.start(); - } - catch (Exception e) - { - sendError(response, "Unexpected error when trying to start the webapp"); - Log.warn(e); - return; - } } sendMessage(response, "Deployed Web APP");