我如何允许在 Tomcat 上运行的应用程序访问网络目录? [英] How would I allow an application running on Tomcat access to a network directory?

查看:31
本文介绍了我如何允许在 Tomcat 上运行的应用程序访问网络目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Windows 7 上运行的 Tomcat 服务器上运行 Web 应用程序(用 Java 编写).在应用程序的某个时刻,我尝试通过基本的 java.io.File 类访问远程计算机上的目录.

I'm running a web application (written in Java) on a Tomcat server running on Windows 7. At some point in the application, I try to access a directory on a remote machine through the basic java.io.File class.

如果我通过tomcat6.exe//TS//MyServiceName"从命令行启动Tomcat,我的应用程序可以成功找到网络目录.但是,当我将 Tomcat 作为服务启动时,它认为该目录不存在.

If I start Tomcat from the command line through "tomcat6.exe //TS//MyServiceName", my application can successfully find the network directory. When I start Tomcat as a service, though, it thinks the directory doesn't exist.

根据一些研究,我假设这是一个身份验证问题.我已经将 Windows 服务更新为以我的域用户帐户身份登录",并且我已经更新了 tomcat 服务以使用 'tomcat6.exe//US//MyServiceName --User="bhardage" 添加用户名和密码--Password="xxx"',但即使进行了这两项更改,它仍然找不到网络目录.

Based on some research, I'm assuming it's an authentication issue. I've updated the windows service to "Log on as" my domain user account, and I've updated the tomcat service to add a username and password with 'tomcat6.exe //US//MyServiceName --User="bhardage" --Password="xxx"', but even with both of these changes it still doesn't find the network directory.

我也试过 'tomcat6.exe//US//MyServiceName --User="mydomain\\bhardage" --Password="xxx"' 没有运气.

I've also tried 'tomcat6.exe //US//MyServiceName --User="mydomain\\bhardage" --Password="xxx"' with no luck.

谁能告诉我让我的 Web 应用程序在不同用户下运行的正确方法?

Would anyone be able to tell me the proper way to get my web application running under a different user?

非常感谢任何帮助/建议.

Any help/suggestions are much appreciated.

谢谢,

B.J.

推荐答案

登录身份"功能似乎存在一些问题.也许这些问题仍然存在.

There seemed to be some problems with the "Log on as" feature. Maybe these problems still exist.

您可以尝试通过windows服务管理器中tomcat服务的属性设置用户账号.

You can try to set the user account via the properties of the tomcat service in the windows service manager.

这是说明怎么做.看看第 3 次尝试.它基于旧版本的 tomcat (5.5),但它应该以相同的方式工作.

Here is a description how to do that. Look at attempt number 3. It is based on an old version of tomcat (5.5) but it should work the same way.

可能是服务启动tomcat的时候你的网络目录没有映射.这可能是因为用户在单独的登录行为中登录.

Maybe your network directory is not mapped when the service starts tomcat. This may be because the user logs on in a separate logon act.

在访问网络目录之前尝试执行net use"命令.这可以通过以下方式完成:

Try to execute a "net use" command before accessing the network directory. This can be done with:

Runtime.exec("net use Z: \\\\My\\Share")

这篇关于我如何允许在 Tomcat 上运行的应用程序访问网络目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆