简体   繁体   English

Java / Tomcat没有足够的权限来执行'java'

[英]Java/Tomcat has not enough permission to execute 'java'

I have the following code running in one of my Java-Servlets on my Tomcat server on Ubuntu: 我在Ubuntu上的Tomcat服务器上的一个Java-Servlet中运行了以下代码:

ProcessBuilder pb = new ProcessBuilder( "java", "-jar", "test.jar", Integer.toString( jobId ), Integer.toString( software ), Integer.toString( entryPoint ), application );
pb.directory( new File( "/home/user/Folder" ) );
proc = pb.start();

But in line three I get this error: 但是在第三行中我得到了这个错误:

java.io.IOException: Cannot run program "java" (in directory "/home/user/Folder"): error=13, Keine Berechtigung

It is german and means, that it doesn't have enough rights to execute 'java'. 它是德语,意味着它没有足够的权限来执行'java'。

Does anyone know how to fix that? 有谁知道如何解决这个问题?

this means that the user who starts the tomcat server does not have permissions to launch java process inside /home/user/Folder. 这意味着启动tomcat服务器的用户没有权限在/ home / user / Folder中启动java进程。

check who's running tomcat with: 检查谁在运行tomcat:

ps aux | grep tomcat

either change the owner of /home/user/Folder so that it's owned by the user who runs the tomcat or adjust the file permissions accordingly 或者更改/ home / user / Folder的所有者,以便它由运行tomcat的用户拥有或相应地调整文件权限

to change the owner of the directory you execute the following: 要更改执行以下目录的所有者:

chown -R tomcat /home/user/Folder

to add permissions (so that tomcat can access the folder) you execute the following: 要添加权限(以便tomcat可以访问该文件夹),请执行以下命令:

chmod -R o+rwx /home/user/Folder

Note! 注意! you only need to choose one method, not both. 你只需要选择一种方法,而不是两种方法。

Possible cause: AFAIR from your other question, you use a Linux machine, so there can be (besides the standard Unix security) also SELinux in action, which allows to specify further restrictions. 可能的原因:AFAIR来自您的其他问题,您使用的是Linux机器,因此除了标准的Unix安全性之外, SELinux还可以运行,它允许指定进一步的限制。 And it is quite possible, that there is a restriction imposed on tomcat (or even java itself), that prevents it from starting other processes (either all, or from a specified list). 很有可能,对tomcat(甚至是java本身)施加了限制,阻止它启动其他进程(全部或从指定列表)。

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

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