• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to update Tomcat's JVM in Linux?  RSS feed

 
Mike London
Ranch Hand
Posts: 1505
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I finally found out where to update the new JDK I installed into linux (/etc/bashrc). Thanks to all for all the suggestions.

I now get 1.5.0_08 with a java -version at the linux prompt.

The huge problem remains, however, that if I start the browser with a out.println("Version = " + System.getProperty('java.version') command, I still get 1.4.2.

All the environment variables seem to be correct. I've also restarted both apache and tomcat.

Here are the environment variables:

JAVA_HOME = /usr/java/1.5.0_08
CLASSPATH => points to Java 5, not 1.4.2
CATALINA_HOME -> points to Tomcat 5.0.3x

Clearly, I'm still missing something simple (hopefully), right?

What do I need to do to finally tell Tomcat under Linux to use the new JDK?

Thanks again in advance.

-- Mike

[ EJFH: Removed inadvertent "strikethrough" that may have been intended as an emoticon. ]
[ September 14, 2006: Message edited by: Ernest Friedman-Hill ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Restarted it how -- how is it running? Via an /etc/init.d script, or just launched by hand? If it's via an init script, you should go look at that file and make sure it's not setting JAVA_HOME for you.

I have to admit that precisely which files bash reads when it starts up, and in what order, is something of a mystery to me, mainly because the answer is totally different depending on whether bash is started as a login shell, an interactive non-login shell, a non-interactive shell, and whether the UID and EUID are equal or unequal! As a result, this is only a gut feeling rather than an absolute fact, but my guess is that /etc/bashrc won't be read by an init script, and adding the appropriate JAVA_HOME definition to /etc/profile will fix this problem.
 
Mike London
Ranch Hand
Posts: 1505
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat is running automatically. I've restarted it several times using a tool called "Web Host Manager", but that has no effect on the version displayed (1.4.2).

Based on your suggestion, I tried to add the line in /etc/profile like this:

JAVA_HOME = /usr/java/jdk1.5.0_08

but that had no effect.

Hmmmmm

-- M
 
Jason Liao
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

JAVA_HOME = /usr/java/1.5.0_08
CLASSPATH => points to Java 5, not 1.4.2
CATALINA_HOME -> points to Tomcat 5.0.3x
[/QB]


Set JRE_HOME=/usr/java/1.5.0_08
 
Mike London
Ranch Hand
Posts: 1505
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason,

JRE_HOME doesn not exist as an environment variable on this server.

How do I print out all the environment variables (on the screen) so I can hopefully spot the one that is still pointing to the 1.4.2 JVM?

Thanks.

-- M
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat uses JRE_HOME only if it exists and is different from JAVA_HOME; it's not often used.

Go see if there's a file names /etc/init.d/tomcat, and if it does, see if it sets JAVA_HOME or directly includes some file that does.
 
Mike London
Ranch Hand
Posts: 1505
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no /etc/init.d folder on the server. There is an init.d file, but it's empty.

I used the "printenv" command to look at all the environment variables. They all point to the JDK1.5.0_08 folder.

Do I maybe need to just reboot this server?

Thanks for replies!!!

-- M
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try adding your environment variables directly to the catalina.sh script.




Then restart tomcat.
 
Mike London
Ranch Hand
Posts: 1505
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem was that the startomcat file in /usr/sbin was setting the path to the old one. I finally found this file!

Thanks for all your help!!!

-- M
 
George Stoianov
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am curious what distribution are you using??

I wanted to point a few things 1) If you are updating your JVM you should update it for all apps (read for the whole system) provided you won't break something you need like browser plug ins. The reason for that is that you wish to keep current with security patches distributed by your distro of choice when they become available and save yourself the time of reinstalling and reconfiguring again and again after each patch. 2) Tomcat if setup "properly" runs under a separate user in most cases named tomcat too, that is where the environment vars should be changed. Most distributions will use start up scripts to set up the environment for all users before the machine reaches the final runlevel 5 for the X server GUI logins. Also your java version would be linked to something like /usr/bin/java which would point to the currently installed version /usr/local/share/java-XXXX making a change like the one you just did will possibly break that which means that unless you specify the correct path you will be running the wrong JVM version.

Yes I agree linux can seem like a mess but nonetheless pretty much everything is in text files, you can use a find, and follows some pretty good logic for those in the know (which is also ever changing ).

I have been running Tomcat for a while and some operations are a pain so I hope this helps a little bit for future endeavors.
George
 
Mike London
Ranch Hand
Posts: 1505
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks George.

The distro is RedHat 9.

The problem getting the browser part of the server updated was that the JAVA_HOME was being set both in the /etc/bashrc and also in the starttomcat shell sript (oops!). Thus, when tomcat loaded it referred to the old JVM. Changing this variable to /usr/java1.5.0_08 fixed the problem.

Thanks again for your reply.

-- Mike
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!