macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Installing Tomcat on Mac OS X
Pages: 1, 2

The installer will ask you where you wish to install Tomcat. Just type in /Library/Tomcat/jwsdp-1_0-ea2 and click on the next button. The installation will begin. This takes a while, so go get a cuppa tea, and while waiting for the installer to run, do the following:



In /Library/StartupItems make a folder called Tomcat.

Screen shot.

In that folder you will create two files, the first, an executable shell script called Tomcat, and the second a property list called StartupParameters.plist. Both are simple text files.

  • Tomcat shell script:

    	#!/bin/sh
    	
    	##
    	# Start Tomcat
    	##
    	
    	. /etc/rc.common
    	
    	ConsoleMessage "Starting the Java WebServices framework"
    	
    	export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
    	export CATALINA_HOME="/Library/Tomcat/Home"
    	export TOMCAT_HOME="/Library/Tomcat/Home"
    	export JWSDP_HOME="/Library/Tomcat/Home"
    	
    	sh ${TOMCAT_HOME}/bin/startup.sh
  • StartupParameters.plist:

    	<?xml version="1.0" encoding="UTF-8"?>
    	<!DOCTYPE plist SYSTEM
           "file://localhost/System/Library/DTDs/PropertyList.dtd">
    	<plist version="0.9">
    	<dict>
    		<key>Description</key>
    		<string>Tomcat Servlet and JSP Server</string>
    		<key>Messages</key>
    		<dict>
    			<key>start</key>
    			<string>Starting Tomcat Server</string>
    			<key>stop</key>
    			<string>Stopping Tomcat Server</string>
    		</dict>
    		<key>OrderPreference</key>
    		<string>None</string>
    		<key>Provides</key>
    		<array>
    			<string>Tomcat</string>
    		</array>
    		<key>Requires</key>
    		<array>
    			<string>Resolver</string>
    		</array>
    	</dict>
    	</plist>

You can either use a text editor to create the .plist file, or Apple's PropertyList editor.

Make sure the Tomcat script you just added is executable.

chmod 755 Tomcat

Screen shot.

When the Tomcat installer is complete you should see the jwsdp-1_0-ea2 folder in your /Library/Tomcat folder.

Make a soft link to that folder from an alias called Home.

ln -s jwsdp-1_0-ea2 Home

Your TOMCAT_HOME is now always going to be /Library/Tomcat/Home.

If you wish to install other versions of Tomcat, put them in /Library/Tomcat and remake the soft link to Home. This way you don't need to change any other settings.

So give it a go.

cd /Library/StartupItems/Tomcat and type:

./Tomcat to run the Tomcat script.

You should see the following as Tomcat's startup script launches.

Using CATALINA_BASE: /Library/Tomcat/Home
Using CATALINA_HOME: /Library/Tomcat/Home
Using CATALINA_TMPDIR: /Library/Tomcat/Home
Using JAVA_HOME: /System/Library/Frameworks/JavaVM/Versions/1.3.1/Home

Now try to go to http://localhost:8080 using your Web browser.

You should see the Web Services Developer Pack EA2 screen. That's it. You have installed the Web Services Developer Pack. As a final test, restart your Mac. If everything worked properly, you should see "Starting Tomcat Server" appear in your startup window. Let the Mac sit there without logging in.

Now, using a browser on your other Mac (You do have another Mac don't you?) you should be able to go to http://10.0.1.xx:8080 and get the Web services page to open.

Congratulations, you now have a Tomcat installed that boots at startup and runs without requiring a user to log in.

Have a play with the examples and then, when you're feeling up to it, you can start writing your own Web services, servlets, and JSP pages.

Dave Sag is a skilled Object Modeler and Software Designer, using Java as well as other programming environments.


Return to the Mac DevCenter.