<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>171487</bug_id>
          
          <creation_ts>2007-03-19 21:48 0000</creation_ts>
          <short_desc>www-servers/tomcat-5.5 init script uses root&apos;s VM</short_desc>
          <delta_ts>2007-04-19 16:35:57 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Ebuilds</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>trivial</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>paul@austin.name</reporter>
          <assigned_to>wltjr@gentoo.org</assigned_to>
          <cc>java@gentoo.org</cc>

      

      
          <long_desc isprivate="0">
            <who>paul@austin.name</who>
            <bug_when>2007-03-19 21:48:59 0000</bug_when>
            <thetext>The init script for tomcat-5.5 is run as root, so running java-config will return the root user&apos;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&apos;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</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>paul@austin.name</who>
            <bug_when>2007-03-19 21:53:12 0000</bug_when>
            <thetext>using the following in /etc/conf.d/tomcat-55 will do the trick

JAVA_HOME=`su -c &quot;java-config --jre-home&quot; tomcat`</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>betelgeuse@gentoo.org</who>
            <bug_when>2007-03-19 22:27:19 0000</bug_when>
            <thetext>(In reply to comment #1)
&gt; using the following in /etc/conf.d/tomcat-55 will do the trick
&gt; 
&gt; JAVA_HOME=`su -c &quot;java-config --jre-home&quot; tomcat`
&gt; 

Or just use GENTOO_VM in conf.d. Like export GENTOO_VM=&quot;sun-jdk-1.6&quot;

betelgeuse@pena ~ $ java -version
java version &quot;1.5.0_11&quot;
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=&quot;sun-jdk-1.6&quot; java -version
java version &quot;1.6.0&quot;
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&apos;s quite easy to do.

&gt; 
&gt; The real issue is that root can only have a 1.4.x as it&apos;s java VM and some web
&gt; apps need 1.5.
&gt; 

I haven&apos;t heard of any such restrictions. Care to elaborate?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>nichoj@gentoo.org</who>
            <bug_when>2007-03-19 22:31:55 0000</bug_when>
            <thetext>As for needing 1.4 as the system vm, this hasn&apos;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&apos;s user vm, is that by default, tomcat&apos;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 &apos;Using a Specific VM&apos;</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>betelgeuse@gentoo.org</who>
            <bug_when>2007-03-19 22:42:07 0000</bug_when>
            <thetext>Just came to think that it wouldn&apos;t be a bad idea to support for example:
java-config --jdk-home &lt;vmhandle&gt;
Now this just prints the in use one.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>paul@austin.name</who>
            <bug_when>2007-03-19 22:48:32 0000</bug_when>
            <thetext>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 &apos;root&apos; should always use the System VM
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>nelchael@gentoo.org</who>
            <bug_when>2007-03-19 22:55:32 0000</bug_when>
            <thetext>(In reply to comment #2)
&gt; (In reply to comment #1)
&gt; &gt; using the following in /etc/conf.d/tomcat-55 will do the trick
&gt; &gt; 
&gt; &gt; JAVA_HOME=`su -c &quot;java-config --jre-home&quot; tomcat`
&gt; &gt; 
&gt; 
&gt; Or just use GENTOO_VM in conf.d. Like export GENTOO_VM=&quot;sun-jdk-1.6&quot;

This aproach works, and I&apos;m using it in resin init.d/conf.d scrips.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>nichoj@gentoo.org</who>
            <bug_when>2007-03-20 00:06:45 0000</bug_when>
            <thetext>(In reply to comment #5)
&gt; When you try to set the user VM to anything other than the system VM it gives
&gt; an error and Gentoo recommends to use a 1.4 vm as the system VM.

That is no longer true, and hasn&apos;t, as I mentioned, for several months now.

I think you are thinking about the &apos;generation-1&apos; 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 &apos;generation-2&apos;, that is no longer a limitation, as there is a difference between system vm and the vm used for building.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>wltjr@gentoo.org</who>
            <bug_when>2007-04-19 16:35:57 0000</bug_when>
            <thetext>Fixed in -r3, JAVA_HOME has been moved to init script, and GENTOO_VM can now be set in conf.d file.</thetext>
          </long_desc>
      
    </bug>

</bugzilla>