tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David M. Holmes" <>
Subject Re: dumb question regarding servlets in packages running in tomcat.
Date Tue, 01 Aug 2000 18:08:43 GMT
This probably doesn't help but... I place my servlets in packages under WEB-INF/classes and
them with the full package and class name (no entries in web.xml).


--- "Boniakowski,Jeb" <> wrote:
> Hi, this is a dumb question that's been frustrating me for embarassingly
> long.  If anyone knows of a more appropriate place for dumb questions
> (besides /dev/null, wiseguys) or has a pointer to the right docs to look in
> for this info, I will gladly accept those in lieu of direct help, though I
> must add that I've read all the FAQs, docs, and refs on the apache page and
> in the archives.
> I'm running tomcat standalone on a win98 box (gimme a break, it's at work).
> My problem is that when I try to use any servlets that are in packages, I
> get this error:
> java.lang.NoClassDefFoundError: COM/nntllc/servlet/TDLogin (wrong name:
> TDLogin)
> 	at java.lang.ClassLoader.defineClass0(Native Method)
> 	at java.lang.ClassLoader.defineClass(
> 	at java.lang.ClassLoader.defineClass(
> And so on, up the call stack.
> Now, if I take that TDLogin.class file, and put it in WEB-INF/classes,
> comment out the package line, and change the entry in my web.xml file
> accordingly, I'm fine.  It works.
> Here is the package line:
> package COM.nntllc.servlet;
> Here is the relevant piece of the web.xml file (all that's snipped is the
> DTD ref and the <?xml...> bit):
> <web-app>
>     <servlet>
>         <servlet-name>
>             TDLogin
>         </servlet-name>
>         <servlet-class>
>             COM.nntllc.servlet.TDLogin
>         </servlet-class>
>     </servlet>
>     <servlet-mapping>
>         <servlet-name>
>             TDLogin
>         </servlet-name>
>         <url-pattern>
>             /TDLogin
>         </url-pattern>
>     </servlet-mapping>
> </web-app>
> And here is the directory listing for the dir in question:
> $ls webapps/nnt/WEB-INF/classes/COM/nntllc/servlet/
> TDLogin.class
> Now, I know that tomcat is finding the class via the url:
> http://localhost:8080/nnt/servlet/TDLogin
> because if I rm the class file, I get a 404 error from that url.  So in some
> way, it seems to me that tomcat is saying "doot doo doo here's a request for
> something called /nnt/servlet/TDLogin, lemme check my server.xml for a
> context for that...yup, there it is, webapps/nnt doot doo doo now I need a
> web.xml so I know what the hell that is...okay, there it is, right in
> WEB-INF like it's supposed to be...well, it says here that TDLogin is a
> servlet, and I'm supposed to take all requests for /nnt/servlet/TDLogin and
> send them to that servlet, where does web.xml say that is?  Oh yeah, right
> here in WEB-INF/classes/COM/nntllc/servlet/TDLogin.class.  I can find that
> okay.  open it up, check the package, seems fin@#$@#$@$@#$where's my
> classdef?"
> I don't really understand what would cause a NoClassDefFoundError in any
> case.  According to my "Java Programming Language, Second Edition" by Arnold
> and Gosling (god bless him), that occurs when a class can not be found when
> it is needed.  But it is finding the class, at least to some extent, cause
> it breaks more when I rm the class.  So my guess is there's some kind of
> package/namespace/(?classpath?) issue at work here.  It finds the file,
> opens it, expecting to find some definition for the class.  I have this in
> the file:  
> public class TDLogin extends HttpServlet {
> What more does it want from me?  Perhaps interestingly, it does the same
> thing if I leave TDLogin.class in COM/nntllc/servlet whether or not I have
> the package line at the top.
> I'd think it was a package-y issue, but I know it's finding the file (from
> above-mentioned 404 error) and if it was reading the file and not liking the
> package stuff, wouldn't it say something like "TDLogin should be in a file
> /COM..."?
> I realize this is probably the most annoying type of question possible and
> you probably get it all the time and the message is long, but I've been
> working on this since yesterday at like 4pm, and I'm really frustrated and
> dumb feeling now.  Any advice, even scornful advice, would be appreciated.
> jeb.
> PS - sorry my last message was in HTML.  I'm using outlook.  I'll avoid it
> in the future

Do You Yahoo!?
Kick off your party with Yahoo! Invites.

View raw message