tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Mayr <ste...@mayr-stefan.de>
Subject Re: WebApp access to a LAN share
Date Sun, 16 Oct 2011 11:39:46 GMT
Am 16.10.2011 10:31, schrieb André Warnier:
> Léa Massiot wrote:
>> Hello,
>>
>> Thank you for reading my post.
>>
>> Here is my problem:
>> - I have two machines S and M on the same LAN.
>> - S is a Debian machine running a Tomcat server.
>> - And I have a WebApp W deployed on this Tomcat server.
>> - M is a Windows machine which hosts some files for W. - S and M
>> belong to the same Samba domain.
>> - On M, the WebApp files are stored in a directory: "C:\p1\p2\".
>> - "p2" is a share.
>> - Somewhere in the WebApp Java code, I have declared a "final" to
>> store the
>> files path.
>> Here is what I wrote:
>> public static final String s_path = "//M/p2/";
>> - Now, when I manipulate the WebApp in such a way a file "f.xml"
>> located in
>> "C:\p1\p2\p3\" has to be opened and read, I get the following error:
>> java.io.FileNotFoundException: /M/p2/p3/f.xml (No such file or directory)
>> My question is: how do I have to declare "s_path" to properly access,
>> from S
>> (W), those files which are stored on M?
>> (I basically want to have the data on one machine and Tomcat on another
>> machine).
>
> Without discussing the pros and cons of the underlying logic, the issue
> here is that Java (on S) does not understand that "//M/p2/" means a
> "network share" in Microsoft notation.
> (Only Windows understands that).
> What you need to to is "mounting" that network share to a local (Linux)
> mountpoint on S.
> Then in Java you access that mountpoint, not the original share.
>
> This is quite Off-Topic regarding Tomcat and even Java, but here is an
> idea :
>
> On the Linux machine,
>
> 1) create an empty directory /mnt/M/p2
>
> 2) in the file /etc/fstab, add the following line (all on one line):
> //M/p2 /mnt/M/p2 cifs
> rw,username=xxx,password=yyy,uid=uuu,gid=ggg,dir_mode=0775,file_mode=0774 0
> 2
>
> (xxx and yyy are the (Windows) user-id and password needed to access
> that share; uuu and ggg are a Linux user-id and group under which the
> remote files will "look like" under Linux). And you will need to get
> someone to help you with the other parameters, to adjust them to your
> needs.
>
> 3) under Linux, isssue the command "mount -a". This will read the file
> /etc/fstab, and mount all the mountpoint that ar not already mounted
> (like the new one above).
>
> After this, under Linux, whenever you access the directory "/mnt/M/p2",
> you will see the files on the remote M nachine.
> And in Java, you then access this the same way, as "/mnt/M/p2".
>

So machine "M" is essentially a fileserver that is accessed by 
application "W".

I see two options:
1. Abstract it on OS level: Linux machine "S" mounts the fileshare into 
the local directory /M/p2 via CIFS/SMBFS. Details were just outlined by 
André
2. Solve it in your application using jCIFS (or another component) to 
access a remote Windows fileshare

Independent recommendation: make s_path a configuration variable. 
Hardcoded paths are no good idea

- Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message