AddThis Social Bookmark Button

Listen Print Discuss

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.


  • Opening Up for All to Run
    2004-02-21 11:14:47  woodgnome [Reply | View]

    Great article - I have to say "as usual" for the O'Reilly Network.

    Having got Tomcat running using my administrator permissions, what permissions to I need to change for the /Library/Tomcat and /Library/StartupItems/Tomcat (if at all) so that Tomcat will be there for everyone?

    I've seen someone else note that Console complains on startup that it needs root permission - is there a way (permissions, re-direction etc.) to avoid this?

    Thanks


    BTW My interest in Tomcat is as a pre-requisite to getting Memento (www.memento.org) - an information management tool - running.
    • Opening Up for All to Run
      2005-03-21 21:13:37  MDW [Reply | View]

      Did you ever get an answer for this? I am also unable to get Tomcat to start at boot time. The permissions seem right.
  • Nice easy install
    2004-01-29 19:23:29  javaravyn [Reply | View]

    I have been trying unsuccessfully to install Tomcat for a while now.

    This was short, to the point, and easy to follow. The only problem I had was creating directories in the StartupItems folder. I have mysql installed and it might have been weirding it out.

    Went into terminal and used sudo to mkdir's and it was fine. Same thing with the tomcat and plist. I created them elsewhere and then moved it in.

    Thanks for the help!
    M@
  • No such directory "/Library/Tomcat/Home/"
    2004-01-01 14:30:28  anonymous2 [Reply | View]

    /Library/Tomcat/Home/bin/startup.sh: /Library/Tomcat/Home/bin/startup.sh: No such file or directory
    • No such directory "/Library/Tomcat/Home/"
      2005-08-08 13:21:41  illovich [Reply | View]

      I'm having this problem as well. I think the problem stems from the fact that this article is for an older version of Tomcat.

      basically, the reason that this error message is happening for me is that there is no /Library/Tomcat/Home/bin/ dir and thus no /Library/Tomcat/Home/bin/startup.sh. (I made the link correctly, and it correctly resolves to /Library/Tomcat/jwsdp-1_0-ea2)

      It may be as someone else mentioned that Tomcat no longer comes with the Web Services pack from Sun, but I haven't figured it out yet.
    • No such directory "/Library/Tomcat/Home/"
      2004-07-09 14:17:09  feltoon [Reply | View]

      I got this too -- anyone know how to fix?
      • No such directory "/Library/Tomcat/Home/"
        2008-02-19 11:48:54  djincheg [Reply | View]

        Type "~" before the first "/". This gives the starting point as the home directory. So it will go as ~/Library/Tomcat/Home . This should work for you.
  • Great guide
    2003-11-11 11:41:13  anonymous2 [Reply | View]

    Well done. Quick, simple, informative. Thanks for the help.
  • 10.3
    2003-11-02 13:01:04  anonymous2 [Reply | View]

    Just did this and it worked on 10.3
    • 10.3
      2003-11-11 07:18:34  anonymous2 [Reply | View]

      When I use the ./jwsdp-1_0-ea2-unix.sh command my terminal freezes at "initializing InstallShield Wizard"

      This is the total out put :

      Using /var/tmp as temporary directory...
      Searching for Java(TM) 2 Platform, Standard Edition...
      Initializing InstallShield Wizard...

      What did I do wrong?

      • 10.3
        2003-11-21 04:08:17  anonymous2 [Reply | View]

        See the following link - it fixed the same problem I was having:
        http://developer.apple.com/technotes/tn2002/tn2099.html
  • Upgraded to Java 1.4.1 now tomcat doesn't work
    2003-10-16 14:32:08  anonymous2 [Reply | View]

    I'm running Tomcat 3.3 on Apple XServe. On Monday, I automatically installed Java 1.4.1 and Mac OSX Server 10.2.8 Update since Software Update prompted me to do it. Ever since then, my website is not visible. The error message says the server couldn't understand the request or there is some misconfiguration. When I tried to look at the jasper or servlet log, it was empty. When I restart Tomcat via command line, there's a message saying that jsaper file was not readable. I uncommented the code referening jdk 1.2 i nthe server.xml file thinking that maybe the jdk was upgraded to 1.4 bu tthat didn't do anything. Then I changed the JAVA_HOME classpath to /System/Frameworks/JavaVM/.../Versions/1.3.1 but that also did not do anything. Does anybody know why upgrading to Java 1.4.1 would affect Tomcat? Does it upgrade the JSP and Servlet spec too? HELP?!
    • Upgraded to Java 1.4.1 now tomcat doesn't work
      2005-08-08 13:36:26  illovich [Reply | View]

      This may be part of your problem:

      http://developer.apple.com/qa/qa2001/qa1025.html

      Q: How do I re-enable JBoss and Tomcat to work after installing the Java 1.4.2 Update?

      A: The run.conf script for starting the JBoss server has a hardcoded reference to the 1.4.1 JVM. Installing the Java 1.4.2 Update removes the Java 1.4.1 installation, and JBoss/Tomcat services will not be able to start.

      To re-enable JBoss and Tomcat the reference below should be changed in the file: /Library/JBoss/3.2/bin/run.conf

      from:
      JAVA=/System/Library/Frameworks/JavaVM.framework/Versions/1.4.1/Home/bin/java

      to:
      JAVA=/usr/bin/java
  • Works with localhost but not with IP address
    2003-09-25 22:18:53  anonymous2 [Reply | View]

    After following the great instruction here, I finally got it to work (98%). However, I can only test the page through http://localhost:8080 but not through http://192.168.0.10 from another computer, or on the server itself. What is going on? Any advisces would be appreciated. - w
    • Works with localhost but not with IP address
      2003-11-02 12:54:59  anonymous2 [Reply | View]

      Is your firewall on for 8080? Sytem Prefs:Sharing:Firewall.

      You probably want it on, so you may need to add 8080 as a allowed port.
  • Great help
    2003-07-14 19:48:29  anonymous2 [Reply | View]

    Thanks. Really a nice instruction
  • Tomcat installer
    2003-06-14 02:18:17  anonymous2 [Reply | View]

    Can be found at: http://www.serverlogistics.com/tomcat.php
  • Problem with running ./Tomcat
    2003-05-06 13:32:54  anonymous2 [Reply | View]

    The install goes well and the files are correctly placed.

    However, I get this message every time I type in ./Tomcat to get it running:

    Starting the Java WebServices framework
    /Library/Tomcat/Home/bin/startup.sh: /Library/Tomcat/Home/bin/startup.sh: Not a directory

    Any ideas?
  • Problems on 10.2.4 with JDK 1.4.1
    2003-04-18 18:01:55  anonymous2 [Reply | View]

    I am running OS X 10.2.4 on my powerbook and it comes with JDK 1.4.1. I had followed this article to install JWSDP kit and tutorial. But I am running into problems starting and stopping the Tomcat server. The funny thing is when I start it up it does output some java exceptions complaining that "connection refused" in the log files. But when I try to connect to the localhost at 8080 it does bring up the JWSDP page. But when I try to stop it or deploy a servlet to it using Ant tool I get the "connection refused" exception.

    I am totally confused. Then I read about the package on Aron Faby's site and downloaded that and followed the instructions. But no success. I get the same error when I try to stop the tomcat server.

    Can somebody help me? I am not sure if the problem is with the OS X version or JDK version 1.41 or Tomcat version 4.1.

    Thanks
    • Problems on 10.2.4 with JDK 1.4.1
      2003-04-19 00:12:15  anonymous2 [Reply | View]

      I've upgraded to java 1.4 too and am now running Tomcat 4.1.24LE - works fine except that to get XML stuff going properly I had to copy my xercesImpl.jar and xmlAPIs.jar files into tomcat/common/endorsed.

      It would help you'd posted the exceptions you get. I've had no trouble and run 5 different tomcats on my tibook depending on the project I am working on. Free free to email me directly (get my email address of the week off http://www.davesag.com) and I'll try and help. cheers davesag.
      • Problems on 10.2.4 with JDK 1.4.1
        2003-07-13 01:24:33  anonymous2 [Reply | View]

        I am running on 10.2.6, and I also recieve java exceptions when I try to start the server- I ran a search and found four xercesImpl.jar files and no xmlAPIs.jar files- What should I do to get running? Also- startup won't write exceptions to log file unless I use sudo, which I see a lot of people say is unnecessary- Thanks
  • OSX 10.2 install
    2003-03-27 21:30:34  anonymous2 [Reply | View]

    instructions worked well (with minor diff's) for 10.2...

    couple of Q's tho (new to UNIX):
    installation indicated that I should either:

    copy files in /Library/Tomcat/jwsdp-1_1/jaxp-1.2.2/lib/endorsed
    to
    <JAVA_HOME>/jre/lib/endorsed
    -or-
    set the java.endorsed.dirs system property to
    /Library/Tomcat/jwsdp-1_1/jaxp-1.2.2/lib/endorsed

    if I want to do the later, I'm assuming that I'm just using the set command in terminal in the following manner:

    set java.endorsed.dirs=/Library/Tomcat/jwsdp-1_1/jaxp-1.2.2/lib/endorsed

    anyone know if that would be right?!!

    2nd Q:
    creating a startupitems tomcat folder for the scripts not possible cause I think permissions are not allowing 9new folder not active in finder for startupitems...
    I'm assuming that all I need to do is change this with chmod command and add folder...??

    thanks much
    sreidy6@attbi.com
    • OSX 10.2 install
      2003-05-01 12:58:57  anonymous2 [Reply | View]


      you need to add the line
      java.endorsed.dirs=/Library/Tomcat/jwsdp-1.1/jaxp-1.2.2/lib/endorsed
      in
      /Library/Tomcat/jwsdp-1.1/conf/jwsdp.properties

      (note it's jwsdp-1.1 not jwsdp-1_1 )

      See
      http://java.sun.com/webservices/docs/1.1/ReleaseNotes.html
      for more info

      2nd Question

      you're probably logged in as non root user
      try putting sudo in front of the commands like mkdir etc

  • Bash or tcsh
    2003-03-13 20:21:06  anonymous2 [Reply | View]

    Export is a command normally found in the bash shell. Is this script written for bash?
  • localhost vs 127.0.0.1
    2003-02-17 10:23:50  anonymous2 [Reply | View]

    hi, sorry for the anon post here but i can't remember my password :-) I'll try to answer your questions.

    firstly are you on a network? if not then localhost won't resolve to anything. also i note you used Localhost - should be localhost. lowercase 'l'.

    next what you got when you go to 127.0.0.1:8080 was correct, my article specified sun's web services kit's build of tomcat cos that's what i was using at the time. in theory the same proceedure will work with any version of tomcat, but you'll need to edit the $TOMCAT_HOME/conf/tomcat-users.xml file to put in your own roles and users.

    also I note you claim to have done all this logged in as root! that's not such a good idea. you should just be logged in as yourself.

    the easy way to do all this now (it is almost a year since i wrote that article) is to use Aaron farby's prepackaged installers at http://www.aaronfaby.com/tomcat.php

    cheers


    dave

  • Installation failed.
    2003-02-17 09:59:37  anonymous2 [Reply | View]

    Installation failed. I followed the instructions verbatim, logged in as root. My second problem is that http://Localhost:8080 was not found but http://127.0.0.1:8080 worked (did not get Tomcat page but a Java Developer page with the utilities for Tomcat, none of which meant anything to me. When I logged off and back on I could no longer get to even that page. I am hopelessly lost. Does anyone want to offer help? thanks.
  • Command Not Found running TOMCAT script
    2003-01-12 18:52:04  anonymous2 [Reply | View]

    I'm getting a Command Not Found error when running the ./Tomcat command from the shell and at boot.

    I created the file using JEdit for OSX using Unix line breaks - still the same problem.

    Any ideas???
    • Forgot: Command Not Found running TOMCAT script
      2003-01-31 01:40:03  orangehead911 [Reply | View]

      To test (start) the service, type; ./Tomcat start

      \t
    • Command Not Found running TOMCAT script
      2003-01-31 01:13:50  orangehead911 [Reply | View]

      Try this script for the Tomcat script;

      #!/bin/sh

      ##
      # Tomcat
      ##

      . /etc/rc.common

      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"


      StartService ()
      {
      # if ! pid=$(GetPID p4d); then
      ConsoleMessage "Starting The Java WebServices Framework"
      ${TOMCAT_HOME}/bin/startup.sh
      # fi
      }

      StopService ()
      {
      # if pid=$(GetPID p4d); then
      ConsoleMessage "Stopping The Java WebServices Framework"
      ${TOMCAT_HOME}/bin/shutdown.sh
      # else
      # echo "The Java WebServices Framework is not running."
      # fi
      }

      RestartService ()
      {
      # if pid=$(GetPID p4d); then
      ConsoleMessage "Restarting The Java WebServices Framework"
      StopService
      StartService
      # else
      # StartService
      # fi
      }

      RunService "$1"
  • Strange Error
    2003-01-08 20:36:23  anonymous2 [Reply | View]

    I too was following directions to a tee.

    When I ran the installer (in OSX.2.3) I got:
    "Exception in thread "main" java.lang.NoClassDefFoundError: JWSDP"


    I'm stuck, and I'd really like to get ColdFusion Developer for OSX up and running now. Email comments to icranford @mac.com.

    Thank you !!!
  • Cocoon - Help?
    2002-12-21 05:01:58  anonymous2 [Reply | View]

    I installed JWSDP and it works fine. Now I installed Cocoon 2.0.4 , copying the file cocoon.war in Library/Tomcat/Home/webapps. TheCocoon-examples work, but where to save my own examples or what to change else.

    Thank you for help
  • startup/shutdown not working independently
    2002-11-24 13:45:58  anonymous2 [Reply | View]

    Installation and startup at boot is working. However, during development, eg when copying servlets into the WEB-INF/classes subdirectory, it is necessary to manually shutdown and startup Tomcat for Tomcat to recognize the new "improved" class files.

    I created two scripts based on the script in this article. Specifically:

    -----------------------
    #!/bin/sh
    ##
    # Start Tomcat
    ##
    . /etc/rc.common
    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
    ----------------------------------

    After executing this script, Tomcat is still inactive (the shutdown script is the same, substituting "shutdown.sh" for "startup.sh" above.

    Why does the above not work? What needs to be done to get this routine to work?
  • It did not work for me!! Any help
    2002-11-19 03:46:43  anonymous2 [Reply | View]

    I went throught the whole installation carefully and at the very end this is what I got

    [Brian-Sherwoods-Computer:/Library/StartupItems/Tomcat] sherwood% ./Tomcat
    you must be root to run ConsoleMessage
    [Brian-Sherwoods-Computer:/Library/StartupItems/Tomcat] sherwood% ssh -l root localhost
    root@localhost's password:
    Last login: Tue Nov 19 05:35:03 2002 from localhost
    Welcome to Darwin!
    [Brian-Sherwoods-Computer:~] root# cd /Library/StartupItems/Tomcat/
    [Brian-Sherwoods-Computer:/Library/StartupItems/Tomcat] root# ./Tomcat
    Starting the Java WebServices framework
    [Brian-Sherwoods-Computer:/Library/StartupItems/Tomcat] root#

    The Tomcat script doesn't do anything (http://localhost:8080 doesn't work)
    Can anyone help me out??
  • command not found
    2002-11-12 11:23:16  anonymous2 [Reply | View]

    okay...I followed the above article step by step..VERY carefully, as this is my first foray into OS X server type stuff.

    after installing tomcat, at the point you type "./tomcat" in your shell, all i get is "./Tomcat: Command not found."

    I have 10.2.2...any ideas?

    please help, i need this to work!
    • command not found
      2002-11-15 08:49:27  toby_j [Reply | View]

      I had this same problem (10.2.2 also), if you cd to the bin directory of the jwsdp and use the startup.sh you'll get it running. Not sure yet how to SOLVE the problem...

      Toby
      • command not found
        2002-11-28 08:04:58  jrmjr [Reply | View]

        I had same problem: my shell script had bad characters, because I used textEdit to create the file. Use vi (or BBEdit w/Unix line breaks as i did)...
  • Flubbed install...
    2002-10-31 03:31:37  anonymous2 [Reply | View]

    ...and can any kind soul tell me why I get this message when I try to ./tomcat?
    =
    [localhost:/library/startupitems/tomcat] root# ./tomcat
    = <caron>´´0: No such file or directoryhat/Home" e"/JavaVM.framework/Home
  • Does this work in OS X 10.2
    2002-09-10 10:55:42  anonymous2 [Reply | View]

    Has anyone tried/does this process work in 10.2?
    • Does this work in OS X 10.2
      2002-09-12 08:08:44  oliverspapa [Reply | View]

      I just followed the instructions and it seems to have worked fine. I am very new to all of this (I normally have a Web Master hadle all the configurations), but thought that I would give it a whirl. Some of the things do not match exactly to what the article says I ought to be seeing. However, I believe everything went smoothly.

      - Craig
      • Does this work in OS X 10.2
        2002-09-12 19:55:55  kehret [Reply | View]

        Thanks! I'll give it a shot...
  • Tomcat and Apache
    2002-08-12 23:09:45  yoichi [Reply | View]

    Tomcat 3.x (worked fine on PC/Linux/Mac OS 8)

    http://jakarta.apache.org/tomcat/tomcat-3.3-doc/tomcat-apache-howto.html

    Tomcat 4.x (haven't tried this)

    http://jakarta.apache.org/tomcat/tomcat-4.0-doc/config/ajp.html
  • Instal Tomcat in IDE
    2002-08-12 22:35:47  yoichi [Reply | View]

    Does anyone know how to install Tomcat inside Project Builder to develop Servlets so to be able to debug Servlets?

    Thanks,
    Yoichi

  • now with feeling....
    2002-08-06 10:37:25  markroyko [Reply | View]

    Ok, this is a great article, and far superior to the one posted by Apple. However, the next step is to connect this to the built-in Apache server, and Apple's directions on installing the corresponding module kind of...well, let's just say they're not as clear as the step-by-step listed here. Anyone have a clear explanation how make this talk to Apache, assuming you've used this tutorial exactly as described here?
  • tomcat and apache
    2002-07-17 15:12:50  pclancy [Reply | View]

    I really liked this article. It seemed to be much more OS X centric then others I've read. My only wish would be to go deeper into configuring tomcat. I'd really like more information on either Warp or AJP and how they integrate tomcat with Apache.
  • great article - any info on mod_jk?
    2002-06-29 21:31:15  billin [Reply | View]

    This is a fabulous article and couldn't be more timely, given my recent foray into JSP with Mac OS X. Even Apple's articles on integrating Tomcat with Mac OS X aren't as helpful, given that they assume inexplicably that you want to install Tomcat into /usr/local/ instead of /Library/.

    Now that I've got Tomcat happily installed on my machine, I was hoping to have Apache automatically hand off requests for JSP's and servlets to Tomcat. I've been told that a particular Apache module, mod_jk, is used for just such a thing - is that correct? If so, does anyone know of a tutorial on the web for compiling and installing the module on Mac OS X? I read somewhere that www.jspformacs.com had such information, but that URL doesn't seem to be valid anymore. Any others that people know about?

    Regards,
    Bill
    billin@jadeforest.com
  • Security of system files - chmod 777?
    2002-06-19 09:11:26  vkevlar [Reply | View]

    I would suggest not making the file both writable and executable by everyone. 775 is a more secure mode (root and group allowed), or, if you want to make sure only root can write the file (most secure mode), 755.
    I wouldn't recommend using chmod 777 to anyone as a matter of course, on a unix-based system such as MacOS X.