Configuring tomcat for running from read-only device (aka cdrom)

Hola amiguetes, este es mi primer post «técnico», y por lo tanto va a ir en inglés, para poder acercarlo a un mayor público. So here I switch the default language.

In captiva we had to prepare a runnable distribution of a Jakarta Tomcat server, but on a cd-rom. You may think it’s a trivial task: copy the tomcat and JDK directories to the cdrom and done. But no, it’s not so easy.

The JDK can be run from read-only media without problems, but there are several reasons that prevent us from running tomcat from cdrom directly. The system tries to log many events, use the filesystem to persist the sessions, and creates a temporary workspace for JSP compilation. I’ll explain how to solve each of these issues, but first let’s prepare all our stuff.

Required stuff
– Tomcat 5.5.4 (binary distribution)
– Java Developer Kit 5.0 (or 1.5.0)

Configuring tomcat
First of all, we’ll remove all the entries that we don’t need from «server.xml». To avoid problems with file-writing, we’ll comment the «UserDatabase» entry in GlobalResources, and the later use of it as a Realm for the Server tag. If we want to use a Realm, it must be a JDBC realm or any other one hat doesn’t write to disk.
We should remove all FileLoggers in this «server.xml» file.
We will copy now our webapp in the webapp dir, and we will pre-compile all the JSP’s so we can avoid the temporary compilation directory. For this task we will use this ant script, found in Tomcat’s webpage. I f we follow the instructions listed there, we should get all our jsp’s compiled inside the «WEB-INF/classes» directory of the webapp, and a additional «generated_web.xml», that we should merge with the application’s «web.xml», so the JSP classes can get mapped as Servlets.
There’s one last step before we can toast all these directories: Avoid the Session Persistence. For this, we should add one «Manager» element inside the «Host» element of the webapps that are going to be on the cdrom. The base configuration for this element is:

<Manager className=»org.apache.catalina.session.StandardManager» pathname=»»/>

In this way we prevent Tomcat from trying to write session information to any path.
Finally, we should remove all the default webapps that come with the normal distro, from the webapps dir, and from the «conf/Catalina» dir.

Burn it baby!
Now we can copy all our data to the cdrom. We’ll create this path distribution:
${cdrom_path}/jdk-1.5.0
${cdrom_path}/tomcat-5.5.4
In the «jdk» dir, we’ll copy the complete JDK. With the version 5.5 of tomcat we could use the JRE instead of the JDK, but I haven’t tried.
In the tomcat dir, we’ll copy the constents of the tomcat home dir, including all the directories, with our modified files. We can remove the JSP pages cause they’re compiled now, and the temporary src directory for them.

Now, we can add a pair of bat files or sh scripts for autorunning the server. I have these two in the ${cdrom_path} directory, ie, th root of the cd:

start.bat
set JAVA_HOME=jdk-1.5.0
set CATALINA_HOME=tomcat-5.5.4
%CATALINA_HOME%\bin\startup.bat

stop.bat
set JAVA_HOME=jdk-1.5.0
set CATALINA_HOME=tomcat-5.5.4
%CATALINA_HOME%\bin\shutdown.bat

This is the end for now. If you encounter any error don’t hesitate on telling me!

2 comentarios en “Configuring tomcat for running from read-only device (aka cdrom)

  1. As it is possible to see you’ll find some clear advantages as well as disadvantages associated with getting one with the lasting automobile financing that can be found today Super Real if you might be unfamiliar with what that loan modification is, or the basic making home affordable guidelines, brush high on those before reading further.

Deja un comentario