You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sameer Acharya <ac...@yahoo.com> on 2006/09/01 09:48:20 UTC

Re: Why cannot I put JSVC into a shell script to run

Are you saying that when you run a command from console it works but when you put it into a shell script and try and run the script it doesnt work ?

Are you using the same command from console , did you try and do a ps to see if tomcat has started/not started ?
Putting the entire command on one line shouldnt be an issue .
-Sameer

Patrick Wang <pw...@uclink.berkeley.edu> wrote: Hi,

I can only copy/paste the contents from startTomcat.sh to the console,
everything works fine. But when I run the command from
the console startTomcat.sh, it gave me no error, however the

ming/Q_21972914.html##> tomcat doesnot get started, I make sure the execute
rights is assigned, etc.

One thing is that I make all these strings into one single line in the
startTomcat.sh, will this have any effect?

./bin/jsvc -jvm

ming/Q_21972914.html##> server -Xdebug -Xnoagent
-Xrunjdwp:transport=dt_socket,address=8000,suspend=n,server=y
-Djava.endorsed.dirs=./common/endorsed -cp ./bin/bootstrap.jar -outfile
./logs/catalina.out -errfile ./logs/catalina.err
org.apache.catalina.startup.Bootstrap

 

Do I need to setup the environment variable? However I can run the command from
the console without the environment setup either.

 

Pat



 		
---------------------------------
 All-new Yahoo! Mail - Fire up a more powerful email and get things done faster.

RE: Why cannot I put JSVC into a shell script to run

Posted by Patrick Wang <pw...@uclink.berkeley.edu>.
I got an error code in Catalina.err

java.lang.ClassNotFoundException: org.apache.catalina.startup.Bootstrap
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at
org.apache.commons.daemon.support.DaemonLoader.check(DaemonLoader.java:109)
 daemonec error: An error was detected checking the
org.apache.catalina.startup.Bootstrap
jsvc.exec error: Service exit with a return value of 2



-----Original Message-----
From: Patrick Wang [mailto:pwang@uclink.berkeley.edu] 
Sent: Friday, September 01, 2006 9:45 AM
To: 'Tomcat Users List'
Subject: RE: Why cannot I put JSVC into a shell script to run

Pascal:

Thanks for the detailed explanation,

The procedure I used to launch jsvc

Login in SERVER using root account through SSH.

Go to TOMCAT directory,

Run startTomcat.sh, nothing happened.

Then run command cat startTomcat.sh and copy/paste the command to the console,
hit enter.

Tocmat started after verifying the netstat -nlp | grep jsvc


I setup all the environment variable like inside Catalina.sh
By adding 4 echo in my startTomcat.sh

"
echo "JAVA_HOME: $JAVA_HOME"
echo "CATALINA_HOME: $CATALINA_HOME"
echo "CATALINA_BASE: $CATALINA_BASE"
echo "CATALINA_TMPDIR: $CATALINA_TMPDIR"
./bin/jsvc -jvm server -Xdebug -Xnoagent
-Xrunjdwp:transport=dt_socket,address=8000,suspend=n,server=y
-Djava.endorsed.dirs=./common/endorsed -cp ./bin/bootstrap.jar -outfile
./logs/catalina.out -errfile ./logs/catalina.err
org.apache.catalina.startup.Bootstrap
[root@ea tomcat]# ./bin/jsvc -jvm server -Xdebug -Xnoagent
-Xrunjdwp:transport=dt_socket,address=8000,suspend=n,server=y
-Djava.endorsed.dirs=./common/endorsed -cp ./bin/bootstrap.jar -outfile
./logs/catalina.out -errfile ./logs/catalina.err
org.apache.catalina.startup.Bootstrap
"

What is going on here?

Thanks
Pat


-----Original Message-----
From: Pascal Bleser [mailto:pascal.bleser@atosorigin.com] 
Sent: Friday, September 01, 2006 9:09 AM
To: Tomcat Users List
Subject: Re: Why cannot I put JSVC into a shell script to run

Patrick Wang wrote:
> Thanks for the reply, you are correct. The same command line doesnot work when
I
> put into a shell command. I used the command netstat to see if Tomcat has
> started since it listen to the port.

Rather use lsof -i instead of netstat + having to grep the output:

if lsof -i:8080 &>/dev/null; then
  # something is listening on 8080
else
  # nothing is listening on 8080
fi


Another approach is to use netcat in "zero I/O mode" to make a TCP
connect on the port:

if netcat -n -w 1 -z localhost 8080; then
  # something responds to connect on 8080
else
  # nothing responds to connect on 8080
fi

N.B.:
 -n is to avoid host and protocol name lookups
 -w 1 is to set the timeout for the connect to 1 second
 -z is for "zero I/O mode" -- i.e. just connect() and close

> Command from console works, starting shell script not working without an error
> shown up on the console.

Just a wild guess: what about your JAVA_HOME, JRE_HOME and other
environment variables that affect Tomcat ?

Are you starting that shell script from the same environment as when
you do it with the command, directly ?
Same environment means: same user, also from an interactive shell, etc...

If, for example, that shell script is being started by init as root,
you will end up having a totally different environment as when you log
in into an interactive shell.

> Since I am new to the bash shell script, I am not sure how to debug it.

bash -x ./my_script.sh

> I checked the catalina.err, it seems cannot find a file, classpath was not
> setup? But everything in the console works great. Could the environment on the
> console and shell script different?

See above.

Personally, I always setup the full environment (well, at least the
environment variables that affect Tomcat) in bin/setenv.sh
If that file exists, it will automatically be sourced by catalina.sh

That's where you should do your environment settings, especially
JAVA_HOME and JRE_HOME.
Do not rely on the environment as it is setup by an interactive login
(e.g. ~/.profile or ~/.bashrc)

e.g.
---8<-------------------------------
JAVA_HOME=/usr/java/jdk1.5.0
JRE_HOME=$JAVA_HOME
JAVA_OPTS="-Xms128m -Xmx128m"
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME JRE_HOME
---8<-------------------------------

cheers
-- 
  -o) Pascal Bleser               ATOS Worldline/Aachen(DE)
  /\\   System Architect              WLP Business Platform
 _\_v "Really, I'm not out to destroy Microsoft.  That will
just be a completely unintentional side effect."-L.Torvalds


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Why cannot I put JSVC into a shell script to run

Posted by Patrick Wang <pw...@uclink.berkeley.edu>.
Pascal:

Thanks for the detailed explanation,

The procedure I used to launch jsvc

Login in SERVER using root account through SSH.

Go to TOMCAT directory,

Run startTomcat.sh, nothing happened.

Then run command cat startTomcat.sh and copy/paste the command to the console,
hit enter.

Tocmat started after verifying the netstat -nlp | grep jsvc


I setup all the environment variable like inside Catalina.sh
By adding 4 echo in my startTomcat.sh

"
echo "JAVA_HOME: $JAVA_HOME"
echo "CATALINA_HOME: $CATALINA_HOME"
echo "CATALINA_BASE: $CATALINA_BASE"
echo "CATALINA_TMPDIR: $CATALINA_TMPDIR"
./bin/jsvc -jvm server -Xdebug -Xnoagent
-Xrunjdwp:transport=dt_socket,address=8000,suspend=n,server=y
-Djava.endorsed.dirs=./common/endorsed -cp ./bin/bootstrap.jar -outfile
./logs/catalina.out -errfile ./logs/catalina.err
org.apache.catalina.startup.Bootstrap
[root@ea tomcat]# ./bin/jsvc -jvm server -Xdebug -Xnoagent
-Xrunjdwp:transport=dt_socket,address=8000,suspend=n,server=y
-Djava.endorsed.dirs=./common/endorsed -cp ./bin/bootstrap.jar -outfile
./logs/catalina.out -errfile ./logs/catalina.err
org.apache.catalina.startup.Bootstrap
"

What is going on here?

Thanks
Pat


-----Original Message-----
From: Pascal Bleser [mailto:pascal.bleser@atosorigin.com] 
Sent: Friday, September 01, 2006 9:09 AM
To: Tomcat Users List
Subject: Re: Why cannot I put JSVC into a shell script to run

Patrick Wang wrote:
> Thanks for the reply, you are correct. The same command line doesnot work when
I
> put into a shell command. I used the command netstat to see if Tomcat has
> started since it listen to the port.

Rather use lsof -i instead of netstat + having to grep the output:

if lsof -i:8080 &>/dev/null; then
  # something is listening on 8080
else
  # nothing is listening on 8080
fi


Another approach is to use netcat in "zero I/O mode" to make a TCP
connect on the port:

if netcat -n -w 1 -z localhost 8080; then
  # something responds to connect on 8080
else
  # nothing responds to connect on 8080
fi

N.B.:
 -n is to avoid host and protocol name lookups
 -w 1 is to set the timeout for the connect to 1 second
 -z is for "zero I/O mode" -- i.e. just connect() and close

> Command from console works, starting shell script not working without an error
> shown up on the console.

Just a wild guess: what about your JAVA_HOME, JRE_HOME and other
environment variables that affect Tomcat ?

Are you starting that shell script from the same environment as when
you do it with the command, directly ?
Same environment means: same user, also from an interactive shell, etc...

If, for example, that shell script is being started by init as root,
you will end up having a totally different environment as when you log
in into an interactive shell.

> Since I am new to the bash shell script, I am not sure how to debug it.

bash -x ./my_script.sh

> I checked the catalina.err, it seems cannot find a file, classpath was not
> setup? But everything in the console works great. Could the environment on the
> console and shell script different?

See above.

Personally, I always setup the full environment (well, at least the
environment variables that affect Tomcat) in bin/setenv.sh
If that file exists, it will automatically be sourced by catalina.sh

That's where you should do your environment settings, especially
JAVA_HOME and JRE_HOME.
Do not rely on the environment as it is setup by an interactive login
(e.g. ~/.profile or ~/.bashrc)

e.g.
---8<-------------------------------
JAVA_HOME=/usr/java/jdk1.5.0
JRE_HOME=$JAVA_HOME
JAVA_OPTS="-Xms128m -Xmx128m"
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME JRE_HOME
---8<-------------------------------

cheers
-- 
  -o) Pascal Bleser               ATOS Worldline/Aachen(DE)
  /\\   System Architect              WLP Business Platform
 _\_v "Really, I'm not out to destroy Microsoft.  That will
just be a completely unintentional side effect."-L.Torvalds


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Why cannot I put JSVC into a shell script to run

Posted by Pascal Bleser <pa...@atosorigin.com>.
Patrick Wang wrote:
> Thanks for the reply, you are correct. The same command line doesnot work when I
> put into a shell command. I used the command netstat to see if Tomcat has
> started since it listen to the port.

Rather use lsof -i instead of netstat + having to grep the output:

if lsof -i:8080 &>/dev/null; then
  # something is listening on 8080
else
  # nothing is listening on 8080
fi


Another approach is to use netcat in "zero I/O mode" to make a TCP
connect on the port:

if netcat -n -w 1 -z localhost 8080; then
  # something responds to connect on 8080
else
  # nothing responds to connect on 8080
fi

N.B.:
 -n is to avoid host and protocol name lookups
 -w 1 is to set the timeout for the connect to 1 second
 -z is for "zero I/O mode" -- i.e. just connect() and close

> Command from console works, starting shell script not working without an error
> shown up on the console.

Just a wild guess: what about your JAVA_HOME, JRE_HOME and other
environment variables that affect Tomcat ?

Are you starting that shell script from the same environment as when
you do it with the command, directly ?
Same environment means: same user, also from an interactive shell, etc...

If, for example, that shell script is being started by init as root,
you will end up having a totally different environment as when you log
in into an interactive shell.

> Since I am new to the bash shell script, I am not sure how to debug it.

bash -x ./my_script.sh

> I checked the catalina.err, it seems cannot find a file, classpath was not
> setup? But everything in the console works great. Could the environment on the
> console and shell script different?

See above.

Personally, I always setup the full environment (well, at least the
environment variables that affect Tomcat) in bin/setenv.sh
If that file exists, it will automatically be sourced by catalina.sh

That's where you should do your environment settings, especially
JAVA_HOME and JRE_HOME.
Do not rely on the environment as it is setup by an interactive login
(e.g. ~/.profile or ~/.bashrc)

e.g.
---8<-------------------------------
JAVA_HOME=/usr/java/jdk1.5.0
JRE_HOME=$JAVA_HOME
JAVA_OPTS="-Xms128m -Xmx128m"
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME JRE_HOME
---8<-------------------------------

cheers
-- 
  -o) Pascal Bleser               ATOS Worldline/Aachen(DE)
  /\\   System Architect              WLP Business Platform
 _\_v "Really, I'm not out to destroy Microsoft.  That will
just be a completely unintentional side effect."-L.Torvalds


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Why cannot I put JSVC into a shell script to run

Posted by Patrick Wang <pw...@uclink.berkeley.edu>.
Samuel:

Thanks for the reply, you are correct. The same command line doesnot work when I
put into a shell command. I used the command netstat to see if Tomcat has
started since it listen to the port.

Command from console works, starting shell script not working without an error
shown up on the console.

Since I am new to the bash shell script, I am not sure how to debug it.

I checked the catalina.err, it seems cannot find a file, classpath was not
setup? But everything in the console works great. Could the environment on the
console and shell script different?

THanks

Pat

-----Original Message-----
From: Sameer Acharya [mailto:acharya_sam@yahoo.com] 
Sent: Friday, September 01, 2006 12:48 AM
To: Tomcat Users List
Subject: Re: Why cannot I put JSVC into a shell script to run

Are you saying that when you run a command from console it works but when you
put it into a shell script and try and run the script it doesnt work ?

Are you using the same command from console , did you try and do a ps to see if
tomcat has started/not started ?
Putting the entire command on one line shouldnt be an issue .
-Sameer

Patrick Wang <pw...@uclink.berkeley.edu> wrote: Hi,

I can only copy/paste the contents from startTomcat.sh to the console,
everything works fine. But when I run the command from
the console startTomcat.sh, it gave me no error, however the

ming/Q_21972914.html##> tomcat doesnot get started, I make sure the execute
rights is assigned, etc.

One thing is that I make all these strings into one single line in the
startTomcat.sh, will this have any effect?

./bin/jsvc -jvm

ming/Q_21972914.html##> server -Xdebug -Xnoagent
-Xrunjdwp:transport=dt_socket,address=8000,suspend=n,server=y
-Djava.endorsed.dirs=./common/endorsed -cp ./bin/bootstrap.jar -outfile
./logs/catalina.out -errfile ./logs/catalina.err
org.apache.catalina.startup.Bootstrap

 

Do I need to setup the environment variable? However I can run the command from
the console without the environment setup either.

 

Pat



 		
---------------------------------
 All-new Yahoo! Mail - Fire up a more powerful email and get things done faster.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org