The init script for tomcat-5.5 is run as root, so running java-config will return the root user's JAVA_HOME variable. When ideally you should be able to get it to use the VM defined for the tomcat user instead. The real issue is that root can only have a 1.4.x as it's java VM and some web apps need 1.5. Manually setting the VM is an option but it defeats the purpose of the java-config approach and will need changing on each VM upgrade. Paul
using the following in /etc/conf.d/tomcat-55 will do the trick JAVA_HOME=`su -c "java-config --jre-home" tomcat`
(In reply to comment #1) > using the following in /etc/conf.d/tomcat-55 will do the trick > > JAVA_HOME=`su -c "java-config --jre-home" tomcat` > Or just use GENTOO_VM in conf.d. Like export GENTOO_VM="sun-jdk-1.6" betelgeuse@pena ~ $ java -version java version "1.5.0_11" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03) Java HotSpot(TM) Server VM (build 1.5.0_11-b03, mixed mode) betelgeuse@pena ~ $ GENTOO_VM="sun-jdk-1.6" java -version java version "1.6.0" Java(TM) SE Runtime Environment (build 1.6.0-b105) Java HotSpot(TM) Server VM (build 1.6.0-b105, mixed mode) I have been saying that we should provide a documented way in the conf.d file to use the vmhandle to specific a VM different from the root vm. Of course we should still keep the option of giving it by path as it's quite easy to do. > > The real issue is that root can only have a 1.4.x as it's java VM and some web > apps need 1.5. > I haven't heard of any such restrictions. Care to elaborate?
As for needing 1.4 as the system vm, this hasn't been true for some time, like 8 months or so. root VM can be whatever you want with the new Java system. One problem with using tomcat's user vm, is that by default, tomcat's home is /dev/null, and the setting for the user vm gets saved in the home directory... The typical way to configure the vm used is documented at http://www.gentoo.org/proj/en/java/tomcat-guide.xml under 'Using a Specific VM'
Just came to think that it wouldn't be a bad idea to support for example: java-config --jdk-home <vmhandle> Now this just prints the in use one.
The GENTOO_VM approach will work, thanks. When you try to set the user VM to anything other than the system VM it gives an error and Gentoo recommends to use a 1.4 vm as the system VM. root# java-config -L The following VMs are available for generation-2: *) Sun JDK 1.4.2.13 [sun-jdk-1.4] 2) Sun JDK 1.5.0.11 [sun-jdk-1.5] 3) Sun JDK 1.6.0 [sun-jdk-1.6] root# java-config -s 2 !!! ERROR: The user 'root' should always use the System VM
(In reply to comment #2) > (In reply to comment #1) > > using the following in /etc/conf.d/tomcat-55 will do the trick > > > > JAVA_HOME=`su -c "java-config --jre-home" tomcat` > > > > Or just use GENTOO_VM in conf.d. Like export GENTOO_VM="sun-jdk-1.6" This aproach works, and I'm using it in resin init.d/conf.d scrips.
(In reply to comment #5) > When you try to set the user VM to anything other than the system VM it gives > an error and Gentoo recommends to use a 1.4 vm as the system VM. That is no longer true, and hasn't, as I mentioned, for several months now. I think you are thinking about the 'generation-1' system vm, which is only allowed to be a 1.4 jdk, because this is used for building old generation-1 packages which expect to be built with 1.4. For 'generation-2', that is no longer a limitation, as there is a difference between system vm and the vm used for building.
Fixed in -r3, JAVA_HOME has been moved to init script, and GENTOO_VM can now be set in conf.d file.