Web Server Setup: 04 - JSP Server ( Tomcat )

Apache jsp server ( Tomcat )

Note: Had to change port# from 8080 to 8081 with VisualSVN running

\xampp\tomcat\conf\server.xml:

<Connector port="8081" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

   

 

Environment Variables ( Source: RUNNING.txt)

3) Configure Environment Variables

 

Tomcat is a Java application and does not use environment variables. The

variables are used by the Tomcat startup scripts. The scripts use the variables

to prepare the command that starts Tomcat.

 

(3.1) Set CATALINA_HOME (required) and CATALINA_BASE (optional)

 

The CATALINA_HOME and CATALINA_BASE environment variables are used to

specify the location of Apache Tomcat and the location of its active

configuration, respectively.

 

The CATALINA_HOME environment variable should be set as defined in (2.2)

above. The Tomcat startup scripts have some logic to set this variable

automatically if it is absent (based on the location of the script in

Unixes and on the current directory in Windows), but this logic might not work

in all circumstances.

 

The CATALINA_BASE environment variable is optional and is further described

in the "Multiple Tomcat Instances" section below. If it is absent, it defaults

to be equal to CATALINA_HOME.

 

 

(3.2) Set JRE_HOME or JAVA_HOME (required)

 

The JRE_HOME variable is used to specify location of a JRE that is used to

start Tomcat.

 

The JAVA_HOME variable is used to specify location of a JDK. It is used instead

of JRE_HOME.

 

Using JAVA_HOME provides access to certain additional startup options that

are not allowed when JRE_HOME is used.

 

If both JRE_HOME and JAVA_HOME are specified, JRE_HOME is used.

 

‘JAVA_HOME’ Environment Variable

setclasspath.bat

This file will check for presence of JAVA_HOME environment variable and, if found, will check for 4 files in the path ‘%JAVA_HOME%\bin\’

Here’s the initial discovery routine

:needJavaHome
rem Check if we have a usable JDK
if "%JAVA_HOME%" == "" goto noJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\javaw.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\jdb.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome
set "JRE_HOME=%JAVA_HOME%"

CATALINA_OPTS

set CATALINA_OPTS=-Xms256m -Xmx512m

CATALINA_OPTS or JAVA_OPTS?

CATALINA_OPTS is used to control Tomcat environment options, whereas JAVA_OPTS controls the environment options at a higher level ie. for any Java library.

You can start Tomcat with more heap memory using the following:

On Windows
Edit the file $TOMCAT_HOME\bin\startup.bat and insert or alter the following line, substituting for the desired values:
set CATALINA_OPTS=-Xms(min heap)m -Xmx(max heap)m

For example if you want to allocate a minimum heap size of 256MB and a max heap size of 512MB you will have to write the following on Windows:
set CATALINA_OPTS=-Xms256m -Xmx512m

The line you add should go just before the line starting call “%EXECUTABLE%”…

If you are running tomcat 5.5 via tomcat.exe, you can update the heap size by running tomcatw.exe and setting the required values via the Java tab.

On Linux
Edit the file $TOMCAT_HOME/bin/startup.sh and insert the following line, substituting for the desired value, eg. Bash Shell:
export CATALINA_OPTS=”-Xms(min heap)m -Xmx(max heap)m”

The line you add should go just before the line starting exec “$PRGDIR…

Permanent Generation Size

If you get the error message: java.lang.OutOfMemoryError: PermGen space you need to add the argument -XX:MaxPermSize=128m to CATALINA_OPTS, in addition to any argument you use to set the heap size.

‘CATALINA_HOME’ Environment Variable

This is used by the scripts to locate critical components and CAN’T be hard-coded

Setting the Environment Variables

 

JDK/JRE Installation

  • Copied JRE6 to D:\xampp\jre6
  • Set JAVA_HOME to same path
  • TomCat was failing due to inability to discover JDK/JRE
  • Installed ‘jdk-6u43-windows-i586.exe’
  • Set JAVA_HOME to ‘C:\Program Files (x86)\Java\jdk1.6.0_43 \’

After installing LoadUI, now TomCat won’t load due to JDK/JRE conflicts…need to check registry settings

TomCat Error when JDK/JRE can’t be found in the registry

11:04:28 PM  [Tomcat]           Attempting to start Tomcat app...
11:04:28 PM  [Tomcat]           Tomcat Started/Stopped with errors, return code: 1
11:04:28 PM  [Tomcat]           Make sure you have Java JDK or JRE installed and the required ports are free
11:04:28 PM  [Tomcat]           Check the "/xampp/tomcat/logs" folder for more information

After installing JDK6, it successfully started:

11:17:56 PM  [Tomcat]           Attempting to start Tomcat app...
11:17:58 PM  [Tomcat]           Status change detected: running
11:25:05 PM  [mysql]             Attempting to start MySQL app...
11:25:05 PM  [filezilla]           Attempting to start FileZilla app...
11:25:06 PM  [filezilla]           Status change detected: running
11:25:07 PM  [mysql]             Status change detected: running

catalina_start.bat output

[XAMPP]: Searching for JDK or JRE HOME with reg query ...
ERROR: The system was unable to find the specified registry key or value.
. [XAMPP]: Could not find 32 bit or 64 bit JDK
. [XAMPP]: Looking for 32 bit JDK on 64 bit machine
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Development Kit
    CurrentVersion    REG_SZ    1.6
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Development Kit\1.6
    JavaHome    REG_SZ    C:\Program Files (x86)\Java\jdk1.6.0_43
    MicroVersion    REG_SZ    0
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Development Kit\1.6.0_43
    JavaHome    REG_SZ    C:\Program Files (x86)\Java\jdk1.6.0_43
    MicroVersion    REG_SZ    0
[XAMPP]: Using JDK
[XAMPP]: Seems fine!
[XAMPP]: Set JAVA_HOME : C:\Program Files (x86)\Java\jdk1.6.0_43
[XAMPP]: Set CATALINA_HOME : D:\xampp\tomcat
Using CATALINA_BASE:   "D:\xampp\tomcat"
Using CATALINA_HOME:   "D:\xampp\tomcat"
Using CATALINA_TMPDIR: "D:\xampp\tomcat\temp"
Using JRE_HOME:        "C:\Program Files (x86)\Java\jdk1.6.0_43"
Using CLASSPATH:       "D:\xampp\tomcat\bin\bootstrap.jar;D:\xampp\tomcat\bin\to
mcat-juli.jar"
Jun 3, 2012 11:17:57 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performanc
e in production environments was not found on the java.library.path: C:\Program
Files (x86)\Java\jdk1.6.0_43\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\
Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\Syste
m32\WindowsPowerShell\v1.0\;.
Jun 3, 2012 11:17:57 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jun 3, 2012 11:17:57 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jun 3, 2012 11:17:57 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 484 ms
Jun 3, 2012 11:17:57 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jun 3, 2012 11:17:57 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.30
Jun 3, 2012 11:17:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\xampp\tomcat\webapps\docs
Jun 3, 2012 11:17:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\xampp\tomcat\webapps\examples
Jun 3, 2012 11:17:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\xampp\tomcat\webapps\host-manager
Jun 3, 2012 11:17:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\xampp\tomcat\webapps\manager
Jun 3, 2012 11:17:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\xampp\tomcat\webapps\ROOT
Jun 3, 2012 11:17:58 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jun 3, 2012 11:17:58 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jun 3, 2012 11:17:58 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 623 ms

JAVA & ECLIPSE IDE ( Java Programming )

  • Start Eclipse with a similar script, with the JAVA_HOME environment variable present
@echo off
set  DEV_HOME=D:\devl\Java
set JAVA_HOME=%DEV_HOME%\java32\jdk1.6.0_33\jre
set PATH=%JAVA_HOME%\bin;%PATH%
start %DEV_HOME%\eclipse\eclipse.exe -vm %JAVA_HOME%\bin\javaw.exe -showlocation -vmargs -server -Xms512m -Xmx1024m -XX:MaxPermSize=128m