Awesome! Thanks a million Konstantin, it worked.

As for using the /tmp folder. "/tmp/images" is it actually just a place
where I give the images a uuid name, process them, and then save them
elsewhere immediately  I then delete the original so it should be okay.  I
will also add in the File.getAbsolutePath() call as you suggested and take
a look at the tests cases.

Thanks again!

On Wed, Jan 30, 2013 at 3:08 AM, Konstantin Kolinko
<knst.koli...@gmail.com>wrote:

> 2013/1/30 Jimmy Johnson <eclectic.sou...@gmail.com>:
> > Ah, Okay, so I should use the addWebapp method to add a path to an
> external
> > folder?
> >
> > e.g tomcat.addWebapp("/MyWebApp/images", "/tmp/images");
> >
>
> It should not matter whether it is an external folder or not, as you
> are not relying on the autodeployment feature. There are many examples
> of "addWebapp" calls in the test cases.
>
> I would not omit those "File.getAbsolutePath()" calls.
>
> I would beware that "/tmp" is usually cleaned when a server is
> rebooted. Is it OK to use such non-unique name as "images"?
>
>
> > On Tue, Jan 29, 2013 at 2:06 PM, Konstantin Kolinko
> > <knst.koli...@gmail.com>wrote:
> >
> >> 2013/1/29 Jimmy Johnson <eclectic.sou...@gmail.com>:
> >> > System: Mac OS X 10.8
> >> > Tomcat Version: 7.0.30
> >> > Language: Java
> >> >
> >> > I'm trying to set up the context in an embedded Tomcat instance to
> serve
> >> > files from a local directory not within the deployed folder.
> >> >
> >> > In the standard server.xml when using the standard Tomcat
> configuration I
> >> > have this:
> >> >
> >> >     <Context docBase="/MyWebApp/images" path="/tmp/images/"
> >> > reloadable="false"/>
> >> >
> >> > and it works great.
> >> >
> >> > I have tried different variations on the following tomcat embedded
> call
> >> > without success:
> >> >
> >> >     tomcat.addContext(tomcat.getHost(), "/MyWebApp/images",
> >> > "/documents/images/");
> >> >
> >> > I also tried:
> >> >
> >> >     tomcat.addContext("/MyWebApp/images", "/documents/images/");
> >> >
> >> > It seems that Tomcat does see the external docBase folder I have
> >> specified
> >> > because if I specify a path that doesn't exist it complains.  It also
> >> see's
> >> > the context mapping because hitting the "/MyWebApp/images" filters out
> >> the
> >> > request before it hits the spring security filters I have in place and
> >> > reports a 404 file not found.
> >> >
> >> > I am planning on looking at the source this evening and seeing if I
> can
> >> > track down the file path it is looking at, but I thought someone here
> >> might
> >> > know of a solution.
> >> >
> >> > It looks like this grails question was along the same lines:
> >> >
> >> >
> >>
> http://stackoverflow.com/questions/8332851/grails-add-context-to-embedded-tomcat-in-development
> >> >
> >> > But im not using grails.
> >> >
> >> > Here is the full startup code I am using:
> >> >
> >> > package launch;
> >> >  import java.io.File;
> >> > import org.apache.catalina.startup.Tomcat;
> >> >  public class Main {
> >> >  public static void main(String[] args) throws Exception {
> >> >  String webappDirLocation = "/src/main/webapp/";
> >> > Tomcat tomcat = new Tomcat();
> >> >  //The port that we should run on can be set into an environment
> variable
> >> > //Look for that variable and default to 8080 if it isn't there.
> >> > String webPort = System.getenv("PORT");
> >> > if(webPort == null || webPort.isEmpty()) {
> >> > webPort = "8080";
> >> > }
> >> >  tomcat.setPort(Integer.valueOf(webPort));
> >> >  tomcat.addWebapp("/MyWebApp", new
> >> > File(webappDirLocation).getAbsolutePath());
> >> > tomcat.addContext("/MyWebApp/images", "/tmp/images/");
> >>
> >> The above two lines. You already know the "addWebapp" method, so why
> >> are you trying to use "addContext"?
> >>
> >> >  tomcat.start();
> >> > tomcat.getServer().await();
> >> > }
> >> > }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>

Reply via email to