> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> Sent: Tuesday, November 18, 2014 10:02 AM
> To: [email protected]
> 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: [email protected]
> For additional commands, e-mail: [email protected]
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>