Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 171487 - www-servers/tomcat-5.5 init script uses root's VM
Summary: www-servers/tomcat-5.5 init script uses root's VM
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High trivial (vote)
Assignee: William L. Thomson Jr. (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-19 21:48 UTC by Paul Austin
Modified: 2007-04-19 16:35 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Austin 2007-03-19 21:48:59 UTC
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
Comment 1 Paul Austin 2007-03-19 21:53:12 UTC
using the following in /etc/conf.d/tomcat-55 will do the trick

JAVA_HOME=`su -c "java-config --jre-home" tomcat`
Comment 2 Petteri Räty (RETIRED) gentoo-dev 2007-03-19 22:27:19 UTC
(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?
Comment 3 Josh Nichols (RETIRED) gentoo-dev 2007-03-19 22:31:55 UTC
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'
Comment 4 Petteri Räty (RETIRED) gentoo-dev 2007-03-19 22:42:07 UTC
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.
Comment 5 Paul Austin 2007-03-19 22:48:32 UTC
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
Comment 6 Krzysztof Pawlik (RETIRED) gentoo-dev 2007-03-19 22:55:32 UTC
(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.
Comment 7 Josh Nichols (RETIRED) gentoo-dev 2007-03-20 00:06:45 UTC
(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.
Comment 8 William L. Thomson Jr. (RETIRED) gentoo-dev 2007-04-19 16:35:57 UTC
Fixed in -r3, JAVA_HOME has been moved to init script, and GENTOO_VM can now be set in conf.d file.