You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by ph...@free.fr on 2014/11/18 16:02:20 UTC
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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Remote resources
Posted by Glen Peterson <gl...@organicdesign.org>.
If it's mounted, does it count as a symlink? If so, this may help, I
don't know:
http://stackoverflow.com/a/26413018/1128668
On Tue, Nov 18, 2014 at 11:38 AM, Mark Thomas <ma...@apache.org> wrote:
> On 18/11/2014 17:22, Ed Rouse wrote:
>>
>>
>>> -----Original Message-----
>>> From: phiroc@free.fr [mailto:phiroc@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-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@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.
>
> No, you do not need a custom class loader to do this.
>
> If the Tomcat process can read the files then you can add them via the
> new (for Tomcat 8) resources configuration.
>
> If the Tomcat process can't read the files them there is nothing you can
> do in Tomcat to change that.
>
> Mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
--
Glen K. Peterson
(828) 393-0081
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Remote resources
Posted by Mark Thomas <ma...@apache.org>.
On 18/11/2014 17:22, Ed Rouse wrote:
>
>
>> -----Original Message-----
>> From: phiroc@free.fr [mailto:phiroc@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-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@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.
No, you do not need a custom class loader to do this.
If the Tomcat process can read the files then you can add them via the
new (for Tomcat 8) resources configuration.
If the Tomcat process can't read the files them there is nothing you can
do in Tomcat to change that.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Remote resources
Posted by Ed Rouse <er...@milner.com>.
> -----Original Message-----
> From: phiroc@free.fr [mailto:phiroc@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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@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>