2013/11/6 <[email protected]>:
> Author: olamy
> Date: Wed Nov 6 01:31:25 2013
> New Revision: 1539209
>
> URL: http://svn.apache.org/r1539209
> Log:
> [MTOMCAT-211] The .war file is not extracted from executable war
>
> Modified:
>
> tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java
>
> 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=1539209&r1=1539208&r2=1539209&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
> Wed Nov 6 01:31:25 2013
> @@ -560,28 +560,35 @@ public class Tomcat7Runner
> InputStream inputStream = null;
> try
> {
> + File expandFile = null;
> inputStream =
> Thread.currentThread().getContextClassLoader().getResourceAsStream(
> entry.getValue() );
> if ( !useServerXml() )
> {
> if ( entry.getKey().equals( "/" ) )
> {
> - File expandFile = new File( extractDirectory,
> "webapps/ROOT.war" );
> - debugMessage( "expand to file:" +
> expandFile.getPath() );
> - expand( inputStream, expandFile );
> + expandFile = new File( extractDirectory,
> "webapps/ROOT.war" );
> }
> else
> {
> - File expandFile = new File( extractDirectory,
> "webapps/" + entry.getValue() );
> - debugMessage( "expand to file:" +
> expandFile.getPath() );
> - expand( inputStream, expandFile );
> + expandFile = new File( extractDirectory, "webapps/"
> + entry.getValue() );
> }
> }
> else
> {
> - File expandFile = new File( extractDirectory, "webapps/"
> + entry.getValue() );
> - debugMessage( "expand to file:" + expandFile.getPath() );
> - expand( inputStream, new File( extractDirectory,
> "webapps/" + entry.getValue() ) );
> + expandFile = new File( extractDirectory, "webapps/" +
> entry.getValue() );
> }
> +
> + debugMessage( "expand to file:" + expandFile.getPath() );
> +
> + // MTOMCAT-211 ensure parent directories created
> +
> + if ( !expandFile.getParentFile().mkdirs() )
> + {
> + throw new Exception( "FATAL: impossible to create
> directories:" + expandFile.getParentFile() );
> + }
The above mkdirs() call returns "false" if those directories already exist.
Can webappWarPerContext.entrySet() contain several wars? If so then I
expect the code to throw the above exception when processing the
second war.
In Tomcat such code is usually written like this:
quoting from o.a.c.core.StandardContext
[[[
if (!dir.mkdirs() && !dir.isDirectory()) {
log.warn(sm.getString("standardContext.workCreateFail", dir,
getName()));
}
]]]
> +
> + expand( inputStream, expandFile );
> +
> }
> finally
> {
>
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]