View System Documentation - Tomcat Notes
Installation Steps
- Download and install J2SE JDK 1.6+ from Sun's site. As of 1/2005, IBIS-PH doesn't use any of the new features of Java Version 1.5 but the class files are compiled using JDK 1.6. Plus 1.5+ has seen some speed and XML improvements that are worthwhile. Tomcat 5.x requires Java JVM 1.5+, while Tomcat 4.x can use either JVM (any 1.2+ JVM). If the platform is Windows it is recommended to download the Windows version that has the installer which sets the appropriate paths etc. Make sure that the JDK is downloaded NOT the JRE! If using previous version the source Java code will need to be complied for the destination JDK.
- Download the Tomcat app server package from the Apache Tomcat site. Follow links to the downloads and select the desired version. Again if the target platform is a Windows operating system and it is desired to have the application server run as a Windows service then download the Windows installer version.
- Install Tomcat
- Setup/configure the Tomcat Java JVM
- Edit/configure Tomcat's default web application behaviour (web.xml)
- Edit/configure Tomcat's control file (server.xml)
- Change the shutdown signature and port
- Change the port (development only) and enable compression
- Configure Access Logs for access trending/analysis
- Remove all default webapp contexts
- Add/edit/configure the View app's context
- Optionally, configure the HTTPS (SSL) connector
- Optionally, configure the Character Encoding
- Physically delete/remove the standard Tomcat webapp(s)
- Deploy the IBIS-PH View System webapp
Misc Info
Tomcat Install Overview
Tomcat comes in either zip, tar, rpm, or Windows exe format for the specified OS and CPU. Basically what happens is that the Tomcat system files are extracted into a directory. The main thing that the system needs is to have the Java environment setup and some environment variables that should be set, which are:- JAVA_HOME = JDK Root dir (needs to include the tools.jar. Typically this path is like: d:\java\1.5.1\ (Windows) or /usr/local/java1.5.1 (linux) and has sub directories like bin/ & lib/.
- CATALINA_HOME = tomcat root dir (e.g. D:/tomcat or /usr/local/tomcat5).
- CATALINA_OPTS = (optional) Contains command line arguments like JVM memory settings. This value is NOT required for the system to run but it is the easiest way to set the JVM settings. Another way is to modify the catalina.sh or catalina.bat file located in the [CATALINA_HOME]/bin directory.
Windows installer note: If installers used then only the CATALINA_OPTS
probably needs to be set as everything else is handled by the
program's setup.
See the Tomcat Jarkarta website for more information on setup.
Multiple Tomcats Note: If on the same box, then modify the startup (.sh/.bat) catalina files and specify the appropriate JAVA_HOME and CATALINA_HOME variables in those files. There are other ways to make this work as well - that's simply one. Listed below are the changes made to the startup.bat and catalina.bat file.
See the Tomcat Jarkarta website for more information on setup.
Multiple Tomcats Note: If on the same box, then modify the startup (.sh/.bat) catalina files and specify the appropriate JAVA_HOME and CATALINA_HOME variables in those files. There are other ways to make this work as well - that's simply one. Listed below are the changes made to the startup.bat and catalina.bat file.
startup.bat:
REM Commented out the usage of the existing Tomcat4 env variable:
REM if not "%CATALINA_HOME%" == "" goto gotHome
catalina.bat (added to the top and switch back at the bottom):
set TEMP_JAVA_HOME=%JAVA_HOME%
set TEMP_CATALINA_HOME=%CATALINA_HOME%
set JAVA_HOME=d:\java\1.5.1
set CATALINA_HOME=d:\tomcat5
For Linux, modified the catalina.sh file to have this at the top:
JAVA_HOME=/usr/local/java/jdk1.5.0_02
JAVA_OPTS="-Djava.awt.headless=true"
CATALINA_HOME=/usr/local/jakarta-tomcat-5.5.9
CATALINA_OPTS="$CATALINA_OPTS -server -Xms1024m -Xmx1024m -Xmn256m"
java -Djava.awt.headless=true
REM Commented out the usage of the existing Tomcat4 env variable:
REM if not "%CATALINA_HOME%" == "" goto gotHome
catalina.bat (added to the top and switch back at the bottom):
set TEMP_JAVA_HOME=%JAVA_HOME%
set TEMP_CATALINA_HOME=%CATALINA_HOME%
set JAVA_HOME=d:\java\1.5.1
set CATALINA_HOME=d:\tomcat5
For Linux, modified the catalina.sh file to have this at the top:
JAVA_HOME=/usr/local/java/jdk1.5.0_02
JAVA_OPTS="-Djava.awt.headless=true"
CATALINA_HOME=/usr/local/jakarta-tomcat-5.5.9
CATALINA_OPTS="$CATALINA_OPTS -server -Xms1024m -Xmx1024m -Xmn256m"
Headless graphics
Batik requires Graphics2D, the standard Java API for 2D graphics, to generate the images. This may be a problem with UNIX or Linux Web servers because Graphics2D needs an X11 server, which seldom runs on Web servers. Since JDK 1.4, you can run a so-called headless application by setting the java.awt.headless property to true. Note that the JDK still links to the X11 library, but the server doesn't need to be started. You can set the property directly on the command line or environment variable like above:java -Djava.awt.headless=true
Setup Tomcat Account
This runs Tomcat as something other than root/system. Doing this simply locks down the possibility of a stray application getting on the system and being able to do damage. This is outlined in the Wrox Apache Tomcat 5 book and is also discussed in numerous websites like jGuru. Listed below are some general steps from the book:- create a "tomcat" account which owns and has the privs to where tomcat will be installed and ran from.
- Make sure the tomcat account has the JAVA_HOME and CATALINA_HOME enviro variables.
Windows:
- the tomcat account should be removed from all groups.
- IF running as a service, the Services utility can be used to select a user account for use when launching Tomcat (Admin Tools). Double click the tomcat service, [Log On] tab, then "log on as" and enter the un/pw.
- Else IF NOT as a service, then use the Window's "run as" command:
"run as" /user:tomcat c:\tomcat\bin\startup.bat
Linux:
- create both a tomcat user and tomcat group (adduser)
- Secure the tomcat file system.
- Secure the JVM
For more specifics on file privs etc. see: Chapter 15, Tomcat
Security, of Professional Apache Tomcat 5. ISBN: 0-7645-5902-8
Windows Tomcat Setup
Run the .exe file which runs a windows setup. This steps you through everything and installs a tomcat service which can auto start on system startup.
Windows Service Notes: If you want the system out log, you'll need to
check the Tomcat service's "allow to interact with the system" checkbox.
IMPORTANT: For Windows XP, Server 2003, and after, the "mssvcr71.dll" either needs to be copied into the "windows/system32" directory or the "c:/java/jdk1.6/bin" (or whereever the JVM is installed) needs to be part of the system's path so that the dll can be found and loaded. If this is not done the Apache-Tomcat service will not be able to start. Later versions of the Tomcat installer must have fixed this issue since it appears to not be an issue for Adopters in 2008.
IMPORTANT: For Windows XP, Server 2003, and after, the "mssvcr71.dll" either needs to be copied into the "windows/system32" directory or the "c:/java/jdk1.6/bin" (or whereever the JVM is installed) needs to be part of the system's path so that the dll can be found and loaded. If this is not done the Apache-Tomcat service will not be able to start. Later versions of the Tomcat installer must have fixed this issue since it appears to not be an issue for Adopters in 2008.
If this step is done by hand, simply unzip the installation package and set the environment variables. You can then run the [CATALINA_HOME]/bin/startup.bat to start, and press [Ctrl]-c in the system out window to stop the server or run the shutdown.bat file located in the same bin directory. The startup.bat then needs to be part of the one of the Windows on startup mechanisms.
Linux Tomcat Setup
IMPORTANT: For the Batik Graphics to be able to convert SVG to JPEG on Unix,
the headless environment variable or Java system property must be set.
Env Var: JAVA_OPTS='-Djava.awt.headless=true'
JVM 1.4+ System Property: java.awt.headless=true
See Paul Leo's system setup document for the main meat.
JVM 1.4+ System Property: java.awt.headless=true
Multiple Tomcat Installs on the Same Server
Here's a simple list for multiple installs on the same server. Of course there are many options here including one install with multiple engines etc.- Installed into different directories
- Modified both installed catalina.sh (linux) (or catalina.bat for windows) files as described
- Changed the server ports to be unique e.g. <Server port="8005"
- Changed the connector ports to be unique e.g. <Connector port="8080"
- Added unique jvmRoute attribute to the Engine element e.g. <Engine jvmRoute="tomcat4"
JVM Memory Settings
Add the JVM memory settings within the env var CATALINA_OPTS (JAVA_OPTS also works but will apply the settings to any JVM request). There isn't a hard and fast rule on what these numbers should be because it depends on a variety of factors. The Apache Tomcat5 book recommends setting the Xms and Xmx the same to minimize the time it takes to grow the heap. It is recommended to specify a considerably lower value than the amount of physical RAM in your system, so the operating system and other applications will also have enough space. Otherwise the swap memory of the operating system will be used, which can result in high disk activity (thrashing), and reduced system performance. See Bea's JVM Tuning Page for info on how to tune WebLogic and general JVM settings.
NOTE: This settings are for Sun's JVM. Other JVMs may have
different command line settings. Also, these settings might not apply
to latter versions of the JVM.
Basically there are 3 main values that should be set. These are the min heap size "Xms" the max heap size "Xmx" and the server flag "server".
Example:
LINUX: CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx512m"
WINDOWS: set CATALINA_OPTS=-server -Xms256m -Xmx512m
WINDOWS: set CATALINA_OPTS=-server -Xms256m -Xmx512m
NOTE: Server mode instructs the JVM to perform more extensive run-time optimization.
This flag MUST be the first argument/parameter specified otherwise it will be set
as a "client" (according to http://java.sun.com/docs/hotspot/PerformanceFAQ.html).
Specifying the "server" flag means that right after startup the system will have
slightly slower execution, but after the JVM had enough time to optimize the code,
the execution should be faster.
Garbage Collection
Again this may or may not apply to the later JVM versions. These notes are simply here for historical purposes and may prove to be useful.It appears that when specifying garbage collection that if large amounts of memory (greater than 256M) are specified then the incremental compacting GC should not be used for performance reasons (-Xincgc). This bottleneck was experienced when running Tomcat4 with Java 1.4 on Susue Linux 9, and heap of 512m to 1024m. According to Sun on JVM 1.3, if you need lots of memory and experience a GC delay, try setting the "eden" sizes: -XX:NewSize=128m -XX:MaxNewSize=128m (or set a ratio of old to new via -XX:NewRatio=8). Another way to set this size is using -Xmn256m. Eden is where all new objects are created. According to Sun, most objects are short term objects and as such are better off caught in a small memory area that is quickly and easily garbage collected (e.g. don't have to go through a huge memory pool). The long term objects are then copied into the perm heap area and GC'd differently. Also, turn on GC messages by issuing this on the command line: -verbose:gc -Xloggc. Can also profile heap usage by -Xrunhprof:heap=all or other option, try -Xrunhprof:help. Also see jvmstat tool. Also note that these settings are for Sun JVMs 1.4+.
JVM 1.5:
This might be something to try also: Use the parallel young generation collector (-XX:+UseParallelGC) along with the adaptive size policy feature (-XX:+UseAdaptiveSizePolicy).
JVM Links
- Sun's J2EE and SE Performance Tuning
- Sun's VM Options Page for 1.4+
- http://java.sun.com/performance/
- Tuning Garbage Collection with the 1.3.1 Java Virtual Machine
- http://java.sun.com/docs/hotspot/PerformanceFAQ.html
- Sun One - Chapter 5:Tuning the Java Runtime System
- Sun's J2EE and SE Performance Tuning
- Java Performance Tuning.Com
- Caucho Performance Tuning
NOTES:
Tried CATALINA_OPTS of: -server -Xms256m -Xmx256m -heapsize32m -freememory20m but these heap and free mem settings wouldn't work as documented.
ANOTHER OPTION - EDIT CATALINA.SH (linux) or CATALINA.BAT (windows)
Can also set the JVM memory settings by modifying this script file which is typically used to start Tomcat. These files can also be modified for the HOME enviro vars so that the environment variables are not needed/used. Both of these files are located in the [CATALINA_HOME]/bin directory.
WINDOWS SERVICE: If Tomcat was installed on Windows as a service then the enviro variable probably doesn't need to be set depending on the version and the installer (test). Or, if installed you should be able to set by going to: Start / Programs / Apache / Tomcat 5.0 / Configure Tomcat. This will open up a dialog box to change settings. Click the middle tab, Java VM. There is a text area to add Java Options. After the last entry/value, add -Xms###m -Xmx###m. Click Apply or OK, and restart the Tomcat service.
NOTE: This requires Tomcat to be started and the system apps to not be removed as outlined/semi-recommended in this document.
Tried CATALINA_OPTS of: -server -Xms256m -Xmx256m -heapsize32m -freememory20m but these heap and free mem settings wouldn't work as documented.
ANOTHER OPTION - EDIT CATALINA.SH (linux) or CATALINA.BAT (windows)
Can also set the JVM memory settings by modifying this script file which is typically used to start Tomcat. These files can also be modified for the HOME enviro vars so that the environment variables are not needed/used. Both of these files are located in the [CATALINA_HOME]/bin directory.
WINDOWS SERVICE: If Tomcat was installed on Windows as a service then the enviro variable probably doesn't need to be set depending on the version and the installer (test). Or, if installed you should be able to set by going to: Start / Programs / Apache / Tomcat 5.0 / Configure Tomcat. This will open up a dialog box to change settings. Click the middle tab, Java VM. There is a text area to add Java Options. After the last entry/value, add -Xms###m -Xmx###m. Click Apply or OK, and restart the Tomcat service.
NOTE: This requires Tomcat to be started and the system apps to not be removed as outlined/semi-recommended in this document.
EXAMPLE JVM SETTINGS FROM COCOON V2:
(default)64 | 128 | 256 | 384 | |
---|---|---|---|---|
Xms | 0 | 0 | 0 | 0 |
Xmx | 64 | 100 | 228 | 356 |
heapsize | 60 | 80 | 208 | 236 |
freememory | 1 | 20 | 20 | 20 |
So if you see errors like:
java.lang.OutOfMemoryError <<no stack trace available>> java.lang.OutOfMemoryError <<no stack trace available>> Exception in thread "main"Then you'll need to increase the stack space.
Edit Tomcat's Default Webapp Behaviour
The file $CATALINA_HOME/conf/web.xml is the default system Deployment Descriptor for all web applications. Each IBIS-PH application specifies most of these settings but it's still a good idea to have a default welcome page and general error pages even though the IBIS-PH apps specify these.
IMPORTANT: Make a backup copy of this file before editing. Also note that the
elements are ordered and that these elements MUST be in an exact order. See
Bea's web.xml defs
for more info on each element.
ENABLE / DISABLE DIRECTORY LISTINGS AND MAKE HTTP READ ONLY
Edit the $CATALINA_HOME/conf/web.xml file and locate the main servlet element's init params (located in the upper section). Change the parameter's value with the 'param-name' of 'listings' from 'true' to 'false'. Tomcat defaults with the system being in read only mode but it's best to make sure explicitly. Add a 'init-param' element like given below. "Read-Only" means that HTTP DELETE and PUT requests are rejected.<servlet> <servlet-name>default</servlet-name> <servlet-class>org.apache.catalina. servlets.DefaultServlet</servlet-class> . . . <init-param> <param-name>listings</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>readonly</param-name> <param-value>true</param-value> </init-param> . . .
REMOVE / COMMENT OUT INVOKER SERVLET
Comment out or delete the servlet invoker definition and mapping:<servlet> <servlet-name>invoker</servlet-name> . . . and <servlet-mapping> <servlet-name>jsp</servlet-name> <url-pattern>*.jsp</url-pattern> </servlet-mapping>
SET DEFAULT SYSTEM WELCOME PAGES
The welcome pages are simply a list of files/urls that will be called if a general, non specific application request is made to the system. If it is a general request to an application e.g. http://ibis.health.utah.gov/ibisph-view then the "ibisph-view" application will have a welcome list that will be used (as well as a default servlet call). If an application is installed as the "ROOT" application or has it's application path set to "/" then it's welcome pages will be used first for the system. Else, the files listed here will be used in the order they are listed (e.g. if it can't find the first welcome file it will go to the next one). Also, note that the items listed MUST be a file and NOT an application servlet call.BOTTOM LINE: This isn't needed because the IBIS-PH applications provides this. However, below is a sample of what this would look like if it was needed.
<welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>/ibisph-view/index.html</welcome-file> <welcome-file-list>
SET ERROR PAGE
At a very minimum, the HTTP 404 code should be handled in case a request is made to the general system that does not exist (same bottom line as the welcome pages).<error-page> <error-code>404</error-code> </location>http://health.utah.gov/error</location> <error-page>
SETTING DEFAULT SESSION TIMEOUT
This value really isn't needed for IBIS-PH apps since each already specifies this value in their respective web.xml files. In any case if a default is wanted for the system set this value:<session-config> <session-timeout>30</session-timeout> </session-config>
"default" SERVLET NOTE:
This is required for the system to function. Also, if any of the applications
need to serve files then the url pattern of "/" is needed. Without this pattern
there is no process to locate and stream back data files. If not specified then
each app needs to have a file serving servlet...
Edit / Configure Tomcat's server.xml
This is the main configuration file that controls the host engine and application contexts. These are optional and is not needed for the application to work but are some common entries that some system administrators should consider changing.IMPORTANT: Make a backup copy of this file before editing.
See Demystifying Tomcat 4's server.xml File for more info on each element. Or Tomcat's docs.
CHANGE SHUTDOWN PORT AND SIGNATURE
<Server port="8007" shutdown="remoteshutdown" debug="0">
CHANGE CONNECTOR'S PORT AND ENABLE COMPRESSION
Leave at 8080 for OIT. I change it to 80 so I don't have to do localhost:8080 in my development environment. Also, for faster development, leave the compression off. Some sites might want to use 80 if on Linux there's a way to keep on 8080 and remap 80 to it (see Paul Leo's setup document).<Connector port="80" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" *** BELOW IS FOR TOMCAT 5 ONLY AND ONLY FOR PRODUCTION *** compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata" compressableMimeType="text/html,text/xml" >
CONFIGURE ACCESS LOGS TO BE READABLE FOR TRENDING PACKAGES
If this app server is being front ended by Apache, performance can be increased by not logging access. If this is the case, then skip this. Else, within the Engine element set a value element to be like the one below (pattern attribute is the key):<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="access" suffix=".log" resolveHosts="true" pattern="common" />And, define the actual logger class. Within the Host element make sure there's an entry like:
<Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true" />See http://www.faqchest.com/prgm/tomcat-l/ tmct-02/tmct-0210/tmct-021056/tmct02101513_20837.html for more specifics.
TURN OFF UNPACK and AUTO DEPLOY
For speed, and security, remove the autodeploy and unpacking of wars from a production environment. For development, leave these on and also set the 'appBase' set to the CVS/ IBIS folder's webapps directory. This allows for everything to be kept in one directory for easy backups and easier management of all the related project work products. Note that you can leave the WAR packed for even tighter security. This doesn't allow for hot patching of files and according to the docs will be a little slower than when compared with a fully extracted war. If using a process where a Maven or Ant build is pushed to the app server then the auto deploy should be enabled otherwise the app server will have to be restarted.<Host name="localhost" debug="0" appBase="webapps" unpackWARs="false" autoDeploy="false">
REMOVE ALL OTHER WEBAPP CONTEXTS
For a production environment, comment out or remove all the defined "Context" elements which includes examples, ROOT, etc. These elements are contained within the Host element and look like:<Context path="/examples" docBase="examples" debug="0" . . .
ADD IBISPH VIEW SYSTEM CONTEXT
There are several ways to set the View system as the default app. Rename the app's main directory as "ROOT", specify in the context in the app's META-INF/context.xml file or set the context in the server.xml file as shown below:<Context path="" docBase="ibisph-view" debug="0" reloadable="false" crossContext="false" /> <Context path="/ibisph-view" docBase="" debug="0" reloadable="false" crossContext="false" />
NOTES: For development, leave the reloadable="true" so that the app will auto reload
whenever any of the class files change (e.g. if re-compiled). For those that do NOT
want cookie support, add the cookies="false" attribute to the Context element. Session
objects will then use URL re-writing.
TWO CONTEXTS FOR A GIVEN APP: Tomcat requires a default/root app. Tomcat also auto creates contexts within applications it finds within it's default appBase folder. So if the view system is setup as the default app, Tomcat will auto create a context with the path of "/ibisph-view/". The problem/issue is if there are 2 contexts both pointing to the same docbase then you'll get 2 instances of the same app within the webapp server container/JVM which run separately but use/share the same files. So for something like artifacting, you'll have files which have navigation built for potentially two different contexts. In the old way of artifacting a hash was used which really could get things messed up pretty quick - concerning. To get around this create a blank or a dummy docBase which matches the /ibisph-view path. This forces Tomcat to not auto create a working "ibisph-view" app. Note that Tomcat 559 will complain if a base of "dummy" or any other invalid/non existent directory name is specified. It doesn't complain about "" being used. There are other ways around this also like not having a "base" webapps directory and simply having a single app under a single virtual host. Also can put directory outside of the base directory then the path looks funny etc.
ANOTHER WAY NOTES: Specify the Host appBase attribute to be: webapps/ibisph-view then set the docBase of the context to / and the admin's docBase to ../ibisph-admin. The blank dummy context can then be removed. The view system as of Oct, 2005 handles both contexts being used. However, with artifacting, the first time the page is artifacted is how the menuing system will be saved. So if the ibisph-view/home/Welcome.html is hit first then all of it's navigation will be ibisph-view/... (which works) but then if someone else comes and hits a page as the root/default app then some pages will have the ibish-view context while others will have navigation links that have a blank context.
WARS, AUTODEPLOY, CONTEXTS: if a context is specified, the war won't auto redeploy (even if enabled). To get around this you need to delete the app's files and then the system will auto deploy the war (assuming enabled and the war is in the webapps directory).
DEVELOPMENT DIRECTORY NOTE: If you have your webapp located outside the normal directory specified with the Host element then you'll need to explicitly point to that directory in the "docBase" attribute.
NOTE ABOUT APP SERVLET MAPPING (web.xml): You can have a blank servlet alias but then everything will be funneled through that servlet. So all requests for jsps javascripts, css, etc. would all hit that servlet and not be served up as web content.
HTTPS Configuration (Optional)
HTTPS allows data sent to/from the server to be encrypted using Secure Socket Layer (SSL). This secure data communication is desirable when dealing with sensitive query datasets or sensitive indicator profiles etc. Note that to be effective, an authentication and authorization mechanism needs to be utilized in addition to the encrypting of the data transferred. Also note that a separate installation of the application should also be considered to ensure that all requests and traffic are authorized and encrypted.The basic steps are:
- If you are running a 1.3 JVM (version 1.4+ already has this bundled in), download JSSE 1.0.3 (or later) from http://java.sun.com/products/jsse/ and either make it an installed extension on the system, or else set an environment variable JSSE_HOME that points at the directory into which you installed JSSE.
- Create a certificate keystore by executing the following command:
Windows: %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
Unix: $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA
and specify a password value of "changeit". - Uncomment the "SSL HTTP/1.1 Connector" entry in $CATALINA_HOME/conf/server.xml and tweak as necessary.
See the Tomcat SSL how to/setup documentation for more detailed instructions.
Character Encoding (Optional)
Tomcat again uses iso-8859-1 per default to decode those GET parameters regardless of which encoding is set in the request even if it is set by an apps filter. To change this behavior you have to change connector configuration inside the server.xml of your Tomcat as described here. The attribute URIEncoding defines a fixed encoding the server uses for every request. What we want to use is the attribute useBodyEncodingForURI which tells the server to use the encoding defined for the body for the GET parameters too.Delete / Remove Default Tomcat Installed Webapps
Physically delete/remove the standard Tomcat webapp(s) which were auto installed. Even if the app's context is removed from/doesn't exist in the server.xml the app will still load/be available (the Host's autodeploy attribute doesn't control this either - it's only a default for war files placed in the root of the webapps directory). These apps are located in the [CATALINA_HOME]/webapps directory (or where ever specified in the server.xml file) and can include:- tomcat-docs
- ROOT
- jsp-examples
- servlets-examples
- webdav
If the manager and/or admin apps are to be kept then see how to secure Admin and Manager in Chapter 15 of the Apache Tomcat book already mentioned on this page. Otherwise these should also be removed from the [CATALINA_HOME]/server/webapps directory. These apps are in a directory named:
- admin
- manager
IBIS-Q CGI Tomcat Setup/Configuration
After many hours of searching/reading/trials and errors here's the only way I could get this work on Tomcat5.- Enable Tomcat's CGI Servlet Handler. Rename the tomcat/server/lib/servlets-cgi.renametojar to servlets-cgi.jar
- Enable CGI in tomcat/conf/web.xml. Uncomment/enter this servlet entry:
<servlet> <servlet-name>cgi</servlet-name> <servlet-class>org.apache.catalina.servlets. CGIServlet</servlet-class > <init-param> <param-name>debug</param-name> <param-value>255</param-value> </init-param> <init-param> <param-name>cgiPathPrefix</param-name> <param-value>cgi-bin</param-value> </init-param> <init-param> <param-name>executable</param-name> <param-value> d:/tomcat/webapps/ibisq/cgi-bin/hi_iq_func.exe </param-value> </init-param> <load-on-startup>10</load-on-startup> </servlet> <servlet-mapping> <servlet-name>cgi</servlet-name> <url-pattern>/cgi-bin/*</url-pattern> </servlet-mapping>
NOTES:- These entries are also able to be made in the ibisph-view web.xml file.
- You can have multiple cgi servlet entries as long as they are named differently (and of course you'd want different url mappings...).
- debug = 0 is minimal info. 255 allows a page to be returned when testing ibisq urls directly. This page shows all the request info etc.
- giPathPrefix is critical. I tried many settings here and could only get it to work as set.
- executable is required. If this entry is not here then it assumes perl. Much time was spent on this setting as well. Tried putting the cgi exe in the path (e.g. tomcat/bin). It worked there as long as there was another copy in the webapps/ibisq/cgi-bin directory. Never could figure this out. The easiest way was simply to put in the full explicit path to the exe.
- Mapping didn't work with /ibisq/cgi-bin but would only work with /cgi-bin. Again I'm not sure why/how this works because it doesn't seem like it would considering the url needed.
- Create an IBISQ context in the tomcat/conf/server.xmlEven though this is not a standard web app (tomcat complains about it) this is still required and doesn't work without it.
- Update the IBISQ URL located in the webapps/ibisph-view/deployment_specific.propertieshttp://localhost:8080/ibisq/cgi-bin/hi_iq_func.exeNOTES:
- The context needs to match and the ".exe" is required to work - at least on windows.
- This is confusing since the cgi servlet mapping should only catch for root /cgi-bin requests but that's how it works. Tried different mappings all unsuccessfully.
Test URLS
Note: favorite bookmarks are stored in the user's area under my favorites (for IE) and typically in C:\Documents and Settings\username\Application Data\Mozilla\Firefox\Profiles\default.7pi\bookmarks.html for NS/FF.LOCAL / DEVELOPMENT MACHINE:
General Tomcat
- Tomcat's Index page (needs ROOT webapp)
- Manager App's List Command
- Install View App via Manager App
- Remove View App via Manager App
Local View System (assuming the app is the default app, if not add the appropriate app context path)
- Root Only - Tests web.xml welcome page list
- /index.html - Tests redirection to home/welcome.html
- Application Log
- System Information JSP - This proves that the app is installed and displays system information about: Java, Servlet, OS, XML/Xalan, HTTP request).
- HTTP Test/Information JSP - Displays info about the HTTP request and allows for the testing of GZIP responses.
- HTTP Error JSP - Bad page test - 404 error
- MVC Error JSP - Controller/view test
- MVC Error JSP - Malformed XSLT - 500 error
- To test MVC error that crashes the request/response, change the home/page.xslt to be malformed and try the Welcome Page
- Indicator Set - Proof of Concept Test
- Library Index
Other Links:
BATIK 1.5 & 1.6 - JARs
TO WORK ON LINUX: export JAVA_OPTS='-Djava.awt.headless=true' need Java 1.4.1+ for this to work.JARS NEEDED (for transcoding):
- batik-awt-util.jar
- batik-bridge.jar
- batik-css.jar
- batik-dom.jar
- batik-ext.jar
- batik-gvt.jar
- batik-parser.jar
- batik-script.jar
- batik-svg-dom.jar
- batik-transcoder.jar
- batik-util.jar
- batik-xml.jar
NOT NEEDED:
- svg-gen
- swing
- extensions
- gui-util
Security
JAAS Security == to Spring/ACEGILinux Symbolic Links
There are several ways to locate the webapps to another spot rather than the default [CATALINA_HOME]/webapps dir. They include setting the value in the server.xml file, standard Linux symbolic links, and the context configuration as outlined below:<Context path="/myApp" docBase="myApp" debug="0"> <Resources className="org.apache.naming.resources.FileDirContext" allowLinking="true" /> </Context>With the default catalina.policy, this still won't work if your jar is outside of the web-app, and you are running "-security". In this case you also need to edit catalina.policy to grant rights to the file.
URLS / Links
- Jarkarta Tomcat website
- LDAP Auth
- Servlet Alians and URL mapping
NOTE ABOUT APP SERVLET MAPPING (web.xml): You can have a blank servlet alias but then everything will be funneled through that servlet. So all requests for jsps javascripts, css, etc. would all hit that servlet and not be served up as web content. - jGuru: Tomcat FAQ Home Page