Permission denied while running native commands in Tomcat - java

I'm trying to build an webapp as wrapper for youtube-dl. I'm calling the youtube-dl command using Runtime.getRuntime().exec() but all I'm getting is permission denied saying File system is read-only
And I'm passing the working directory while executing command like Runtime.getRuntime().exec("youtube-dl ...",null,workingDirectory)
Permission for the workingDirectory is changed like below
drwxr-xr-x 1 tomcat tomcat 0 May 13 08:21 Folder
Even tried ProcessBuilder instead of RunTime results same issue and tried other commands such as touch to create file, but the result is same. got touch: cannot touch 'a.txt': Read-only file system error
I'm using tomcat9 - 9.0.16-3ubuntu0.18.04.1, Java8 - 1.8.0_242, Ubuntu - 18.04.1 and tomcat is installed via apt-get
Could anyone tell me what I'm doing wrong?

Seems like your file system went to read only mode.. Please get that server reboot..

Related

Executing jstack getting access denied

My application is running as a windows service.
When I try to take thread dump using below command from Cmd running as Administrator, I am getting access denied on a machine running on Windows 2016 server
"D:\myapp\jre\bin\java.exe" -classpath tools.jar sun.tools.jstack.JStack 2544 >log1.txt
Getting
2544: Access is denied
Similar command when I run on another machine running in Windows server 2012,it successfully captures thread dump.
And both of these services are running with Local system.
As I googled and found this issue could be due to the service running under Localsystem and the command prompt(which I am using to execute jstack) running under different process, I modified the service to log on as my user account and restarted the service, still getting access denied.
Also tried using PsExec using below command:
psexec -s "D:\myapp\jre\bin\java.exe" -classpath tools.jar sun.tools.jstack.JStack 2544 >log1.txt.
I dont know why but I am getting
Error: Could not find or load main class sun.tools.jstack.JStack.
(Just to add I am running this command from the same folder where tools.jar is residing.)
I seem to have been stuck at all places..Any help will me much appreciated

Sudo java -jar vs java -jar

I have a server running on Java using the library Pi4j to control the RaspberryPi's GPIOs and a file on which I write the current GPIOs' statuses. When I run the code from IntelliJ IDE everything works just fine.
But when I create the .jar file and run it like
sudo java -jar server.jar
It works fine updating the file, but the GPIOs do not change their status.
When I do
java -jar server.jar
The GPIOs correctly change their status but I get the error java.io.FileNotFoundException: relStat.txt (Permission denied)
My file permission are all set to anyone, so anyone should be able to read, modify and run it.
Why does this happen?
This is a permission issue,
The file owner is the "pi" user.
Which user you are running under?

Eclipse RSE Error: Operation failed. File system input or output error

I am trying to connect Eclipse to a Virtualbox instance running Ubuntu on Windows 10, using the Remote Systems Explorer. I am able to establish an SSH-only connection by inputting my username and password, and I can access the file system. However, when I try to actually open a file, I get an RSEF1002 error:
Operation failed. File system input or output error
I have set chmod 777 on the directory which I would like to work from. I also tried disconnecting and reconnecting my Eclipse connection, and restarting Eclipse. Nothing has worked so far. Has anyone experienced a similar problem?
Let me know if there are more details I can provide that might help debug the problem.
I had the exact same problem. I went and did
ls -la
in my workspace "/home/myuser/workspace-cdt" and and then went into a directory called RemoteSystemsTempFiles
the i saw a directory "10.160.16.3" corresponding to the IP of the machine i was working on, but what was important there the owner was root
drwxr-xr-x 3 root root 4096 Mai 16 23:06 10.160.16.3
then did
chown -R myuser:myuser 10.160.16.3
and that's how i sloved my problem. I think that happened because i did and upgrade of eclipse cdt from root and that messed up the directory permission in my workspace.

How to run "hello world" JSP page with Tomcat8 in Intellij IDEA 15?

I created webproject template in Intellij IDEA 15 (EE) and tried to run "hello world" application with simple JSP page on installed Tomcat server. But I've got this kind of error:
Error running Tomcat 8.0.33: Error copying configuration files from /opt/tomcat/conf to /home/praytic/.IntelliJIdea15/system/tomcat/Tomcat_8_0_33_webproject/conf: /opt/tomcat/conf/catalina.properties (Permission denied)
I tried this answer, but it didn't make a thing. I don't know, maybe the reason is that I use wrong installation guide. However it works fine from the terminal. How To Install Apache Tomcat 8 on Ubuntu 14.04
I've checked the /opt/tomcat/conf permissions and it says that only root has access to list, create/delete the folder and tomcat and me can only list files. However I added myself as a tomcat-user in tomcat-users.xml. Doesn't it matter?
The error means that intelliJ needs write access to the conf file. So the other answer was correct. You have to set the write flag with +w or like this:
chmod -R 644 /opt/tomcat/conf/ as root or with sudo.
It has nothing to do with tomcat users, only with OS users. It is unfortunately not enough, that only root has the write permissions, except that IntelliJ would be also started with root permission, but that is also not a good idea.

Executing java via exec or shell_exec gives error

I have jdk1.7.0_07 installed on server(linux). The file permission to ~/bin files are executable(755). However when I tried to execute,
$output = exec("/usr/java/jdk1.7.0_07/bin/java -version 2>&1");
echo $output;
It gives permission denied error, I have tried this,
$output = exec("java -version 2>&1");
echo $output;
Which gives command not found error. While checking my environment variables. I have succesfully added JAVA_HOME = /usr/java/jdk1.7.0_07 and for PATH = /usr/java/jdk1.7.0_07/bin
But,
When I run above mentioned PHP script it keeps giving me those permission denied or command not found error. Any personal experience or clue?
If you are running these commands from the command-line, you probably execute them with your own user permissions. However, when you execute these same commands via a PHP script in a web app, they will be executed with the Apach user (typically www-data) permissions. These means that you cannot rely on the command-line output to debug permission errors unless you can log in as the exact same user that runs your PHP script.
If your OS is CentOS it could come from SELinux.
root#ls:~# /usr/sbin/getenforce
Enforcing
root#ls:~# /usr/sbin/setenforce Permissive
root#ls:~# /usr/sbin/getenforce
Permissive
More detail in https://superuser.com/questions/455935/php-script-cant-run-bash-script-sh-permission-denied
It fixed the problem for me.
It seems you have 2 distinct problems:
If it gives you permission denied error when you give the full path to Java executable, then your permissions are probably incorrect. The most common cause is, somewhere along the path, Apache User (usually www-data) does not have read access. For instance, if www-data does not have read permission for jdk1.7.0_07 directory it can't see (or open) it's child directory called bin.
Regarding the path, it will not work unless permissions are correctly set. However, where did you set your environment PATH? Was it in the user profile?

Categories

Resources