tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1310131 - in /tomcat/maven-plugin/trunk: tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java
Date Thu, 05 Apr 2012 23:23:56 GMT
Author: olamy
Date: Thu Apr  5 23:23:55 2012
New Revision: 1310131

URL: http://svn.apache.org/viewvc?rev=1310131&view=rev
Log:
[MTOMCAT-133] Servlet mapping to "/" does not work
apply same fix for the exec war feature.

Modified:
    tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
    tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java

Modified: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java?rev=1310131&r1=1310130&r2=1310131&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
(original)
+++ tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
Thu Apr  5 23:23:55 2012
@@ -306,6 +306,7 @@ public abstract class AbstractExecWarMoj
                 os.putArchiveEntry( new JarArchiveEntry( StringUtils.removeStart( path, "/"
) + ".war" ) );
                 IOUtils.copy( new FileInputStream( projectArtifact.getFile() ), os );
                 os.closeArchiveEntry();
+
                 properties.put( Tomcat7Runner.WARS_KEY, StringUtils.removeStart( path, "/"
) + ".war|" + path );
             }
 
@@ -364,6 +365,11 @@ public abstract class AbstractExecWarMoj
                 properties.put( Tomcat7Runner.USE_SERVER_XML_KEY, Boolean.FALSE.toString()
);
             }
 
+            os.putArchiveEntry( new JarArchiveEntry( "conf/web.xml" ) );
+            IOUtils.copy( getClass().getResourceAsStream( "/conf/web.xml" ), os );
+            os.closeArchiveEntry();
+
+
             properties.store( tmpPropertiesFileOutputStream, "created by Apache Tomcat Maven
plugin" );
 
             tmpPropertiesFileOutputStream.flush();

Modified: tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java?rev=1310131&r1=1310130&r2=1310131&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java
(original)
+++ tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java
Thu Apr  5 23:23:55 2012
@@ -19,8 +19,11 @@ package org.apache.tomcat.maven.runner;
  */
 
 import org.apache.catalina.Context;
+import org.apache.catalina.Host;
 import org.apache.catalina.connector.Connector;
+import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.startup.Catalina;
+import org.apache.catalina.startup.ContextConfig;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.valves.AccessLogValve;
 import org.apache.tomcat.util.http.fileupload.FileUtils;
@@ -163,7 +166,33 @@ public class Tomcat7Runner
         }
         else
         {
-            tomcat = new Tomcat();
+            tomcat = new Tomcat()
+            {
+                public Context addWebapp( Host host, String url, String name, String path
)
+                {
+
+                    Context ctx = new StandardContext();
+                    ctx.setName( name );
+                    ctx.setPath( url );
+                    ctx.setDocBase( path );
+
+                    ContextConfig ctxCfg = new ContextConfig();
+                    ctx.addLifecycleListener( ctxCfg );
+
+                    ctxCfg.setDefaultWebXml( new File( extractDirectory, "conf/web.xml" ).getAbsolutePath()
);
+
+                    if ( host == null )
+                    {
+                        getHost().addChild( ctx );
+                    }
+                    else
+                    {
+                        host.addChild( ctx );
+                    }
+
+                    return ctx;
+                }
+            };
 
             if ( this.enableNaming() )
             {
@@ -265,15 +294,18 @@ public class Tomcat7Runner
             for ( Map.Entry<String, String> entry : this.webappWarPerContext.entrySet()
)
             {
                 String baseDir = null;
+                Context context = null;
                 if ( entry.getKey().equals( "/" ) )
                 {
                     baseDir = new File( extractDirectory, "webapps/ROOT.war" ).getAbsolutePath();
+                    context = tomcat.addWebapp( "", baseDir );
                 }
                 else
                 {
                     baseDir = new File( extractDirectory, "webapps/" + entry.getValue() ).getAbsolutePath();
+                    context = tomcat.addWebapp( entry.getKey(), baseDir );
                 }
-                Context context = tomcat.addWebapp( entry.getKey(), baseDir );
+
                 URL contextFileUrl = getContextXml( baseDir );
                 if ( contextFileUrl != null )
                 {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message