Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8561687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:33:26+00:00 2026-06-11T16:33:26+00:00

So I have the following problem: I have a web service running inside a

  • 0

So I have the following problem: I have a web service running inside a Tomcat7 server on Linux. The web service however has to execute some commands (mostly file operations such as copy and mount). Copy I’ve replaced with java.nio, but I don’t think that there is a replacement for mount.

So I’m trying to execute shell commands out of my Tomcat Java process. Unfortunately it doesn’t execute my commands. I’ve implemented the execution of shell commands in Java before. So my code should be correct:

Process pr = Runtime.getRuntime().exec("mount -o loop -t iso9660 <myimage> <mymountpoint>");
pr.waitFor();

<myimage> and <mymountpoint> are absolute paths, so no issues there either.

  • I’ve debugged my commands and they are working when executed on the console.
  • I’ve tried sending other commands. Simple commands such as id and pwd are working!
  • I’ve tried using /bin/bash -c "<command>", which didn’t work.
  • I’ve tried executing a shell script, which executes the command, which didn’t work.
  • I’ve tried escaping the spaces in my command, which didn’t work.

So I’ve digged even deeper and now I’m suspecting some Tomcat security policy (Sandbox?), which prevents me from executing the command. Since security is no issue for me (it’s an internal system, completely isolated from the outside world), I’ve tried a hack, which became quite popular just recently:

System.setSecurityManager(null);

This didn’t work either. I’m using Java7 and Tomcat7 on RHEL6. Tomcat7 is just extracted! I don’t have any files in /etc/.. or any other folder than /opt/tomcat/, where I’ve extracted the zip from the Tomcat home page. I’ve searched the /opt/tomcat/conf folder for security settings, but all I could find was the file catalina.policy, where it didn’t seem like I could set some security level for shell commands.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:33:27+00:00Added an answer on June 11, 2026 at 4:33 pm

    It’s generally a bad idea to use the single-string form of Runtime.exec. A better option is to use ProcessBuilder, and split up the arguments yourself rather than relying on Java to split them for you (which it does very naïvely).

    ProcessBuilder pb = new ProcessBuilder("/bin/mount", "-o", "loop", /*...*/);
    pb.redirectErrorStream(true); // equivalent of 2>&1
    Process p = pb.start();
    

    You say you’re on RHEL so do you have selinux active? Check your logs and see if this is what’s blocking you (I think it’s audit.log you’re looking for, it’s been a few years since I’ve used selinux). If this does turn out to be the problem then you should probably ask on superuser or serverfault rather than SO…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem. A web service is sending a JSON POST request
I have the following problem. I got two forms on my web page. On
My question is motivated by the following problem. I have a set of web
Hi i have following Problem. I write a Mediawiki Extension where i need some
I made the simple hello world NODEJS Server. I have a enyo web service
I have the following code in a java Web Service: public boolean makeFile(String fileName,
I have the following web service: [ScriptService] public class Handler : WebService { [WebMethod]
I have very weird problem with web-services. Setup is following: 6 web-services deployed on
I have a IIS-Hosted WCF service running on one server and a windows service
I have some webservice to test, running on a server, in axis2. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.