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: nicho...@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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to