You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2006/05/24 01:24:58 UTC
svn commit: r409023 - in /geronimo/branches/1.1:
applications/console-framework/src/webapp/WEB-INF/
applications/console-standard/
applications/console-standard/src/java/org/apache/geronimo/console/configmanager/
applications/console-standard/src/webap...
Author: djencks
Date: Tue May 23 16:24:58 2006
New Revision: 409023
URL: http://svn.apache.org/viewvc?rev=409023&view=rev
Log:
GERONIMO-2006. Fix tomcat buffer overrun, try to upgrade plans when old plan format is detected. +1 from jgenender, acabrera, gdamour, possible jsisson and djencks
Modified:
geronimo/branches/1.1/applications/console-framework/src/webapp/WEB-INF/web.xml
geronimo/branches/1.1/applications/console-standard/project.xml
geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java
geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/configmanager/deploy.jsp
geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/web.xml
geronimo/branches/1.1/configs/console-jetty/project.xml
geronimo/branches/1.1/configs/console-tomcat/project.xml
Modified: geronimo/branches/1.1/applications/console-framework/src/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/applications/console-framework/src/webapp/WEB-INF/web.xml?rev=409023&r1=409022&r2=409023&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-framework/src/webapp/WEB-INF/web.xml (original)
+++ geronimo/branches/1.1/applications/console-framework/src/webapp/WEB-INF/web.xml Tue May 23 16:24:58 2006
@@ -71,6 +71,20 @@
<param-value>/graphs</param-value>
</init-param>
</servlet>
+
+ <servlet>
+ <display-name>Plan Export Forward Servlet</display-name>
+ <servlet-name>plan-export-forward</servlet-name>
+ <servlet-class>org.apache.geronimo.console.servlet.ContextForwardServlet</servlet-class>
+ <init-param>
+ <param-name>context-path</param-name>
+ <param-value>/console-standard</param-value>
+ </init-param>
+ <init-param>
+ <param-name>servlet-path</param-name>
+ <param-value>/plan-export</param-value>
+ </init-param>
+ </servlet>
<servlet-mapping>
<servlet-name>se-console</servlet-name>
@@ -91,6 +105,10 @@
<servlet-mapping>
<servlet-name>svg-forward</servlet-name>
<url-pattern>/graphs/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>plan-export-forward</servlet-name>
+ <url-pattern>/plan-export</url-pattern>
</servlet-mapping>
<security-constraint>
Modified: geronimo/branches/1.1/applications/console-standard/project.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/applications/console-standard/project.xml?rev=409023&r1=409022&r2=409023&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/project.xml (original)
+++ geronimo/branches/1.1/applications/console-standard/project.xml Tue May 23 16:24:58 2006
@@ -92,6 +92,11 @@
</dependency>
<dependency>
<groupId>geronimo</groupId>
+ <artifactId>geronimo-upgrade</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>geronimo</groupId>
<artifactId>geronimo-deploy-jsr88</artifactId>
<version>${pom.currentVersion}</version>
</dependency>
Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java?rev=409023&r1=409022&r2=409023&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java (original)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java Tue May 23 16:24:58 2006
@@ -17,8 +17,11 @@
package org.apache.geronimo.console.configmanager;
+import java.io.ByteArrayInputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.StringWriter;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
@@ -34,6 +37,9 @@
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
@@ -43,17 +49,21 @@
import org.apache.geronimo.deployment.plugin.ConfigIDExtractor;
import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.upgrade.Upgrade1_0To1_1;
+import org.w3c.dom.Document;
public class DeploymentPortlet extends BasePortlet {
+ private static final String DEPLOY_VIEW = "/WEB-INF/view/configmanager/deploy.jsp";
+ private static final String HELP_VIEW = "/WEB-INF/view/configmanager/deployHelp.jsp";
+ private static final String MIGRATED_PLAN_PARM = "migratedPlan";
+ private static final String ORIGINAL_PLAN_PARM = "originalPlan";
+ private static final String FULL_STATUS_PARM = "fullStatusMessage";
+ private static final String ABBR_STATUS_PARM = "abbrStatusMessage";
private PortletRequestDispatcher deployView;
-
private PortletRequestDispatcher helpView;
- private boolean messageNotRendered = true;
-
public void processAction(ActionRequest actionRequest,
ActionResponse actionResponse) throws PortletException, IOException {
- messageNotRendered = true;
if (!PortletFileUpload.isMultipartContent(actionRequest)) {
throw new PortletException("Expected file upload");
}
@@ -107,6 +117,7 @@
throw new PortletException(e);
}
DeploymentFactoryManager dfm = DeploymentFactoryManager.getInstance();
+ FileInputStream fis = null;
try {
DeploymentManager mgr = dfm.getDeploymentManager("deployer:geronimo:inVM", null, null);
try {
@@ -128,23 +139,58 @@
while(progress.getDeploymentStatus().isRunning()) {
Thread.sleep(100);
}
-
+
+ String abbrStatusMessage;
+ String fullStatusMessage = null;
if(progress.getDeploymentStatus().isCompleted()) {
- String message = "The application was successfully "+(isRedeploy ? "re" : "")+"deployed.<br/>";
+ abbrStatusMessage = "The application was successfully "+(isRedeploy ? "re" : "")+"deployed.<br/>";
// start installed app/s
if (!isRedeploy && startApp != null && !startApp.equals("")) {
progress = mgr.start(progress.getResultTargetModuleIDs());
while(progress.getDeploymentStatus().isRunning()) {
Thread.sleep(100);
}
- message+="The application was successfully started";
+ abbrStatusMessage+="The application was successfully started";
}
- actionResponse.setRenderParameter("outcome",message);
} else {
- actionResponse.setRenderParameter("outcome", "Deployment failed: "+progress.getDeploymentStatus().getMessage());
+ fullStatusMessage = progress.getDeploymentStatus().getMessage();
+ // for the abbreviated status message clip off everything
+ // after the first line, which in most cases means the gnarly stacktrace
+ abbrStatusMessage = "Deployment failed:<br/>"
+ + fullStatusMessage.substring(0, fullStatusMessage.indexOf('\n'));
+ // try to provide an upgraded version of the plan
+ try {
+ if (planFile != null && planFile.exists()) {
+ byte[] plan = new byte[(int) planFile.length()];
+ fis = new FileInputStream(planFile);
+ fis.read(plan);
+ DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document doc = documentBuilder.parse(new ByteArrayInputStream(plan));
+ // v1.1 switched from configId to moduleId
+ String configId = doc.getDocumentElement().getAttribute("configId");
+ if (configId != null && !("".equals(configId))) {
+ StringWriter sw = new StringWriter();
+ new Upgrade1_0To1_1().upgrade(new ByteArrayInputStream(plan), sw);
+ // have to store the original and upgraded plans in the session
+ // because the buffer size for render parameters is sometimes not
+ // big enough
+ actionRequest.getPortletSession().setAttribute(MIGRATED_PLAN_PARM, sw.getBuffer());
+ actionRequest.getPortletSession().setAttribute(ORIGINAL_PLAN_PARM, new String(plan));
+ }
+ }
+ } catch (Exception e) {
+ // cannot provide a migrated plan in this case, most likely
+ // because the deployment plan would not parse. a valid
+ // status message has already been provided in this case
+ }
}
+ // have to store the status messages in the portlet session
+ // because the buffer size for render parameters is sometimes not big enough
+ actionRequest.getPortletSession().setAttribute(FULL_STATUS_PARM, fullStatusMessage);
+ actionRequest.getPortletSession().setAttribute(ABBR_STATUS_PARM, abbrStatusMessage);
} finally {
mgr.release();
+ if (fis!=null) fis.close();
}
} catch (Exception e) {
throw new PortletException(e);
@@ -184,13 +230,23 @@
protected void doView(RenderRequest renderRequest,
RenderResponse renderResponse) throws PortletException, IOException {
- if (messageNotRendered) {
- renderRequest.setAttribute("outcome", renderRequest
- .getParameter("outcome"));
- messageNotRendered = false;
- }
+ // The deployment plans and messages from the deployers sometime exceeds
+ // the buffer size for render attributes. To avoid the buffer
+ // overrun the render attributes are temporarily stored in the portlet
+ // session during the processAction phase and then copied into render
+ // attributes here so the JSP has easier access to them. This seems
+ // to only be an issue on tomcat.
+ copyRenderAttribute(renderRequest, FULL_STATUS_PARM);
+ copyRenderAttribute(renderRequest, ABBR_STATUS_PARM);
+ copyRenderAttribute(renderRequest, MIGRATED_PLAN_PARM);
+ copyRenderAttribute(renderRequest, ORIGINAL_PLAN_PARM);
deployView.include(renderRequest, renderResponse);
- // clear previous message for next rendering
+ }
+
+ private void copyRenderAttribute(RenderRequest renderRequest, String attr) {
+ Object value = renderRequest.getPortletSession().getAttribute(attr);
+ renderRequest.getPortletSession().removeAttribute(attr);
+ renderRequest.setAttribute(attr, value);
}
protected void doHelp(RenderRequest renderRequest,
@@ -200,8 +256,8 @@
public void init(PortletConfig portletConfig) throws PortletException {
super.init(portletConfig);
- deployView = portletConfig.getPortletContext().getRequestDispatcher("/WEB-INF/view/configmanager/deploy.jsp");
- helpView = portletConfig.getPortletContext().getRequestDispatcher("/WEB-INF/view/configmanager/deployHelp.jsp");
+ deployView = portletConfig.getPortletContext().getRequestDispatcher(DEPLOY_VIEW);
+ helpView = portletConfig.getPortletContext().getRequestDispatcher(HELP_VIEW);
}
public void destroy() {
Modified: geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/configmanager/deploy.jsp
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/configmanager/deploy.jsp?rev=409023&r1=409022&r2=409023&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/configmanager/deploy.jsp (original)
+++ geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/configmanager/deploy.jsp Tue May 23 16:24:58 2006
@@ -1,9 +1,67 @@
-<%@ page import="java.io.PrintWriter"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<portlet:defineObjects/>
-<c:if test="${! outcome}"><pre>${outcome}</pre></c:if>
+<script>
+// toggle the display state of an element
+function <portlet:namespace/>toggleDisplay(id) {
+ var element = document.getElementById("<portlet:namespace/>"+id);
+ if (element.style.display == 'inline') {
+ element.style.display='none';
+ } else {
+ element.style.display='inline';
+ }
+}
+</script>
+
+<!-- Abbreviated status message -->
+<c:if test="${!(empty abbrStatusMessage)}">
+ <div id="<portlet:namespace/>abbrStatusMessage" style="display:inline">
+ ${abbrStatusMessage}<br/>
+ <c:if test="${!(empty fullStatusMessage)}">
+ <button onclick="<portlet:namespace/>toggleDisplay('fullStatusMessage');<portlet:namespace/>toggleDisplay('abbrStatusMessage');return false;">Show full details</button>
+ </c:if>
+ </div>
+</c:if>
+<!-- Full status message -->
+<c:if test="${!(empty fullStatusMessage)}">
+ <div id="<portlet:namespace/>fullStatusMessage" style="display:none">
+ <pre>
+<c:out escapeXml="true" value="${fullStatusMessage}"/>
+ </pre>
+ </div>
+</c:if>
+
+<P/>
+
+<!-- Migrated Plan -->
+<c:if test="${!(empty migratedPlan)}">
+<hr/><br/>
+The deployment plan you provided appears to be for a previous version of
+the application server.
+A migrated version of your plan is provided below for your convenience. Not all
+deployment plans can be fully migrated so some manual editing may be required
+before the migrated plan can be deployed.
+<p/>
+<div id="<portlet:namespace/>migratedPlan" style="display:inline">
+Migrated plan:
+<form method="POST" action="/console/plan-export">
+ <textarea name="migratedPlan" rows=10 cols=80><c:out escapeXml="true" value="${migratedPlan}"/></textarea>
+ <br/>
+ <button onclick="<portlet:namespace/>toggleDisplay('originalPlan');<portlet:namespace/>toggleDisplay('migratedPlan');return false;">Show original plan</button>
+ <input type="submit" value="Save this plan locally"/>
+</form>
+</div>
+<div id="<portlet:namespace/>originalPlan" style="display:none">
+Original plan:
+<form>
+ <textarea rows=10 cols=80><c:out escapeXml="true" value="${originalPlan}"/></textarea><br/>
+ <button onclick="<portlet:namespace/>toggleDisplay('migratedPlan');<portlet:namespace/>toggleDisplay('originalPlan');return false;">Show Migrated plan</button>
+</form>
+</div>
+<br/><hr/><br/>
+</c:if>
+
<form enctype="multipart/form-data" method="POST" action="<portlet:actionURL><portlet:param name="action" value="deploy"/></portlet:actionURL>">
<table>
<tr><th align="right">Archive: </th><td><input type="file" name="module" /></td></tr>
Modified: geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/web.xml?rev=409023&r1=409022&r2=409023&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/web.xml (original)
+++ geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/web.xml Tue May 23 16:24:58 2006
@@ -763,6 +763,11 @@
<servlet-name>maven-repo</servlet-name>
<servlet-class>org.apache.geronimo.console.car.GeronimoAsMavenServlet</servlet-class>
</servlet>
+<servlet>
+ <display-name>Plan Export Servlet</display-name>
+ <servlet-name>plan-export</servlet-name>
+ <servlet-class>org.apache.geronimo.console.configmanager.PlanExportServlet</servlet-class>
+</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
@@ -775,6 +780,10 @@
<servlet-mapping>
<servlet-name>maven-repo</servlet-name>
<url-pattern>/maven-repo/*</url-pattern>
+</servlet-mapping>
+<servlet-mapping>
+ <servlet-name>plan-export</servlet-name>
+ <url-pattern>/plan-export</url-pattern>
</servlet-mapping>
Modified: geronimo/branches/1.1/configs/console-jetty/project.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/configs/console-jetty/project.xml?rev=409023&r1=409022&r2=409023&view=diff
==============================================================================
--- geronimo/branches/1.1/configs/console-jetty/project.xml (original)
+++ geronimo/branches/1.1/configs/console-jetty/project.xml Tue May 23 16:24:58 2006
@@ -146,6 +146,14 @@
</dependency>
<dependency>
<groupId>geronimo</groupId>
+ <artifactId>geronimo-upgrade</artifactId>
+ <version>${geronimo_version}</version>
+ <properties>
+ <geronimo.dependency>true</geronimo.dependency>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>geronimo</groupId>
<artifactId>geronimo-management</artifactId>
<version>${geronimo_version}</version>
<properties>
Modified: geronimo/branches/1.1/configs/console-tomcat/project.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/configs/console-tomcat/project.xml?rev=409023&r1=409022&r2=409023&view=diff
==============================================================================
--- geronimo/branches/1.1/configs/console-tomcat/project.xml (original)
+++ geronimo/branches/1.1/configs/console-tomcat/project.xml Tue May 23 16:24:58 2006
@@ -146,6 +146,14 @@
</dependency>
<dependency>
<groupId>geronimo</groupId>
+ <artifactId>geronimo-upgrade</artifactId>
+ <version>${geronimo_version}</version>
+ <properties>
+ <geronimo.dependency>true</geronimo.dependency>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>geronimo</groupId>
<artifactId>geronimo-management</artifactId>
<version>${geronimo_version}</version>
<properties>