> -----Original Message----- > From: phi...@free.fr [mailto:phi...@free.fr] > Sent: Tuesday, November 18, 2014 10:02 AM > To: users@tomcat.apache.org > Subject: Remote resources > > Hello, > > is there a way to access the contents of a directory (e.g., images) on > a remote [Windows] network drive, which is mounted on a Linux > filesystem (e.g., /mnt/myremotedrive), from a Java application running > on a Tomcat Server? > > What makes this task problematic is the fact that the images are stored > in a location which is not normally accessible by Tomcat > (/mnt/myremotedrive), or by its applications. > > Many thanks. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org
There is, but it's not easy. You need to create a custom class loader that extends WebappClassLoaderBase, then create a DirResourceSet and add it to the root. The way I did it was with a custom context that I put into a singleton class so I could access it from the loader. Then you just DirResourceSet drs = new DirResourceSet(wsRoot, "/images", "/mnt/myremotedrive/images", "/"); wsRoot.addPostResources(drs); Once this is working, you can access the images from /images as usual. You have to set up a context.xml file in the META-INF directory of your app similar to this: <?xml version="1.0" encoding="UTF-8" ?> <Context> <Resources className="context package and class" /> <Loader loaderClass="classloader package and class" delegate="false" /> </Context>