This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Tomcat and the fly likes eclipse and servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "eclipse and servlets" Watch "eclipse and servlets" New topic
Author

eclipse and servlets

Stephen Bloch
Ranch Hand

Joined: Aug 19, 2003
Posts: 48
Working my way through _Eclipse in Action_... chapter 7....
I've gotten several JSP's to work correctly under Tomcat.
I've gotten a simple servlet to work correctly under Tomcat.
But as soon as a servlet uses a class I've defined in another package, I get a NoClassDefFoundError. I assume something is wrong in the search paths, but I've checked every path-related Eclipse preference I can find, and they all refer to the basedir of the other packages. Do I need to do something special to tell Tomcat how to find packages at run time?

I'm using Eclipse 2.1, Java 1.4.1, Tomcat 5.0.28, SysDeo Tomcat plugin 2.2.1, MacOS 10.2.8.


SCJP 1.4
Stephen Bloch
Ranch Hand

Joined: Aug 19, 2003
Posts: 48
Addendum: I have confirmed that I can get a servlet to refer to a user-defined class that's defined in the same package, and I can refer to a user-defined class that's defined in another package in the same Eclipse project, but I can't get at a class that's defined in a package in a different project. Even the <em>same</em> package in a different project.



So where do I set the paths?
  • The most obvious one to me was "Project -> Properties -> Java Build Path -> Projects", where I checked the name of the other project where the class is defined.
  • Just to make sure, I also went to "Project -> Properties -> Java Build Path -> Libraries" and added the "bin" directory of said other project. (Removing this duplicate path entry doesn't help either.)
  • "Windows -> Preferences -> Build Order" specifies things in the right order, dependee before dependant.


  • Is there anyplace else I need to go to tell Eclipse how to find the classes in question?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30390
    
150

Steven,
In WSAD: The "build path" is used at compile time. The "java jar dependencies" is used at runtime. If it isn't set properly, you get runtime errors, but not compile errors. You can set the java jar dependencies by right clicking the project and selecting properties (for a web project.)

So it follows that Tomcat's classpath needs a jar for this other project.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Stephen Bloch
Ranch Hand

Joined: Aug 19, 2003
Posts: 48
OK, I've looked under Project -> Properties -> Tomcat -> Devloader Classpath, checked "Enable DevLoader", and checked all the relevant folders. No dice: the servlet still couldn't find classes defined in different projects. So I stopped Tomcat and re-started it; startup failed because it was unable to find the DevLoader class. I un-checked "Enable DevLoader" and re-started Tomcat, and the servlet was again unable to find classes defined in different projects.



Am I missing a component of Tomcat, or have I failed to set some option in Eclipse, or what?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30390
    
150

Your Eclipse is fine. Now this sounds like a Tomcat question, so I'm moving it to our Apache/Tomcat forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: eclipse and servlets