How to configure Tomcat 6 in Ubuntu for Eclipse
If you are an Ubuntu user and a Java developer there’s a great chance that you’d want at some point to develop web applications using Eclipse and Tomcat. The easiest way to install Tomcat is by using the package manager:
sudo apt-get install tomcat6 tomcat6-*
Now configuring Eclipse to use the instance of Tomcat you previously installed should be straightforward. Unfortunately, because of the way Tomcat is packaged, after you install the container there are a few steps that should be followed in order to be able to add Tomcat 6 to your Eclipse’s servers list:
sudo ln -s /var/lib/tomcat6/conf /usr/share/tomcat6/conf sudo ln -s /etc/tomcat6/policy.d/03catalina.policy /usr/share/tomcat6/conf/catalina.policy sudo ln -s /var/log/tomcat6 /usr/share/tomcat6/log sudo chmod -R 777 /usr/share/tomcat6/conf
After all this is done you can start working on your projects as usual. Happy coding!
You might also like:
6 Comments
Leave a comment
Recent Posts
Projects that I support
Recent Comments
nope said:
yeah that was my first thought too, but: mount: warning: seems to be mounted read-write. too bad, would have been just perfect. more»Klaus Deiss said:
Dear Radu, I tried it on Ubuntu 10.0.4.2 and 10.0.4.3 with different kernel versions (amd64 server 2.6.32 kernel). No... more»scompo said:
Nope.. Now it’s not working again.. This printer it’s a real pain in the butt.. The other hp printer I had... more»Dmitrij said:
Thank you Peter and Patrice. Could you please post the updated script? more»hd_flash_pains said:
didn’t work for me more»








Been there, done that. But there’s more to it: switch from openjdk to sun jre (you can’t do remote debugging with openjdk, for some reason – it’s missing some remote debugging component), modify tomcat’s startup script to start the server with remote debugging enabled, then configure eclipse to connect to tomcat for remote debugging? Care to add instructions for this too? I can in theory retrace to some extent what I’ve been through, but I’m not that much of a writer to write it all down in a blog.
Eclipse can connect to Tomcat 6 for debugging purposes just by running your web application with the “Debug on Server” option.
It may be so when tomcat is installed locally – I never tried it. But if you want eclipse to connect to a tomcat located on a different host, you need to do a little more work. Until I did all these things, I was not able to connect eclipse running on Windows to a VM running tomcat on kubuntu lucid.
First thing to do, if you haven’t done so already, is switch from openjdk to sun’s jdk on the server. It’s not that I don’t like openjdk, it just doesn’t provide all components needed by remote debugging on tomcat – I can’t remember what, but until I did so tomcat didn’t want to start with the changed startup script (see below) complaining about some missing executable (in log messages in /var/log/daemon.log).
Then you need to change tomcat’s startup script to add these args to tomcat’s startup command:
Then you need to set up a debug configuration for debugging your app as a remote Java app in Eclipse, providing the server’s hostname or IP number and the port on which the debugger running tomcat is listening – 8000 with the args listed above.
After restarting tomcat, you should be able to debug apps running on tomcat from a remote workstation. To test if tomcat started up with debugging enabled, just:
and see if port 8000 is listed. If not, start digging through the logs (/var/log/daemon.log, various in /var/log/tomcat6).
Unless you get th is port 8000 open, eclipse will tell you it can’t connect to the server – at least that’s what happened to me.
One more thing I noticed: if tomcat can’t start an app due to unhandled exceptions at startup, the debugger will die. If tomcat is able to start all deployed apps, but an unhandled exception occurs at runtime in an app, the debugger will also die. In neither situation will tomcat die too, so such exceptions are a problem only for debugging, and are relatively safe in production environments (if you don’t care about unhandled exceptions, t hat is). So you’ll probably have to restart tomcat a lot while debugging.
A more “upgrade friendly” (ie you don’t lose settings when server startup script is upgraded) is to edit /etc/default/tomcat6. There is a line here that enables the debugger by uncommenting (removing the hash mark) the following line:
#JAVA_OPTS="\${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"Hope that helps.
I also noticed there were some changes in the startup scripts from karmic to lucid/maverick (I was a bit stupid and negligent in my previous comment – what I wrote above was about karmic, not lucid, and I didn’t yet get to thoroughly investigate the problem on maverick). In lucid, you just have to enable some debug option in some startup file (I can’t remember by heart what the file is). Bottom line (for me) is, you have to look at tomcat’s startup files, and see where and how the debug args can be enabled/added to tomcat’s startup command.
What I’m interested in, but could not find any reference via Google, nor had the time to investigate at least halfway thoroughly, is whether it is possible to run tomcat in a debugger using openjdk instead of now oracle’s jvm. I could notice some jpda-related package names in the openjdk code base, but didn’t get any further than that.
Darn. I guess I’m out of luck. I’m a newbie when it comes to linux, tomcat, and jsp, but regardless no matter what I do I just can’t make it work. I installed java6, eclipse helios, tomcat6, configured it following instructions from all websites including this one, follow a tutorial and in the end the jsp page that i create is not found in the browser. Everything else seems to work fine, no compilation errors, the server starts with no problem, but the page never appears in the URL that is supposed to appear in. I tried tomcat7 and made no difference. I’ve already spent a month and nothing. I’m about to give up with Linux/eclipse/JSP. I thought it would be all really streamlined by now since it’s been out for so long… ugh.