tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Wille <...@phatness.com>
Subject Re: Subclassing WebdavServlet
Date Mon, 26 Jul 2004 18:51:36 GMT
Okay, thanks for that reassurance.  Might you have an idea about the 
cause of the ClassNotFoundException?  I've copied all servlets*.jar in 
server/lib to common/lib.  I'm not sure what else, if anything, needs 
to be done.

Thanks!

-Mike Wille

On Jul 26, 2004, at 2:38 PM, Shapira, Yoav wrote:

>
> Hi,
> You can subclass it, should be fine.
>
> Yoav Shapira
> Millennium Research Informatics
>
>
>> -----Original Message-----
>> From: Michael Wille [mailto:mwille@donerus.com]
>> Sent: Monday, July 26, 2004 2:26 PM
>> To: tomcat-user@jakarta.apache.org
>> Subject: Subclassing WebdavServlet
>>
>> Hello All,
>>
>> I would like to know if its possible to subclass the webdav servlet
>> that comes with Tomcat 5.x.  We have need of webdav in our 
>> application,
>> but need to provide a different JNDI InitialContext then the file
>> system.  The thought was we could just override the getResources()
>> method in WebdavServlet to return our own context.
>>
>> What follows is a description of what we are doing:
>>
>> It seems there is at least one obstacle to doing this.  We would have
>> to move/copy the jar files: servlets-default.jar, servlets-common.jar,
>> and servlets-webdav.jar to the common/lib folder.  It seemed when we
>> attempted to move the files to common/lib, all of the default webapps
>> couldn't be loaded as well as some of our application servlets.  When
>> we leave the servlets*.jar files in both server/lib and common/lib, an
>> exception is thrown when accessing our servlet:
>>
>> javax.servlet.ServletException: Error instantiating servlet class
>> com.test.webdav.XDav
>>
>> And this is caused by:
>>
>> java.lang.NoClassDefFoundError:
>> org.apache.catalina.servlets.DefaultServlet
>>
>> This seems strange considering the app should have access to the
>> servlets-default.jar now that it is in common.  Or is there an issue
>> with libs in both server and common?
>>
>> Any help is hugely appreciated.
>>
>> Thanks!
>>
>> -Mike Wille
>>
>> Our subclassed servlet (with only test code for the InitialContext):
>>
>> package com.test.webdav;
>>
>> import javax.servlet.*;
>> import javax.servlet.http.*;
>>
>> import javax.naming.directory.InitialDirContext;
>> import javax.naming.directory.DirContext;
>>
>> import org.apache.catalina.servlets.*;
>>
>> public class XDav extends WebdavServlet  {
>>
>> 	// need to dup this here because these have
>> 	// private access in apaches webdavservlet
>> 	protected static final String METHOD_HEAD		=
> "HEAD";
>> 	protected static final String METHOD_PROPFIND	= "PROPFIND";
>> 	protected static final String METHOD_PROPPATCH	= "PROPPATCH";
>> 	protected static final String METHOD_MKCOL		=
> "MKCOL";
>> 	protected static final String METHOD_COPY		=
> "COPY";
>> 	protected static final String METHOD_MOVE		=
> "MOVE";
>> 	protected static final String METHOD_LOCK		=
> "LOCK";
>> 	protected static final String METHOD_UNLOCK		=
> "UNLOCK";
>>
>> 	protected Logger logger;
>>
>> 	public void init (ServletConfig config) throws ServletException
> {
>> 		// wake your parents
>> 		super.init(config);
>> 	}
>>
>> 	public void destroy() {
>> 		// kill your parents
>> 		super.destroy();
>> 	}
>>
>> 	/**
>> 	 * Get resources. This method will try to retrieve the resources
>> through
>> 	 * JNDI first, then in the servlet context if JNDI has failed
> (it
>> could be
>> 	 * disabled). It will return null.
>> 	 *
>> 	 * @return A JNDI DirContext, or null.
>> 	 */
>> 	protected DirContext getResources() {
>>
>> 		InitialDirContext result = null;
>>
>> 		// Try the servlet context
>> 		try {
>> 			//result = new IntitialLibraryContext();
>> 			result.bind("directory 1", "directory 1");
>> 			result.bind("directory 2", "directory 2");
>> 			result.bind("directory 3", "directory 3");
>> 			result.bind("directory 4", "directory 4");
>> 			result.bind("directory 3/subdirectory 5",
> "subdirectory
>> 5");
>>
>>
>> 		} catch(Exception e) {
>> 			logger.warning(UtilityTank.getErrorDetail(e));
>> 		}
>> 		return result;
>>
>> 	}
>> }
>
>
>
> This e-mail, including any attachments, is a confidential business 
> communication, and may contain information that is confidential, 
> proprietary and/or privileged.  This e-mail is intended only for the 
> individual(s) to whom it is addressed, and may not be saved, copied, 
> printed, disclosed or used by anyone else.  If you are not the(an) 
> intended recipient, please immediately delete this e-mail from your 
> computer system and notify the sender.  Thank you.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message