简体   繁体   English

无法通过Apache Tomcat访问网络文件夹

[英]Can't access Network folders through Apache Tomcat

I have a .war file published on Apache Tomcat 7.0. 我在Apache Tomcat 7.0上发布了一个.war文件。 The application accesses a folder and displays the filenames of the files inside. 该应用程序访问一个文件夹并显示其中文件的文件名。 This is working perfectly when the folder is on the local machine. 当文件夹位于本地计算机上时,这可以正常工作。 However when the folder in on the Network server (accessed through \\\\192.168.x.xx\\foldername) then the application can't access it and displays "No files found"). 但是,当网络服务器上的文件夹位于(通过\\\\ 192.168.x.xx \\ foldername访问)时,应用程序将无法访问该文件夹,并显示“找不到文件”。

We've tried searching for a possible solution but didn't find anything that seemed related to this specific issue. 我们已尝试寻找可能的解决方案,但未发现与该特定问题相关的任何内容。 We also tried the usual solutions like granting access (sharing), running the application as Administrator, even checking Tomcat users settings but nothing worked. 我们还尝试了常见的解决方案,例如授予访问权限(共享),以管理员身份运行该应用程序,甚至检查Tomcat用户设置,但均无济于事。 So my question is, what do we need to do to allow the application to access that network folder. 所以我的问题是,我们需要做些什么才能允许应用程序访问该网络文件夹。 I also should mention that when the application is running from Eclipse, it can access the folder without any problems. 我还应该提到,当应用程序从Eclipse运行时,它可以毫无问题地访问该文件夹。 Thanks. 谢谢。

This has nothing to do with Tomcat. 这与Tomcat无关。 For one, \\\\host\\share is the Windows-specific way to access a CIFS/SMB share from an Explorer window; 首先, \\\\host\\share是Windows特定的方法,可从资源管理器窗口访问CIFS / SMB共享。 it won't work on *nix where you have to mount the share to a directory. 在必须将共享装载到目录的* nix上它将无法使用。 If you're willing to change the code in the war, take a look at Java open file on shared location or at JCIFS. 如果您愿意在战争中更改代码,请查看共享位置或JCIFS 上的Java打开文件 Or if you map the share to a network drive, you can do z:\\... . 或者,如果将共享映射到网络驱动器,则可以执行z:\\...

You can trick it out by modifying the service properties not to use Local System account and explicitly put the account that already has privilege. 您可以通过修改服务属性以使其使用本地系统帐户来欺骗它,并显式放置已经具有特权的帐户。 (even though you are already logged in using it) (即使您已经使用它登录了)

I hope it helps. 希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM