You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2008/12/30 22:45:24 UTC
svn commit: r730249 - in /tomcat/tc6.0.x/trunk: STATUS.txt
java/org/apache/catalina/startup/HostConfig.java webapps/docs/changelog.xml
Author: markt
Date: Tue Dec 30 13:45:24 2008
New Revision: 730249
URL: http://svn.apache.org/viewvc?rev=730249&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=42747
Ensure context.xml takes effect on first deployment. Make processing of context.xml consistent.
Modified:
tomcat/tc6.0.x/trunk/STATUS.txt
tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java
tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=730249&r1=730248&r2=730249&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Tue Dec 30 13:45:24 2008
@@ -131,21 +131,6 @@
Just did that for trunk (r711934; but it contains also other changes).
Caution: at the moment there's no @VERSION@ substitution for service.bat.
-* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=42747
- Ensure context.xml takes effect on first deployment. Make processing of
- context.xml consistent.
- http://svn.apache.org/viewvc?rev=712464&view=rev
- +1: markt, fhanik, jim
- 0: remm (risky, would it be possible to stop backporting risky changes and behavior modifications to 6.0.x ?)
- -1:
-
-* Make sure DIR deployment with context.xml works when configBase does no exist.
- This is required as a result of my previous changes to HostConfig
- http://svn.apache.org/viewvc?rev=718436&view=rev
- +1: markt, fhanik, jim
- 0: remm (risky, would it be possible to stop backporting risky changes and behavior modifications to 6.0.x ?)
- -1:
-
* Make thread pool limits dynamically configurable
http://svn.apache.org/viewvc?rev=719602&view=rev
http://svn.apache.org/viewvc?rev=719628&view=rev
Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java?rev=730249&r1=730248&r2=730249&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java Tue Dec 30 13:45:24 2008
@@ -21,9 +21,11 @@
import java.io.BufferedOutputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -41,6 +43,7 @@
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.core.ContainerBase;
import org.apache.catalina.core.StandardHost;
+import org.apache.catalina.util.IOTools;
import org.apache.catalina.util.StringManager;
import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.modeler.Registry;
@@ -599,7 +602,7 @@
context.setConfigFile(contextXml.getAbsolutePath());
context.setPath(contextPath);
// Add the associated docBase to the redeployed list if it's a WAR
- boolean isWar = false;
+ boolean isExternalWar = false;
boolean isExternal = false;
if (context.getDocBase() != null) {
File docBase = new File(context.getDocBase());
@@ -615,7 +618,7 @@
deployedApp.redeployResources.put(docBase.getAbsolutePath(),
new Long(docBase.lastModified()));
if (docBase.getAbsolutePath().toLowerCase().endsWith(".war")) {
- isWar = true;
+ isExternalWar = true;
}
} else {
log.warn(sm.getString("hostConfig.deployDescriptor.localDocBaseSpecified",
@@ -648,7 +651,7 @@
}
// Add the eventual unpacked WAR and all the resources which will be
// watched inside it
- if (isWar && unpackWARs) {
+ if (isExternalWar && unpackWARs) {
deployedApp.redeployResources.put(expandedDocBase.getAbsolutePath(),
new Long(expandedDocBase.lastModified()));
deployedApp.redeployResources.put
@@ -656,10 +659,12 @@
addWatchedResources(deployedApp, expandedDocBase.getAbsolutePath(), context);
} else {
// Find an existing matching war and expanded folder
- File warDocBase = new File(expandedDocBase.getAbsolutePath() + ".war");
- if (warDocBase.exists()) {
- deployedApp.redeployResources.put(warDocBase.getAbsolutePath(),
- new Long(warDocBase.lastModified()));
+ if (!isExternal) {
+ File warDocBase = new File(expandedDocBase.getAbsolutePath() + ".war");
+ if (warDocBase.exists()) {
+ deployedApp.redeployResources.put(warDocBase.getAbsolutePath(),
+ new Long(warDocBase.lastModified()));
+ }
}
if (expandedDocBase.exists()) {
deployedApp.redeployResources.put(expandedDocBase.getAbsolutePath(),
@@ -727,10 +732,10 @@
/**
* @param contextPath
- * @param dir
+ * @param war
* @param file
*/
- protected void deployWAR(String contextPath, File dir, String file) {
+ protected void deployWAR(String contextPath, File war, String file) {
if (deploymentExists(contextPath))
return;
@@ -744,7 +749,7 @@
(configBase, file.substring(0, file.lastIndexOf(".")) + ".xml");
if (deployXML && !xml.exists()) {
try {
- jar = new JarFile(dir);
+ jar = new JarFile(war);
entry = jar.getJarEntry(Constants.ApplicationContextXml);
if (entry != null) {
istream = jar.getInputStream(entry);
@@ -808,12 +813,32 @@
if(log.isInfoEnabled())
log.info(sm.getString("hostConfig.deployJar", file));
- // Populate redeploy resources with the WAR file
- deployedApp.redeployResources.put
- (dir.getAbsolutePath(), new Long(dir.lastModified()));
-
try {
- Context context = (Context) Class.forName(contextClass).newInstance();
+ Context context = null;
+ if (deployXML && xml.exists()) {
+ synchronized (digester) {
+ try {
+ context = (Context) digester.parse(xml);
+ if (context == null) {
+ log.error(sm.getString("hostConfig.deployDescriptor.error",
+ file));
+ return;
+ }
+ } finally {
+ digester.reset();
+ }
+ }
+ context.setConfigFile(xml.getAbsolutePath());
+ deployedApp.redeployResources.put
+ (xml.getAbsolutePath(), new Long(xml.lastModified()));
+ } else {
+ context = (Context) Class.forName(contextClass).newInstance();
+ }
+
+ // Populate redeploy resources with the WAR file
+ deployedApp.redeployResources.put
+ (war.getAbsolutePath(), new Long(war.lastModified()));
+
if (context instanceof Lifecycle) {
Class clazz = Class.forName(host.getConfigClass());
LifecycleListener listener =
@@ -822,11 +847,6 @@
}
context.setPath(contextPath);
context.setDocBase(file);
- if (xml.exists()) {
- context.setConfigFile(xml.getAbsolutePath());
- deployedApp.redeployResources.put
- (xml.getAbsolutePath(), new Long(xml.lastModified()));
- }
host.addChild(context);
// If we're unpacking WARs, the docBase will be mutated after
// starting the context
@@ -910,7 +930,52 @@
if( log.isDebugEnabled() )
log.debug(sm.getString("hostConfig.deployDir", file));
try {
- Context context = (Context) Class.forName(contextClass).newInstance();
+ Context context = null;
+ File xml = new File(dir, Constants.ApplicationContextXml);
+ if (deployXML && xml.exists()) {
+ // Will only do this on initial deployment. On subsequent
+ // deployments the copied xml file means we'll use
+ // deployDescriptor() instead
+ synchronized (digester) {
+ try {
+ context = (Context) digester.parse(xml);
+ if (context == null) {
+ log.error(sm.getString("hostConfig.deployDescriptor.error",
+ xml));
+ return;
+ }
+ } finally {
+ digester.reset();
+ }
+ }
+ configBase.mkdirs();
+ File xmlCopy = new File(configBase, file + ".xml");
+ InputStream is = null;
+ OutputStream os = null;
+ try {
+ is = new FileInputStream(xml);
+ os = new FileOutputStream(xmlCopy);
+ IOTools.flow(is, os);
+ // Don't catch IOE - let the outer try/catch handle it
+ } finally {
+ try {
+ if (is != null) is.close();
+ } catch (IOException e){
+ // Ignore
+ }
+ try {
+ if (os != null) os.close();
+ } catch (IOException e){
+ // Ignore
+ }
+ }
+ context.setConfigFile(xmlCopy.getAbsolutePath());
+ deployedApp.redeployResources.put
+ (xmlCopy.getAbsolutePath(), new Long(xmlCopy.lastModified()));
+ } else {
+ context = (Context) Class.forName(contextClass).newInstance();
+ }
+
if (context instanceof Lifecycle) {
Class clazz = Class.forName(host.getConfigClass());
LifecycleListener listener =
@@ -919,17 +984,9 @@
}
context.setPath(contextPath);
context.setDocBase(file);
- File configFile = new File(dir, Constants.ApplicationContextXml);
- if (deployXML) {
- context.setConfigFile(configFile.getAbsolutePath());
- }
host.addChild(context);
deployedApp.redeployResources.put(dir.getAbsolutePath(),
new Long(dir.lastModified()));
- if (deployXML) {
- deployedApp.redeployResources.put(configFile.getAbsolutePath(),
- new Long(configFile.lastModified()));
- }
addWatchedResources(deployedApp, dir.getAbsolutePath(), context);
} catch (Throwable t) {
log.error(sm.getString("hostConfig.deployDir.error", file), t);
@@ -1339,4 +1396,4 @@
public long timestamp = System.currentTimeMillis();
}
-}
+}
\ No newline at end of file
Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=730249&r1=730248&r2=730249&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Tue Dec 30 13:45:24 2008
@@ -35,6 +35,12 @@
<section name="Tomcat 6.0.19 (remm)">
<subsection name="Catalina">
<changelog>
+ <fix>
+ <bug>42747</bug>: Ensure context.xml takes effect on first deployment
+ for WAR and DIR deployments. context.xml is now copied to
+ CATALINA_BASE/<engine name>/<host name> for DIR as well as
+ WAR deployments. (markt)
+ </fix>
<fix><bug>43071</bug>Start poller before acceptor (r719267)</fix>
<update>
Fix read/write timeout of async comet operations
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org