这个问题我有一段时间了,
我有一个网络,可以从许多服务器读取文件。
当它从 eclipse 运行时......一切都很好。
问题是当我在 apache tomcat
上发布网页时..我无法读取服务器上的文件(权限问题
)
我更改了 apache 的用户名和密码以授予它所有权限。
我注意到我唯一一次无法读取文件,是在服务器计算机具有密码保护共享时。
我无法关闭此密码,如何解决它抛出代码。
最佳答案
“我更改 apache 的用户名和密码以授予它所有权限”是什么意思?
如果它在 eclipse 中有效而在 tomcat 中无效,那么它一定是 tomcat 用户对您尝试访问的文件没有读/写权限。
默认情况下,tomcat 用户是“tomcat7”,所以您有这些选项:
1) 更改文件位置权限(不推荐):
chmod 666 "myFile"
或:
chown tomcat7:tomcat7 "myfile"
2) (最佳选择!)更改 tomcat 用户和组,并以您的 os 用户或任何其他具有权限的用户身份运行 tomcat。如果您使用的是 tomcat 7,那么配置文件必须在 /etc/default/tomcat7
中:
# Run Tomcat as this user ID. Not setting this or leaving it blank will use the
# default of tomcat7.
TOMCAT7_USER=tomcat7
# Run Tomcat as this group ID. Not setting this or leaving it blank will use
# the default of tomcat7.
TOMCAT7_GROUP=tomcat7
希望对您有所帮助!
关于java - 在 apache tomcat 问题 : no permission for reading/writing a file 上部署一个 war 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26018963/