You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2013/03/22 01:37:38 UTC
[Bug 54741] New: Add
org.apache.catalina.startup.Tomcat#addWebapp(String, URL) method
https://issues.apache.org/bugzilla/show_bug.cgi?id=54741
Bug ID: 54741
Summary: Add
org.apache.catalina.startup.Tomcat#addWebapp(String,
URL) method
Product: Tomcat 8
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Catalina
Assignee: dev@tomcat.apache.org
Reporter: nicholas@nicholaswilliams.net
Classification: Unclassified
Currently Tomcat can only deploy from a WAR file or directory that exists on
the real file system. It would be nice, in an embedded Tomcat (one JAR)
situation, to be able deploy an application using a JAR file resource without
having to first copy that resource to the local file system.
URL war = this.getClass().getResource("/MyApp.war")
Tomcat tomcat = new Tomcat();
...
tomcat.addWebapp("", war);
I tried doing this with the actual URL string, but that did not work:
URL war = this.getClass().getResource("/MyApp.war")
Tomcat tomcat = new Tomcat();
...
tomcat.addWebapp("", war.toString());
SEVERE: Exception fixing docBase for context []
java.io.FileNotFoundException:
C:\Users\Nicholas\Desktop\Project\target\.extract\webapps\jar:file:\C:\Users\Nicholas\Desktop\Project\target\MyApp-1.0.0-SNAPSHOT.jar
(The filename, directory name, or volume label syntax is incorrect)
I had to do this instead:
URL war = this.getClass().getResource("/MyApp.war")
File warFile = new File(extractDirectory, "MyApp.war");
FileUtils.copyURLToFile(war, warFile);
Tomcat tomcat = new Tomcat();
...
tomcat.addWebapp("", warFile.getAbsolutePath());
Of course, that's ignoring all the error-checking logic. It's just a nuisance
to have to do this. Surely, since Tomcat unzips the WAR file anyway, it could
do it on a URL resource instead of having to copy the file to the local
filesystem.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 54741] Add org.apache.catalina.startup.Tomcat#addWebapp(String,
URL) method
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54741
--- Comment #1 from Christopher Schultz <ch...@christopherschultz.net> ---
FWIW, Tomcat can be configured to NOT expand WAR files, so you can't rely on a
filesystem at all.
As previously discussed, StandardContext.setDocBase says it can take "an
absolute pathname, a relative pathname, or a URL.". I believe you stated that
trying to use a URL that points to a WAR file within a JAR file does not work.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org