Link to home
Start Free TrialLog in
Avatar of LinuxDuke
LinuxDukeFlag for South Africa

asked on

Executing a shutdown of JBoss as a linux normal user that has sudo access.

Hi Experts,

I have a user student that I have granted sudo access on Linux so that he can execute the following command /jboss-4.0.4.GA/bin/shutdown.sh to shutdown JBoss. I get the following error appearing when i try with the student user:
student@server1 bin]$ sudo ./shutdown.sh
/jboss-4.0.4.GA/bin/shutdown.sh: line 78: exec: java: not found
Seems it cant find the Java VM for that user...
Has anyone ever tried to stop jboss  as a different user.

Regards
The Duke
Avatar of gaston_acevedo
gaston_acevedo

Hi,
that problem indicates no java for your user.
in the linux box type set |grep JAVA_HOME

or

java --version

tell me wath you get
Find your java install folder, then do

export JAVA_HOME=/opt/jdk1.5.0_16 (adjust to your java install path)
export PATH=$PATH:$JAVA_HOME/bin

Note: try to find your java path using ' find / -type f -name java'
Avatar of LinuxDuke

ASKER

Hi Experts,

I logged as the user student and exported JAVA_HOME and PATH and this is the out put I get but this disappears when I log off where should I place this on a file where it will be permanent for this user.
As I still get the same error when I execute the shutdown.sh:

[student@server1~]$ set |grep JAVA_HOME
JAVA_HOME=/opt/jdk1.6.0_02
[student@server1 ~]$

[student@server1 bin]$ sudo ./shutdown.sh -S
/jboss-4.0.4.GA/bin/shutdown.sh: line 78: exec: java: not found
ASKER CERTIFIED SOLUTION
Avatar of segurah
segurah

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You also forgot to amend the path, so the shell cannot find the java executable. Please try all the steps above, and see what happens then.

Easiest might be to put all this in a script and "sudo /path/to/script" from the user, just for ease of use, unless you want the environment change ... If you do set the users environment, remember to preseve that in the sudo call, via the -E flag ... would make the call look like "sudo -E /path/to/script". Might actually be all that is wrong here, that the user didn't try preserve the environment:/

Cheers
-- Glenn
I decided to give the user super user access via sudo to resolve this has he need to execute that shutdown.sh commanda.