LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Installing TOMCAT6.0.14 - JAVA_HOME problem (http://www.linuxquestions.org/questions/linux-newbie-8/installing-tomcat6-0-14-java_home-problem-673806/)

snowball2 10-02-2008 03:03 PM

Installing TOMCAT6.0.14 - JAVA_HOME problem
 
Hello,

I am totally new to Linux (using Ubuntu) and have been struggling to install Tomcat 6.0.14 on Ubuntu.

The problem I am having is that everytime I try to start the server I get the following error :
Code:

sudo sh /usr/local/tomcat/bin/startup.sh
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

Yet...
Code:

echo $JAVA_HOME
/usr/lib/jvm/java-6-sun

And java-6-sun is a link to the following directory
Code:

java-6-sun$ ls
bin        ext      jre  LICENSE  README.html
COPYRIGHT  include  lib  man      THIRDPARTYLICENSEREADME.txt

I'm tearing my hair out now as I can't find anything wrong anywhere - the links all seem fine yet the server just wont run.. Can anyone suggest anything I could try or somewhere I could look please?

Cheers,
Gordon

SkyEye 10-02-2008 04:32 PM

First, welcome to LQ!

How are you actually setting the variable? If you are doing it by defining in a config file (Eg: /etc/profile) make sure to "export" the variable
Code:

Eg: (At the end of /etc/profile)

CATALINA_HOME=/usr/local/tomcat
JAVA_HOME=/usr/lib/jvm/java-6-sun
JRE_HOME=/usr/lib/jvm/java-6-sun
export CATALINA_HOME JAVA_HOME JRE_HOME

What I suspect as happening is, that you might be setting the variable only for a user (Eg: for snawball2 only). If this is the case, make sure your variable value is set in the appropriate user environment your Tomcat server is running as.

Generally
, it's ok to set the variable globally as in the above example (i.e. in /etc/profile).

snowball2 10-03-2008 12:41 AM

Hi,

I'm setting the variable in ~/.bashrc using the line :

export JAVA_HOME=/usr/lib/jvm/java-6-sun

I tried changing that to what you suggested:

JAVA_HOME=/usr/lib/jvm/java-6-sun
export JAVA_HOME


but to no avail :(

Gordon.

SkyEye 10-03-2008 05:26 AM

That's what I said,... :) If you look at my post, I said:
Quote:

Originally Posted by SkyEye
What I suspect as happening is, that you might be setting the variable only for a user (Eg: for snawball2 only). If this is the case, make sure your variable value is set in the appropriate user environment your Tomcat server is running as.

Generally, it's ok to set the variable globally as in the above example (i.e. in /etc/profile).

So obviously you are setting the variable in your .bashrc.

.bashrc is not a good place to set a variable like this. (what it does is set the variable when ever a bash session is started by you.) You need to put this in a place where the variable would be set globally.

Try putting it in /etc/profile (and you can remove JAVA_HOME from .bashrc). Better to reboot your computer after setting this.

snowball2 10-03-2008 07:55 AM

Quote:

Originally Posted by SkyEye (Post 3298868)
Try putting it in /etc/profile (and you can remove JAVA_HOME from .bashrc). Better to reboot your computer after setting this.

Hi, I've removed the JAVA_HOME variable from .bashrc and tried it in /etc/profile but still exactly the same problem - I've checked java is installed correctly, i'm able to compile and run from my home dir and I've re-downloaded tomcat but still no joy. :`(

SkyEye 10-03-2008 08:27 AM

Are you using a Tomcat binary distribution or a source distribution? Try with a binary distribution.

I just downloaded apache-tomcat-6.0.18 and was unable to reproduce your error. Lets try this:
  1. Download a Tomcat binary distribution. Eg: apache-tomcat-6.0.18.tar.gz
  2. Open a terminal and change to your download directory (Eg: $ cd ~/Downloads)
  3. Extract the Tomcat archive (Eg: $ tar xzvf apache-tomcat-6.0.18.tar.gz)
  4. Set the variable JAVA_HOME (or, see Note below) in the same terminal (Eg: $ export JAVA_HOME=/usr/lib/jvm/java-6-sun)
  5. Start the Tomcat server (Eg: $ ./apache-tomcat-6.0.18/bin/startup.sh - please note the "." before the slash)

Note:
  • If you have just the JRE (not the JDK), then set JRE_HOME instead if JAVA_HOME variable.
  • And please remove any tailing slashes (Eg: "~/tomcat" instead of "~/tomcat/") in paths.

This should give an output like this, if it was successful:
Using CATALINA_BASE: /home/snowball2/Downloads/apache-tomcat-6.0.18
Using CATALINA_HOME: /home/snowball2/Downloads/apache-tomcat-6.0.18
Using CATALINA_TMPDIR: /home/snowball2/Downloads/apache-tomcat-6.0.18/temp
Using JRE_HOME: /usr/lib/jvm/java-6-sun

This worked for me. I just tested it. Give it a try, if it still persists please try to extract more info about the system/setup.

snowball2 10-03-2008 02:52 PM

Hi,

SkyEye, thanks a lot for all of the assistance! I really appreciate it..:) I'll give you the story so far - things have improved but the tomcat server isn't quite running yet (at least I can't access it over network yet).

I followed your instructions to the letter but get the following output :

Code:

snowball2@ubuntu:/$ sudo /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE:  /usr/local/tomcat
Using CATALINA_HOME:  /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:      /usr

JRE_HOME is the only thing which is different and I'm still struggling with.. I've defined JAVA_HOME and JRE_HOME in /etc/profile and if I echo $JRE_HOME in shell I get :
Code:

snowball2@ubuntu:/$ echo $JRE_HOME
/usr/lib/jvm/java-6-sun

Even if I export immediately before running startup.sh I still get :
Code:

snowball2@ubuntu:/$ export JRE_HOME=/usr/lib/jvm/java-6-sun
snowball2@ubuntu:/$ export JAVA_HOME=/usr/lib/jvm/java-6-sun
snowball2@ubuntu:/$ sudo /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE:  /usr/local/tomcat
Using CATALINA_HOME:  /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:      /usr

It's weird.. :scratch:

Gordon

SkyEye 10-03-2008 11:55 PM

Quote:

Originally Posted by snowball2 (Post 3299329)
Hi,

I followed your instructions to the letter but get the following output :

Code:

snowball2@ubuntu:/$ sudo /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE:  /usr/local/tomcat
Using CATALINA_HOME:  /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:      /usr

JRE_HOME is the only thing which is different and I'm still struggling with..

It doesn't matter if your server starts. :)

After running the startup script, try
$ sudo ps aux | grep java

If it's running you'll get a java process with lot of parameters in the output.

snowball2 10-04-2008 03:39 PM

Quote:

Originally Posted by SkyEye (Post 3299734)
It doesn't matter if your server starts. :)

SkyEye, thanks very much for all your help - got it up and running ! IOU 1 beer! :D

SkyEye 10-07-2008 10:35 AM

Really glad to know you got it working! :)

Hope to see you around LQ.

gogoabc 11-10-2008 03:44 PM

Quote:

Originally Posted by snowball2 (Post 3300334)
SkyEye, thanks very much for all your help - got it up and running ! IOU 1 beer! :D

Dear snowball2,

I have exact the same problem with you.

after I follow the following steps:
1. Download a Tomcat binary distribution. Eg: apache-tomcat-6.0.18.tar.gz
2. Open a terminal and change to your download directory (Eg: $ cd ~/Downloads)
3. Extract the Tomcat archive (Eg: $ tar xzvf apache-tomcat-6.0.18.tar.gz)
4. Set the variable JAVA_HOME (or, see Note below) in the same terminal (Eg: $ export JAVA_HOME=/usr/lib/jvm/java-6-sun)
5. Start the Tomcat server (Eg: $ ./apache-tomcat-6.0.18/bin/startup.sh - please note the "." before the slash)


I got the result:
tai@ubuntu:/$ sudo /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr

After I run: $ sudo ps aux | grep java
I got:
root 9196 0.3 1.2 1069760 45012 pts/0 Sl 16:18 0:02 /usr/bin/java -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/usr/local/tomcat6.0/conf/logging.properties -Djava.endorsed.dirs=/usr/local/tomcat6.0/endorsed -classpath :/usr/local/tomcat6.0/bin/bootstrap.jar -Dcatalina.base=/usr/local/tomcat6.0 -Dcatalina.home=/usr/local/tomcat6.0 -Djava.io.tmpdir=/usr/local/tomcat6.0/temp org.apache.catalina.startup.Bootstrap start
dror 9325 0.0 0.0 3008 772 pts/0 S+ 16:29 0:00 grep java

Can anyone give me hint? Thank you!

SkyEye 11-11-2008 02:37 AM

Quote:

Originally Posted by gogoabc (Post 3337557)
After I run: $ sudo ps aux | grep java
I got:
root 9196 0.3 1.2 1069760 45012 pts/0 Sl 16:18 0:02 /usr/bin/java -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/usr/local/tomcat6.0/conf/logging.properties -Djava.endorsed.dirs=/usr/local/tomcat6.0/endorsed -classpath :/usr/local/tomcat6.0/bin/bootstrap.jar -Dcatalina.base=/usr/local/tomcat6.0 -Dcatalina.home=/usr/local/tomcat6.0 -Djava.io.tmpdir=/usr/local/tomcat6.0/temp org.apache.catalina.startup.Bootstrap start
dror 9325 0.0 0.0 3008 772 pts/0 S+ 16:29 0:00 grep java

Can anyone give me hint? Thank you!

This means your Tomcat server is running. It's not an error message. So try loading the tomcat test page in your browser.

The steps you followed were steps used temporarily to make sure that there is nothing wrong. Those steps did not set the necessary variables permanently. You can do the final setup by following the steps in, post 6 of this thread.

Good luck.


All times are GMT -5. The time now is 08:55 PM.