Friday, January 21, 2011

Setting Up Tomcat and Eclipse in Ubuntu Tutorial

This had me scratching my head for several days, but I finally put all the pieces together. If you want to get around to building some JSP stuff in Tomcat using Eclipse on Ubuntu (or some other Linux) you might run into some problems like I did and just complete a simple Hello World tutorial. Here's the problems and the solutions.

Problem: You don't have an option to create a new "Dynamic Web Project"
Cause: You don't have the Web Tools Platform installed.
Solution: Download WTP.  If you already have Eclipse you can update installation here.

Problem: You are getting any slurry of errors about permissions or can't write or can't find or can't configure errors. They are all varied and confusing and difficult to google. So you probably won't find this page by looking for them.
Cause: You are using the default Tomcat installation from apt. This saves you from worrying about the installation, but it isn't setup the way Eclipse wants you to.
Solution: Run the commands found here. I've archived them incase the forum ever dies or changes drastically.

sudo apt-get install tomcat6
cd /usr/share/tomcat6
sudo ln -s /var/lib/tomcat6/conf conf
sudo ln -s /etc/tomcat6/policy.d/03catalina.policy conf/catalina.policy
sudo ln -s /var/log/tomcat6 log
sudo chmod -R 777 /usr/share/tomcat6/conf

Problem: You get an error about port 8005 and 8080 already in use.
Cause: Tomcat is already running on those ports so they are of course in use.
Solution: Tell Eclipse to start it's Tomcat on a different port. Use the directions found here. I've archived the text incase the page ever dies or changes drastically.

Click on servers tab in eclipse and then double click on the server listed there
Then when the config page opens change the port by clicking on the numbers and typing over them

Problem: You are getting weird Java errors about objects not found or classes or something.
Cause: The Hello World you are attempting to run is way over your head.
Solution: Try something simpler to make sure your Tomcat and Eclipse setup is working properly.  The example from IBM is old but simple.  I'm not going to archive it for you.

No comments:

Post a Comment