How can I best extend WebdavServlet?

2002-09-21 Thread Dave Small

Hi all.

I'm new to Tomcat4, although I've been using Tomcat3 for over two years. A
major difference appears to be the classloader mechanism, which I'm having
trouble getting to grips with. This leads to my question:

Is it possible to write a class that extends the Tomcat4 WebdavServlet? If I
try the obvious 'MyWebdavServlet extends WebdavServlet' in my own package, I
get a ClassDefNotFound for org/apache/catalina/servlets/WebdavServlet when I
try to call it. I guess this is something to do with the classloader,
because if I put the same MyWebdavServlet into the
org.apache.catalina.servlets package (which I know is a dodgy thing to do)
and put that class under tomcat/server/classes, all works well...

Can anyone explain this phenomenon? Has anyone written a class in their own
package that extends WebdavServlet?

Cheers
Dave Small



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: How can I best extend WebdavServlet?

2002-09-21 Thread Jacob Kjome

If the class exists in a jar archive inside $TOMCAT_HOME/server/lib or 
server/classes your webapps cannot see it.  Only the container sees 
that.  You can remedy this by moving the jar file that contains the class 
you want to common/lib.  That way, both the container and your webapp can 
see it.  plain lib (or shared/lib in Tomcat-4.1.x) is where you put classes 
that only your webapps can see.

Jake

At 12:35 PM 9/21/2002 +0100, you wrote:
Hi all.

I'm new to Tomcat4, although I've been using Tomcat3 for over two years. A
major difference appears to be the classloader mechanism, which I'm having
trouble getting to grips with. This leads to my question:

Is it possible to write a class that extends the Tomcat4 WebdavServlet? If I
try the obvious 'MyWebdavServlet extends WebdavServlet' in my own package, I
get a ClassDefNotFound for org/apache/catalina/servlets/WebdavServlet when I
try to call it. I guess this is something to do with the classloader,
because if I put the same MyWebdavServlet into the
org.apache.catalina.servlets package (which I know is a dodgy thing to do)
and put that class under tomcat/server/classes, all works well...

Can anyone explain this phenomenon? Has anyone written a class in their own
package that extends WebdavServlet?

Cheers
Dave Small



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]



Re: How can I best extend WebdavServlet?

2002-09-21 Thread Dave Small

- Original Message -
From: Jacob Kjome [EMAIL PROTECTED]
 If the class exists in a jar archive inside $TOMCAT_HOME/server/lib or
 server/classes your webapps cannot see it.  Only the container sees
 that.

Thanks Jake. One question remains - if I reference the WebdavServlet within
web.xml Tomcat seems able to find it ok in server/lib when I invoke the
servlet. If I reference MyWebdavServlet within web.xml (and MyWebdavServlet
extends WebdavServlet) Tomcat finds MyWebdavServlet but fails to find
WebdavServlet (giving the ClassDefNotFound error). Is there something in the
spec that the classloader can only load main classes and not classes that
are used as a basis for these main classes (such as WebdavServlet)?

cheers
dave



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]