Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Eclipse with Tomcat and Sysdeo Plugin

 
Udit Manektala
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Im trying to get Eclipse to work with Tomcat using the Sysdeo plugin and have a few questions.

Firstly, I have already installed the Sysdeo plugin and can start\stop\restart Tomcat from Eclipse. So that works.
But here's the problem.

1. When I create a new Tomcat Project and put servlets with a web.xml, I can't
find a Deployment Button or anything. So I look around on the net and figure that I dont need to really Deploy anything, the plugin automagically places the files in the TomCat folder.
But when I try to acces the servlet at http://localhost:8080/XYZ/abc even though I have te right XYZ and abc, I still can't access it. So I look into the C:\tomcat\webapps folder and sure enough, that project is not there. Just for kicks, I copy my Web Project folder into the c:\Tomcat\Webapps folder and then I can access the servlet.

But how is this really supposed to work ? Should Sysdeo\Eclipse be placing the class files into the tomcat folder by itself or am i supposed to copy the project folder into the Tomcat\Webapps everytime I make a code change ?

If Its supposed to be copying the project files needed by itself then what couls I be doing wrong?
I have checked the Preferences Window and the path for the Tomcat folder is correct.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no need to copy anything. A webapp doesn't really *need* to be located in the webapps folder - Tomcat is able to run it directly from the Eclipse workspace.

All you should need to do is right clicking on your new project, going into the tomcat submenu and there select the menu entry that reads something along the lines of "update context". That will register the context in Tomcat, telling it to look for the webapp in your project directory.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18214
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not only doesn't a webapp not "need" to live in TOMCAT_HOME/webapps, there's a very good reason why it doesn't. There are occasionally times when it's useful to be running multiple copies of the same codebase - either for multiple Tomcat instances, or as alternate copies in the same instance, but with different setup parameters. Or both.

Although the feature first appeared in Tomcat4, in Tomcat5, the preferred deployment is not to merely plunk down a copy of the webapp codebase, but to formally define the application via a context file. In Tomcat5, that would be in TOMCAT_HOME/conf/Catalina/localhost. The context file defines the webapp context - including custom environment options and the location of the codebase. In Tomcat 5.0, I believe that WARs would be exploded into the TOMCAT_HOME/webapps directory, but this behaviour isn't something cast in stone. And in fact, caused me a log of grief, since Tomcat4 wasn't as likely to end up shoving stale classes down my throat.

In my own Eclipse projects, therefore, I define the web application context to point to my build/webapps directory, which is where I assemble the parts from which I will create the final WAR. This means that I only need to actually build the WAR itself when I'm ready to make a deployable unit, and that saves me some time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic