However, if you want to go off the paved paths, you’d better bring your boots.
My roots are in the MCP environment, so when I install new software, I like to install and run it under some usercode. Preferably non-privileged so I can’t accidently break anything else. But the Java environment relies on the POSIX file system with it’s concept of permanent directories. On the MCP system, permanent directories can only exist in the *DIR/= directory of a pack family. Although the Tomcat installation and running works fine under a usercode, deploying or redeploying web applications under usercode can be surprising, if not impossible. In a later blog I’ll cover my experiments with Tomcat under a usercode.
Tomcat comes from the Apache web site (http://tomcat.apache.org) as a zip file. The easiest way to install it, is by unzipping the file on a Windows PC and use a Windows share to an MCP pack to copy the unzipped Tomcat directory to the MCP system as something like *DIR/tomcat/=. The files will have the OWNER attribute set to the user of the Windows share. If this is not the Tomcat usercode, you’ll have to change the file OWNER attribute, e.g.:
WFL ALTER *DIR/TOMCAT/= (OWNER=”TOMCAT”)
Better not try to copy the files around using LIBRARY MAINTENANCE, this may result in things like “Missing Permanent Directory”.
I checked the Linux startup file (catalina.sh) to see what parameters and settings Tomcat needs to run and copied these arguments to a WFL. Here is the WFL I’m using to start Tomcat (my Tomcat is in *DIR/TOMCAT7 ON USER):
00000100BEGIN JOB WFL/START/TOMCAT;
00000200CLASS = 20;
00000300RUN *DIR/JRE6/BIN/JAVA (
00000400 " -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,"
00000900&" -classpath .:bin/bootstrap.jar:bin/tomcat-juli.jar"
In this WFL:
- Line 300 starts the Java Virtual Machine (JVM).
- Lines 400 and 500 make the JVM run in debug mode. This way you can connect the IDE to the running Tomcat and debug the application while it runs on the JProcessor. (How is that for debugging; the power of a Java IDE and the MCP SUMLOG to figure out what is going on!). Spaces are the argument separators in Java, so don’t put extra spaces in.
- Lines 600, 700, 800 and 1000 set JVM system properties. These properties can be accessed from the Java code and are used by Tomcat.
- Line 900 sets the classpath, the Bootstrap class searches the directories given in the classpath to load classes.
- Line 1100 and 1200 actually execute Tomcat’s Bootstrap class with a “start” parameter.
- Line 1300 tells the system that all relative paths are relative to this directory.
And this is the WFL I used to stop Tomcat:
00000100BEGIN JOB WFL/STOP/TOMCAT;
00000500RUN *DIR/JRE6/BIN/JAVA (
00000800 " -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
00001100&" -classpath .:bin/bootstrap.jar:bin/tomcat-juli.jar"
Basically it is the same WFL, only this time the argument to the Boostrap class is “stop”.
The only configuration change you really need to make, is in the tomcat-users.xml file. As the name suggests, it is an XML file and you at least need to have in there :
<user username=”manager” password=”secret” roles=”manager-gui”/>
This gives you a logon to the Tomcat Manager pages (with user = “manager” and password = “secret” in this example), from where you can deploy, start, stop and undeploy web applications. If web application’s pages need logons, these roles, users and passwords are specified in here as well.
Now, Tomcat can be started. Since nothing was changed in the server.xml file, Tomcat will use port 8080 to serve pages.
I like to use the “WAR file deploy” option of the Manager. It allows me to select a Web application ARchive (WAR file) on my local PC, upload it to the server, unpack it into the webapps directory and start the application.
I mostly use the Netbeans IDE for Java programming. In Netbeans I can program the HTML pages, JSPs, sevlets and supporting classes. I can also maintain the web.xml and context.xml files there. By doing a “Clean and Build” Netbeans creates a ready to deploy WAR file. Of course any Java IDE, like Eclipse, can do this.