tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Winnall <st...@winnall.ch>
Subject WebdavServlet + custom DirContext = unexpected behaviour
Date Fri, 13 Feb 2009 01:01:08 GMT
I'm developing my first ever servlet for Tomcat 6.0.18 under Mac OS X  
10.5.6 with Java 1.5.0_16. I've used Tomcat a lot with Cocoon and I  
know Java reasonably well.

I'd like to extend the standard WebdavServlet that comes with Tomcat  
to access data from a relational database using JDBC. I've started to  
write a DirContext (called DBDirContext) to do this. I've written a  
test servlet

public class DBServlet extends WebdavServlet {...}

and filled it with methods which print out a message and invoke their  
super methods:

... xxx(...) {
     System.out.println("some text");
     super.xxx(...);
}

i.e. I just want a trace on standard output of what WebDAV calls so I  
know what bits of DBDirContext to develop next.

My Tomcat is as installed by NetBeans 6.5, that is with a separate  
CATALINA_HOME and CATALINA_BASE. I have discovered that my  
DBDirContext and supporting database stuff is not found if I include  
it in the WAR file deployed into $CATALINA_BASE/webapps, so I modified  
$CATALINA_BASE/conf/catalina.properties to make common.loader look  
also in $CATALINA_BASE/common/lib and I put DBDirContext and  
supporting cast into there.

If I put the following file into META-INF/context.xml, I can call  
DBServlet over an HTTP session and successfully mount a WebDAV disk  
using the filesystem:

<Context>
     <Resource name="jdbc/xwdb" auth="Container"
           type="javax.sql.DataSource"  
driverClassName="org.postgresql.Driver"
           url="..."
           username="..." password="..." maxActive="20" maxIdle="10"  
maxWait="-1"/>
</Context>

All of my output to standard output appears in the log.

However, when I include <Resources... /> to pull in DBDirContext as  
follows, WebDAV gets as far as an initial OPTIONS method and gives up:

<Context>
     <Resources className="org.vimia.xw.db.dircontext.DBDirContext" />
     <Resource name="jdbc/xwdb" auth="Container"
           type="javax.sql.DataSource"  
driverClassName="org.postgresql.Driver"
           url="..."
           username="..." password="..." maxActive="20" maxIdle="10"  
maxWait="-1"/>
</Context>

The trace I built in does not appear on standard output in this case.  
Examining the response to the OPTIONS method, I see that WebDAV  
generates a response from doOptions in HttpServlet and not from the  
overriding one in WebdavServlet.

So WebdavServlet and my DBServlet seem to be being ignored. I don't  
understand why and I'd be grateful if someone could give me some  
pointers. The Tomcat documentation suggests that changing the  
<Resources .../> to something other than the filesystem results in  
Tomcat not being able to read files it needs: does this include my JAR  
files? If so, do I have to make a hybrid DBDirContext that gets the  
files Tomcat needs from the filesystem and the data I want from the  
database?

Steve




Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message