• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

eclipse and servlets

 
Stephen Bloch
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stephen Bloch
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34686
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stephen Bloch
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34686
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your Eclipse is fine. Now this sounds like a Tomcat question, so I'm moving it to our Apache/Tomcat forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic