• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

How to Modify Tomcat5 to point to new Java installation

S

Superman859

Guest
I am trying to run some Java code with Tomcat but just found out Plesk is still using Java 1.4.2 (ancient). I'm pretty new to using Java on a server and to using Tomcat, so I'm not quite sure how to fix this issue. My code requires Java 1.5 or higher.

I found that the java installation was in /usr/lib/jvm/java (I believe this is where it was linked to), and I downloaded Java 1.5 and now have the folder /usr/lib/jvm/jdk1.5.0_17.

So, I should have the needed files, but now I need the server to recognize them. After some searching, I thought I could change JAVA_HOME in /etc/tomcat5/tomcat5.conf and simply point it to the new directory. I did this, restarted Tomcat, and I haven't noticed any change. The program still runs as before and throws an exception when it requires features of Java 1.5.

Does anyone know what I need to do to get Tomcat pointing to the new Java files so I can use Java 1.5 code? Do I simply need it to reload tomcat5.conf somehow? Or, is changing JAVA_HOME in that file not going to make a difference?

From what I understand, upgrading Tomcat is a pain with Plesk, but upgrading Java shouldn't cause any issues provided the current version of Tomcat can handle it (and Tomcat5 shouldn't have trouble with Java5).

EDIT:
More specifically, running System.getProperty() in Tomcat provides this info:
Version: 1.4.2 Home: /usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre

So the home directory is /usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre based on what Tomat is seeing. However, tomcat5.conf initially had JAVA_HOME="/usr/lib/jvm/java" which points to /etc/alternatives/java_sdk, which points to /usr/lib/jvm/java-1.4.2-gcj, which finally points to /usr/lib/jvm/java-1.4.2-gcj-1.4.2.0, which is an actual folder and seems to match what Tomcat System.getProperty() is getting at.

It's a little confusing, because there are a bunch of links involved all jumping back and forth between a few locations just to finally arrive at that one folder. However, it makes me think that indeed the JAVA_HOME setting for tomcat5.conf might be something to look at, because it ultimately does seem to point to what System.getProperty() points out (without the jre folder specifically, anyways). But I tried replacing JAVA_HOME and restarting Tomcat but nothing changed...
 
Last edited by a moderator:
Just an update. It seems that updating tomcat5.conf is the solution, but Tomcat was not stopping / starting correctly so that file was never reloaded properly (CentOS5). When restarting through Plesk, you do not see this, but if you restart using /etc/init.d/tomcat5 stop and /etc/init.d/tomcat5 start then errrors will appear. It seems there may be some errors in that init script for Tomcat.

Also be sure to check /var/logs/tomcat5/catalina.out for any errors after trying to stop and start Tomcat - that is where I noticed errors related to memory allocation error which was the final issue with why it wouldn't start back up
 
Back
Top