FireDaemon Forums
Go Back   FireDaemon Forums > Support > HOWTOs: Application Tutorials > Java Servlet, JSP and XML Engines

Java Servlet, JSP and XML Engines HOWTOs and Tutorials regarding integrating FireDaemon with various Java Servlet, JSP and XML Engines.


Reply
 
Thread Tools Display Modes
  James Bourne's time 14th September 2005, 04:18 PM    #1  
Old 14th September 2005, 06:18 AM
James Bourne's Avatar
James Bourne James Bourne is offline
FireDaemon Tech Supp
 
Join Date: Jun 2005
Location: Sydney, AU
Posts: 604
Send a message via Skype™ to James Bourne
Default Apache Tomcat (Java)



How To Run Apache Tomcat as a FireDaemon Service

Tomcat ships with its own service runner. However, we recommend you use FireDaemon is preference. Why? Several reasons:

- Ability to instantiate multiple Tomcat instances per server (facilitating multiple JVM versions, Tomcat versions and so forth)
- Much easier to configure than the Apache service runner (everything is in one spot)
- CPU binding and process prioritisation (for performance tuning)
- Uses roughly 10MB of RAM less per instance (not that this matters much these days!)
- Save the FireDaemon service configuration as XML for use on other servers!
- Reliability. FireDaemon is bullet proof. The Apache Service Manager has had issues in the past!
- Can start the Tomcat service interactively for debugging

Anyway it's relatively straight forward to setup Tomcat running as a service under FireDaemon. Read this post in regard to general caveats when running Java as a Windows service.

1. Download and install J2SE(TM) Runtime Environment 5.0 from http://java.sun.com

2. Download and install Tomcat version 5.5 or later from: http://jakarta.apache.org/tomcat/index.html The Windows installer will install the Apache Service Manager in the System Tray plus install a service named Tomcat5. We will deal with these later.

3. Download and install FireDaemon from: http://www.firedaemon.com/downloads/

4. Start the FireDaemon GUI and click on the "Show All Services" toolbar button. Scroll down until you find the Apache installed service named Tomcat. Highlight it and then click the "Uninstall selected service" toolbar button. Confirm the service delete. You may get an error message from FireDaemon in regard to being unable to delete certain portions of the registry - this is normal and can be ignored.



5. Click the "Show All Services" toolbar button again. Now click on the "Create new service definition button" and fill out the fields exactly as you see below (modify the Short Name if you intend to run multiple Tomcat instances and adjust your paths where necessary). The entire Parameters line reads:

Code:
-Xrs -Dcatalina.home="%CATALINA_HOME%" -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" -Djava.util.logging.manager="%LOGGING_MANAGER%" org.apache.catalina.startup.Bootstrap start


6. Now click on the Advanced tab. If you wish to enable FireDaemon debug loggin, check the Enable Debugging option and enter a path and filename to the debug log file. If you wish to capture Tomcat's Stdout and Stderr output enter a path and filename in both the "Capture Stdout in File" and "Capture Stdd in File" fields.



7. Now click on the Dependencies tab. Add a service dependency. This will ensure Tomcat starts late in the boot cycle (ie. after the TCP/IP and CIFS stacks have initialised). "lanmanworkstation" is the Workstation service.



8. Now click on the Environment tab. This is where you would enter environment variables specific to your Tomcat instance. The names and values of the environment variables are below (adjust your paths to suite). Note that environment variable order is important:

Code:
JAVA_HOME: C:\Program Files\Java\jre1.5.0_04
CATALINA_HOME:  C:\Program Files\Apache Software Foundation\Tomcat 5.5
CLASSPATH: %CATALINA_HOME%\bin\bootstrap.jar
CATALINA_TMPDIR: %CATALINA_HOME%\temp
JAVA_ENSORSED_DIRS: %CATALINA_HOME%\common\endorsed
LOGGING_MANAGER: org.apache.juli.ClassLoaderLogManager


9. Now click on the Pre / Post-Service tab. Append a new Post-Service Program. This is where we setup Tomcat to stop gracefully when we shutdown the service. The complete value of the Parameters field is:

Code:
-Xrs -Dcatalina.home="%CATALINA_HOME%" -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" -Djava.util.logging.manager="%LOGGING_MANAGER%" org.apache.catalina.startup.Bootstrap stop


10. Lastly click in the Install button and your Tomcat service should be installed and started.



Point your browser at the Tomcat instance to ensure it is up and running. If you have issues, refer to the FireDaemon debug log file, Windows Event Viewer and the Tomcat log files. Alternately, run the FireDaemon service interactively and turn off logging to Stderr/Stdout so you can see what is happening when the Tomcat instance starts.



Below is the FireDaemon service configuration XML. Scrape this to file and then load it into the FireDaemon GUI (create new service and then click on the "Open a service definition file" toolbar button - alternately you can do it via the command line: firedaemon --install tomcat.xml). Apologies for line wrap below:

Code:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Service>
 <Program>
  <Name>Tomcat</Name>
  <DisplayName>Tomcat</DisplayName>
  <Description>Apache Tomcat 5.5.9</Description>
  <WorkingDir>C:\Program Files (x86)\Apache Software Foundation\Tomcat 5.5</WorkingDir>
  <Executable>C:\Program Files (x86)\Java\jre1.5.0_04\bin\java.exe</Executable>
  <Parameters>-Xrs -Dcatalina.home=&quot;%CATALINA_HOME%&quot; -Djava.endorsed.dirs=&quot;%JAVA_ENDORSED_DIRS%&quot; -Djava.io.tmpdir=&quot;%CATALINA_TMPDIR%&quot; -Djava.util.logging.manager=&quot;%LOGGING_MANAGER%&quot; org.apache.catalina.startup.Bootstrap start</Parameters>
  <Delay>3000</Delay>
  <ConsoleApp>true</ConsoleApp>
  <ForceReplace>true</ForceReplace>
 </Program>
 <Options>
  <AffinityMask>0</AffinityMask>
  <Priority>0</Priority>
  <AppendLogs>true</AppendLogs>
  <EventLogging>true</EventLogging>
  <InteractWithDesktop>true</InteractWithDesktop>
  <PreLaunchDelay>0</PreLaunchDelay>
  <StartUpMode>1</StartUpMode>
  <UponExit>1</UponExit>
  <UponFlap>0</UponFlap>
  <FlapCount>0</FlapCount>
  <ShutdownDelay>5000</ShutdownDelay>
  <ShowWindow>0</ShowWindow>
  <JobType>0</JobType>
  <IgnoreFlags>0</IgnoreFlags>
  <Dependencies>
   <ServiceName>lanmanworkstation</ServiceName>
  </Dependencies>
 </Options>
 <RedirectIO>
  <Stdout>C:\Program Files (x86)\Apache Software Foundation\Tomcat 5.5\stdout.log</Stdout>
  <Stderr>C:\Program Files (x86)\Apache Software Foundation\Tomcat 5.5\sterr.log</Stderr>
 </RedirectIO>
 <Debug>
  <DebugEnabled>true</DebugEnabled>
  <DebugLocation>C:\Program Files (x86)\Apache Software Foundation\Tomcat 5.5\tomcat.log</DebugLocation>
 </Debug>
 <Environment>
  <Variable Name="JAVA_HOME">C:\Program Files (x86)\Java\jre1.5.0_04</Variable>
  <Variable Name="CLASSPATH">C:\Program Files (x86)\Apache Software Foundation\Tomcat 5.5\bin\bootstrap.jar</Variable>
  <Variable Name="CATALINA_HOME">C:\Program Files (x86)\Apache Software Foundation\Tomcat 5.5</Variable>
  <Variable Name="CATALINA_TMPDIR">%CATALINA_HOME%\temp</Variable>
  <Variable Name="JAVA_ENDORSED_DIRS">%CATALINA_HOME%\common\endorsed</Variable>
  <Variable Name="LOGGING_MANAGER">org.apache.juli.ClassLoaderLogManager</Variable>
 </Environment>
 <SMF>
  <SMFEnabled>true</SMFEnabled>
  <SMFFrequency>5000</SMFFrequency>
 </SMF>


 <Scheduling>
  <StartTime>00:00:00</StartTime>
  <EndTime>00:00:00</EndTime>
  <RunDays>127</RunDays>
  <MonthFrom>0</MonthFrom>
  <MonthTo>0</MonthTo>
  <MonthDay>0</MonthDay>
  <RestartFreq>0</RestartFreq>
  <RestartDelay>0</RestartDelay>
 </Scheduling>
 <PostService>
  <PostWorkingDir>C:\Program Files (x86)\Apache Software Foundation\Tomcat 5.5</PostWorkingDir>
  <PostExecutable>C:\Program Files (x86)\Java\jre1.5.0_04\bin\java.exe</PostExecutable>
  <PostEventOrder>1</PostEventOrder>
  <PostParameters>-Xrs -Dcatalina.home=&quot;%CATALINA_HOME%&quot; -Djava.endorsed.dirs=&quot;%JAVA_ENDORSED_DIRS%&quot; -Djava.io.tmpdir=&quot;%CATALINA_TMPDIR%&quot; -Djava.util.logging.manager=&quot;%LOGGING_MANAGER%&quot; org.apache.catalina.startup.Bootstrap stop</PostParameters>
  <PostDelay>10000</PostDelay>
 </PostService>



 <DlgResponder>
  <Enabled>false</Enabled>
  <CloseAll>false</CloseAll>
  <CheckFrequency>5000</CheckFrequency>
  <IgnoreUnknowns>true</IgnoreUnknowns>
  <LogFile></LogFile>
  <Responses>
  </Responses>
 </DlgResponder>

</Service>
Reply With Quote
Reply

Bookmarks

Tags
apache, java, tomcat

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

 
Free 30 Day Trial

Join our Newsletter
Once a month we poke the right people on product releases and promos.



Connect with us



Latest HOWTOs



All times are GMT. The time now is 03:06 AM.


Powered by vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Template-Modifications by TMS
Copyright © 2009 FireDaemon Technologies Limited

[Close]