Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Dec 2002 19:24:47 -0800
From:      "Robert L Sowders" <rsowders@usgs.gov>
To:        Eriq Lamar <eqe@cox.net>
Cc:        owner-freebsd-stable@FreeBSD.ORG, stable@FreeBSD.org
Subject:   Re: newbie trying to get java working on 4.7
Message-ID:  <OFA943A331.46900999-ON88256C84.0012A822@wr.usgs.gov>

next in thread | raw e-mail | index | archive | help
http://www.geovelocity.com/index_apache-tomcat-arcims.html   Hello, here 
is a preliminary Tomcat on FreeBSD recipe. I hope some 
of this helps. We've found FreeBSD to be very stable and have had much 
fewer problems, crashes, or weirdness than we used to with Tomcat on 
Windows 2000.

   The most hairy part that I had to deal with when first installing 
Tomcat on FreeBSD was installing the JDK. I don't know how familiar 
you are with Java support in FreeBSD but, due to some licensing issues 
of some sort, there is not a Sun supported FreeBSD JDK past version 1.8.

   So, in order to install a newer native JDK (like 1.3) you have to 
build it from the source code that you manually download from Sun's 
Java site. The catch, is that in order to build the JDK, you need an 
existing one to already be installed. This is where FreeBSD's stellar 
linux emulation environment comes in handy. You can install a Sun 
supported Linux JDK that runs under emulation. Fortunately, all of 
this work can be done via the ports collection.

So, the order of operations I followed was thus:
----------------------------------------
1.  The usual update of the ports collection (cvsup) so as to install 
the latest code.
     cvsup /etc/cvsupfile_ports

2.  Since I use portupgrade, the ports and packages management wrapper 
utilities, I then run:
     portsdb -uU
     (* see notes below)

3.  If I don't already have X installed, I do so here. I don't ever 
actually run X11 on the server, but building the native JDK will 
install X anyway as the swing classes require open-motif which 
requires X. I like to manually build X or else version 3 will be built 
for me automatically instead of version 4.
     portinstall x11/XFree86-4
     portinstall x11-toolkits/open-motif

4.  If I don't already have the linux emulation environment of my 
choice installed, I do so here:
     portinstall emulators/linux_base

5.  Now it is time to manually download the linux JDK file from Sun's 
site. I, as a paranoid person, always like to first check the Makefile 
for the port and see which jdk revision number it expects, as this 
determines which JDK file to download. Also, the Makefile usually 
contains an exact URL to the correct JDK file.
     grep "\(JDK_REVISION\)\|\(DOWNLOAD_URL\)" \
     /usr/ports/java/linux-sun-jdk13/Makefile

6.  After you download the JDK file (something like 
j2sdk-1_3_1_05-linux-i586.bin), put it in /usr/ports/distfiles. Then 
building the linux JDK is straight forward:
     portinstall java/linux-sun-jdk13

7.  You could just use the linux JDK for all of your Java and Tomcat 
needs, but I (and quite a few others) find the patched, native JDK 
stable enough to use and some say it will perform better. So, to 
install it, you need to grab the JDK1.3 source package from Sun's 
site. Again, I check the ports Makefile for the download URL and name 
of the file to look for:
     grep --context=1 MASTER_SITES /usr/ports/java/jdk13/Makefile

   Just a heads up, you'll need to have a (free) user account in order 
to download the source code from Sun's site. The file you'll download 
is something like j2sdk-1_3_1-src.tar.gz and goes in 
/usr/ports/distfiles as well.

8.  Now you have to get the FreeBSD JDK source patches. Make sure you 
get the patch set that matches the one specified in the Makefile (if 
you cvsup'ed, this'll be the latest patch set).
     grep JDK_PATCHSET_VERSION /usr/ports/java/jdk13/Makefile

   You download this file from:
http://www.eyesbeyond.com/freebsddom/java/jdk13.html

9.  Once you put the patch set file (bsd-jdk131-patches-7.tar.gz) in 
/usr/ports/distfiles, you can finally build the native JDK.
     portinstall java/jdk13

10. Once you have Java installed and working, installing Tomcat is 
fairly simple using portupgrade on the ports collection:
     portinstall www/jakarta-tomcat41

11. Some other commonly used software and utilities I install for 
JSP/Servlet development:
     portinstall devel/jakarta-ant
     portinstall databases/mysql-jdbc-mm (**See note below)

12. If you are running Tomcat through Apache, you'll need to install 
and/or configure Apache (and a connector module - mod-jk?). For our 
web application, we have no static content and aren't doing any load 
balancing yet, so there is no reason for us to use Apache. We use 
Tomcat in a standalone configuration.

13. Now there is the obvious application and environment 
configuration. For our developer's convenience, who all use bash, I 
set some global environment variables in /etc/profile:
     JAVA_HOME=/usr/local/jdk; export JAVA_HOME
     TOMCAT_HOME=/usr/local/tomcat; export TOMCAT_HOME
     CATALINA_HOME=/usr/local/tomcat; export CATALINA_HOME
     CLASSPATH=...

   I also like to create convenient symlinks for Java and Tomcat. I 
symlink the installed, production jdk and tomcat directory thus:
     ln -s /usr/local/jdk1.3.1 /usr/local/jdk
     ln -s /usr/local/jakarta-tomcat4.1 /usr/local/tomcat
     ln -s /usr/local/jakarta-ant-1.5.1 /usr/local/ant
     etc.

14. Notes: Possible Gotchas, Misc. Ramblings (Wisdom?)

   When the Tomcat 4.x port installs, it puts a typical Tomcat 
directory hierarchy under /usr/local/jakarta-tomcat4.x. To start and 
stop Tomcat, it also installs a C program (based on daemonctl.c) 
called tomcat4ctl or tomcat41ctl under /usr/local/bin. It works much 
like apachectl does for apache. To actually start Tomcat (at bootup 
for instance), the script 020.jakarta-tomcat4.sh (or 
020.jakarta-tomcat41.sh) is installed into /usr/local/etc/rc.d. It 
just manages a PID file, and executes tomcat4ctl as user:group www:www.
   The daemonctl.c program executes the $TOMCAT_HOME/bin/bootstrap.jar 
file and writes a PID file. This information has been important to me, 
trying to run Tomcat as a standalone web server, for multiple reasons. 
First of all, since bootstrap.jar is executed as user www, Tomcat 
can't have any connectors using any privileged port (<1024). Since I'm 
doing Tomcat as a standalone server, this is inconvenient since I want 
to use ports 80 and 443. Unfortunately, I don't think bootstrap.jar, 
with its cross platform-ed-ness and single-process-ed-ness, will ever 
give the ability to have a parent process running as root that spawns 
a child for actually handling requests, which binds to port 80, then 
setuid()'s to user www, thus allowing the request handling Tomcat 
process to have privileged ports and limited system access. This is 
the downside of not using Apache in conjunction with Tomcat.
   Also of note to some is the use and presence of the CLASSPATH 
system variable. Our developers used to use the classpath in some 
classes to access some properties files. It worked fine on Tomcat 3.x 
and works fine on Windows 2000 running Tomcat 4.x standalone. On our 
current FreeBSD system w/Tomcat 4.x, it doesn't. None of the scripts 
in Tomcat's bin directory are ever used by FreeBSD by default. On 
Windows, the developers modified setclasspath.sh/setenv.sh (er, .bat?) 
and started Tomcat with startup.bat. On FreeBSD, none of those scripts 
are ever used and are meaningless. It seems I tried to manually use 
one of those scripts to start/stop Tomcat once and it either didn't 
work at all, or it put Tomcat into a weird state (perhaps some weird 
option was set in the scripts or something?). Also, be careful what 
user you start/stop Tomcat as using the FreeBSD ports' tomcat4ctl or 
020.jakarta-tomcat4.sh. Some of our developers took it upon themselves 
to restart Tomcat. They naturally weren't logged in as root. I can't 
remember what happened (this may have been the older 3.x version that 
this happened on) but it didn't work.
   Since our developers make use of the CLASSPATH variable, we've had 
an issue recently with the latest Tomcat and the way it is started and 
the way it runs. There is no way (that I can figure out) to set the 
CLASSPATH variable and have it passed into Tomcat since version 4.x. I 
even manually modified daemonctl.c and rebuilt tomcat4ctl, having it 
pass the '-cp classpath' option to the java instance that would be 
executing bootstrap.jar. It was to no avail as the classpath must be 
cleared or ignored somewhere by Tomcat. When we output 
System.getProperty("java.class.path") we would always get 
"bin/boostrap.jar" and nothing else. It is here that my knowledge ends 
and my ignorance begins.

/*------------------------------------*/
*  - All port installation examples here make use of the portinstall 
command from the portupgrade utility collection. All examples could 
just as easily be installed by cd'ing to the port's directory and 
running: make install
     Ex. cd /usr/local/ports/java/jdk13; make install && make clean
To install and use portupgrade:
     cd /usr/local/ports/sysutils/portupgrade
     make install && make clean
     pkgdb -F
     portsdb -uU

** - The last time I installed the MySQL JDBC driver, the installation 
failed. To build it, it needed the JDK1.8 installed as well as a Java2 
JDK. I don't know if this is still the case. However, since FreeBSD 
Java uses the javavmwrapper port (some scripts and a registration file 
in /usr/local/etc) to manage the different JDK's you can install all 
the JDK's you want without a problem.
   The other option is to just download the pre-built driver from 
MySQL's web site, unjar it, and manually install the driver jar files 
wherever is convenient.
/*------------------------------------*/

   I have been learning a lot about the Java-on-FreeBSD world myself. 
The future looks as though it will only get better as the developers 
push the work of getting a true, native Java2 JDK on FreeBSD. Also, 
from following the freebsd-java mailing list, it looks like some 
people are getting functioning 1.4 JDK's running as well. I'm not 
sure, but it seems I heard word of someone getting native threads to 
work as well. Perhaps by the time one of the FreeBSD 5.x releases are 
out, we'll have a true, native JDK 1.3/1.4 with native 
threads/hotspot. All buildable from the ports (with no manual 
downloading).

   Anyhow, if you have any questions or comments on this brief 
instruction set, let me know. I know that when I first started trying 
to put Java/Tomcat of FreeBSD, it was a trifle confusing and difficult 
to find any kind of definitive or up-to-date guide. I'll try to post 
this on my web site and have members of the freebsd-java list review 
it. Then perhaps I can be of help to the open source community.
-- 
----------------------------------------
ASCII RIBBON CAMPAIGN       /\
NO HTML/RTF EMAILS!        /  \
                            \  /
Kendall P. Gifford          \/
kendall@jedis.com           /\
http://kendall.jedis.com   /  \
----------------------------------------





Eriq Lamar <eqe@cox.net>
Sent by: owner-freebsd-stable@FreeBSD.ORG
12/02/2002 07:18 PM

 
        To:     stable@FreeBSD.org
        cc: 
        Subject:        newbie trying to get java working on 4.7


that's it in a nut shell need help bad
-- 
    Sign,
     Eriq Lamar

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?OFA943A331.46900999-ON88256C84.0012A822>