Install Tomcat with Eclipse

Howto install Tomcat with Eclipse IDE on MacOS X.
What we need:
Tomcat
Eclipse JEE
1. Extract Eclipse into your Applicationfolder and Tomcat to your prefered location for example into your home directory.
2. change into the apache-tomcat-6.0.20/bin directory and make all .sh files executeable
cd <pathtoyourtomcat>/apache-tomcat-6.0.20/bin
chmod +x *.sh
3. test if it starts
./setclasspath.sh
./startup.sh
something like this should appear:
./startup.sh
Using CATALINA_BASE:   apache-tomcat-6.0.20
Using CATALINA_HOME:   apache-tomcat-6.0.20
Using CATALINA_TMPDIR: apache-tomcat-6.0.20/temp
Using JRE_HOME:       /System/Library/Frameworks/JavaVM.framework/Home
4. Test you tomcat installation via your Browser
http://localhost:8080/
if everything works like expected shut the tomcat instance down
./shutdown.sh
5. Now we add Tomcat to our Eclipse environment






Double click on the server and select “Use Tomcat installation (take control of Tomcat installation)”:
Set tomcat preference to use installation directory parameters
Set tomcat preference to use installation directory parameters


6. Modify the tomcat-users.xml file located in /<pathtotomcat>/apache-tomcat-6.0.20/conf directory and add:
<role rolename=”admin”/>
<role rolename=”manager”/>
<user username=”user” password=”password” roles=”admin,manager”/>
with your username and password for administration.

Comments 18

  1. David wrote: Thank you for the tutorial, I was wondering if you knew why when I am trying to find out why when I install Tomcat 6 or 7, and Eclipse EE (Helios) on my OS X 10.6 nothing seems to happen. Tomcat starts just fine from the command line. But in Eclipse, the server appears to start but in fact hitting the url gives me a Apache 404. Here is some of the console log:
    INFO: Starting service Catalina
    May 4, 2011 8:57:12 PM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
    May 4, 2011 8:57:12 PM org.apache.coyote.AbstractProtocolHandler start
    INFO: Starting ProtocolHandler [\"http-bio-8080\"]
    May 4, 2011 8:57:12 PM org.apache.coyote.AbstractProtocolHandler start
    INFO: Starting ProtocolHandler [\"ajp-bio-8009\"]
    May 4, 2011 8:57:12 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 280 ms
    Posted 05 May 2011 at 4:55 am
  2. Raymond wrote: @David,
    I have the exact same problem! So frustrating. Have you figured any thing out?? Can’t seem to find any solutions!
    Posted 19 May 2011 at 9:59 pm
  3. Banym wrote: I can reproduce the issue. It looks like it’s because of the different location parameters used by Eclipse to start the tomcat instance. Did you try to deploy a web application from you Eclipse?
    Posted 22 May 2011 at 12:14 pm
  4. Danny wrote: I have the same problem as well, anyone with a solution to this?
    Posted 29 Jun 2011 at 7:14 am
  5. Banym wrote: Go to server tab and double click on your tomcat server configuration and select: “Use Tomcat installation (take control of Tomcat installation)”
    I updated the tutorial you should see it in a screenshot above.
    Regards,
    Dominik
    Posted 29 Jun 2011 at 7:25 pm
  6. Adam wrote: Thank you SO much for pointing out the “Use Tomcat installation (take control of Tomcat installation)” setting! I was going crazy with this. Now I can truly control Tomcat and deploy properly from within Eclipse.
    Posted 06 Jul 2011 at 4:33 am
  7. thiti wrote: Thank .. SO MUCH !!
    Posted 25 Jul 2011 at 5:43 pm
  8. noemail@gmail.com wrote: Thank you! I was receiving “could not load the Tomcat server configuration at /Servers/Tomcat v7.0 Server at localhost-config.” until I deleted my tomcat server and used your setup.
    Posted 10 Aug 2011 at 6:03 pm
  9. peter steiner wrote: “Go to server tab and double click on your tomcat server configuration and select: “Use Tomcat installation (take control of Tomcat installation)”
    I updated the tutorial you should see it in a screenshot above.
    Regards,
    Dominik”
    Thanks, saved me some time and confusion! Only screener I can wee in the tutorial though!
    I deleted server and created a new one, then I could change the server locations property.
    /Peter
    Posted 28 Aug 2011 at 11:37 am
  10. Vitalii wrote: Hi!
    I’m new to Mac OS and need to use one of IDE with tomcat to create some servlets. I’ve installed Eclipse for EE Developers and tomcat 6.0.33 and have problems with this:
    ./setclasspath.sh
    The BASEDIR environment variable is not defined
    This environment variable is needed to run this program
    what does it mean and what should I do, explain me please.
    Thanx a lot!
    Posted 15 Oct 2011 at 10:34 am
  11. Banym wrote: Hi Vitalli,
    how do you want to use the tomcat? Do you want to run it out of your IDE and deploy your servlets directly to it?
    When did you get this message? When you run the script by your own?
    Regards,
    Dominik
    Posted 15 Oct 2011 at 10:49 am
  12. Kirsty wrote: @Vitalii and @Banym,
    I am having the same issue on Mac OSX.
    I want to run tomcat through Eclipse using JEE. I’m fairly new to servlets/tomcat so don’t really know how else to explain. When I try to view localhost:8080 in the browser (after typing what Vitalii wrote and getting the same message, and then typing ./startup.sh and getting
    “Using CATALINA_BASE: /Users/kirsty/Documents/apache-tomcat-6.0.33
    Using CATALINA_HOME: /Users/kirsty/Documents/apache-tomcat-6.0.33
    Using CATALINA_TMPDIR: /Users/kirsty/Documents/apache-tomcat-6.0.33/temp
    Using JRE_HOME: /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
    Using CLASSPATH: /Users/kirsty/Documents/apache-tomcat-6.0.33/bin/bootstrap.jar
    touch: /Users/kirsty/Documents/apache-tomcat-6.0.33/logs/catalina.out: No such file or directory
    /Users/kirsty/Documents/apache-tomcat-6.0.33/bin/catalina.sh: line 375: /Users/kirsty/Documents/apache-tomcat-6.0.33/logs/catalina.out: No such file or directory”)
    I am not seeing anything but an error message in my browser.
    Posted 03 Nov 2011 at 2:03 am
  13. Banym wrote: First you should try to get an working tomcat on you machine. Try to download the latest version you want to use and run it via the startup.sh script from a terminal.
    For me there is a line in you post you should have a closer look: touch: /Users/kirsty/Documents/apache-tomcat-6.0.33/logs/catalina.out: No such file or directory
    The startup procedure should create this file. Are you allowed to write in this folder?
    And after your tomcat is working from a terminal you should make the connection between your IDE and the tomcat server.
    Regards,
    Dominik
    Posted 07 Nov 2011 at 6:13 pm
  14. David wrote: I also ran into the BASEDIR problem Vitalli did. I’m using 6.0.33 on OS X Lion (10.7.2). If you look at the content of setclasspth.sh it appears to use BASEDIR to construct paths relative to your Tomcat install directory, for the script checks a path to itself…
    if [ ! -x "$BASEDIR"/bin/setclasspath.sh ]; then
    To work around the issue, I simply set BASEPATH to my tomcat directory before running the other two steps. I put Tomcat in my home directory so I did this:
    export BASEDIR=”/Users/my_user_name/apache-tomcat-6.0.33″
    Then ran the setclasspath.sh and startup.sh scripts. It worked.
    Following the rest of the instructions, I’m also able to start and stop the server with Eclipse.
    But, I do get a 404 when visiting http://localhost:8080/ when I start the sever with Eclipse. I think this is normal. When I hit a URL for a web app I’m working on in Eclipse, ex: http://localhost:8080/MyBasicWebApp/ it works.
    Thank you Banym for these excellent instructions!
    Cheers,
    David
    Posted 03 Dec 2011 at 8:58 pm
  15. Sanjee wrote: I followed strictly above and able to configure tomcat in my eclipse and working fine ,but multiple time i made changes my java class then server will crashed and some times it will be out memory permgent exception,how I will resolve these issues.
    Please assist me asap.
    Posted 24 Jan 2012 at 5:53 pm
  16. Banym wrote: Hello Sanjee,
    check your max memory values you are using for your java, eclise and tomcat. There you can increase the max memory. If you change your classes you maybe need to redeploy your application that’s maybe the cause of the crash if you have tomcat up and running while you’re changing the code.
    Regards,
    Dominik
    Posted 25 Jan 2012 at 11:44 am
  17. Antonio wrote: Thanks a lot! =D
    Posted 10 Mar 2012 at 1:47 pm
  18. Jim Geldemrann wrote: Please add to the – Double click on the server and select “Use Tomcat installation (take control of Tomcat installation)”:
    “Set deploy path to the default value (current set)” – If the Tomcat main screen does not appear that this path will need to be set to theTomcat’s web apps folder.
    Posted 15 Apr 2012 at 3:35 pm

Comments

Popular posts from this blog

How to draw an overlay on a SurfaceView used by Camera on Android?

Android TCP Connection Chat application

Create EditText with dropdown in android