[groovy-user] Using Slide . . .

5 views
Skip to first unread message

Russel Winder

unread,
Jan 6, 2008, 3:28:36 AM1/6/08
to Groovy Users
Overall goal: create an automated upload of distributions for Gant.
Immediate Goal: find out how to use Slide to upload to a WebDAV
service.

Slide 2.1 is in Maven even though the Apache Foundation has retired
Slide in favour of Jackrabbit. Slide has a WebDAV client library that I
believe is used by Maven to handle the WebDAV using the Wagon-WebDAV
system. My problem is that even the examples of using Slide WebDAV that
are on the Web fail for me. for example the code below just throws an
HttpException but I can get no information about why. Has anyone got
any experience with using Slide WebDAV who could give me a hand offlist?

Or perhaps there is a live WebDAV library usable form Java/Groovy that
would be better?

Thanks.

This code:

import java.io.File ;
import org.apache.commons.httpclient.Credentials ;
import org.apache.webdav.lib.WebdavResource ;
public class WebdavResourceTest {
public static void main ( final String[] args ) {
try {
final WebdavResource resource = new WebdavResource
( "http://www.russel.org.uk" ) ;
}
catch ( final Exception e ) {
System.err.println ( e ) ;
System.err.println ( e.getMessage ( ) ) ;
System.err.println ( e.getCause ( ) ) ;
e.printStackTrace ( ) ;
}
}
}

ends up with:

org.apache.commons.httpclient.HttpException
null
null
org.apache.commons.httpclient.HttpException
at
org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3467)
at
org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3423)
at
org.apache.webdav.lib.WebdavResource.setNamedProp(WebdavResource.java:967)
at
org.apache.webdav.lib.WebdavResource.setBasicProperties(WebdavResource.java:912)
at
org.apache.webdav.lib.WebdavResource.setProperties(WebdavResource.java:1894)
at
org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1301)
at
org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1320)
at
org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1408)
at
org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1426)
at
org.apache.webdav.lib.WebdavResource.<init>(WebdavResource.java:373)
at WebdavResourceTest.main(WebdavResourceTest.java:7)

. . .


--
Russel.
====================================================
Dr Russel Winder Partner

Concertant LLP t: +44 20 7193 9203
41 Buckmaster Road, f: +44 8700 516 084
London SW11 1EN, UK. m: +44 7770 465 077

signature.asc

Paul King

unread,
Jan 6, 2008, 6:12:44 AM1/6/08
to us...@groovy.codehaus.org

I can probably drag out some code. I have used Slide and
its client library quite a bit.

Paul.


---------------------------------------------------------------------
To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Jürgen Hermann

unread,
Jan 7, 2008, 6:31:24 AM1/7/08
to us...@groovy.codehaus.org
> From: Russel Winder [mailto:russel...@concertant.com]
> final WebdavResource resource = new WebdavResource
> ( "http://www.russel.org.uk" ) ;

For starters, you don't support OPTIONS under that URL (500 response), which is the 1st thing of any WebDAV negotiation. You do under /svn/, so try that one.

Russel Winder

unread,
Jan 7, 2008, 9:28:56 AM1/7/08
to us...@groovy.codehaus.org
Jürgen,

On Mon, 2008-01-07 at 12:31 +0100, Jürgen Hermann wrote:
> > From: Russel Winder [mailto:russel...@concertant.com]
> > final WebdavResource resource = new WebdavResource
> > ( "http://www.russel.org.uk" ) ;
>
> For starters, you don't support OPTIONS under that URL (500 response), which is the 1st thing of any WebDAV negotiation. You do under /svn/, so try that one.

Thanks for this comment, it pushed me in the right direction. It turns
out that the code I had originally was in fact correct, I have no idea
why it didn't work. Gremlins I guess. It works now. Well almost. It
turn out that in Java using:

final WebdavResource resource = new WebdavResource ( "https://dav.codehaus.org/dist/gant/" , credentials ) ;

works fine. However from Groovy, using reflection, the two parameter
constructor fails and I have to use the three parameter constructor:

resource = loader.loadClass ( 'org.apache.webdav.lib.WebdavResource' ).getConstructor ( String , loader.loadClass ( 'org.apache.commons.httpclient.Credentials' ) , boolean ).newInstance ( distributionURL , credentials , true )

Bizarre but it does work. However, now my problem is that I don't
understand the:

putMethod ( String , File )
getMethod ( String , File )

methods. If the local filestore and the server filestore have the same
structure then putMethod (File) and getMethod(File) do the right thing
and actually work, but whenever I use the above two methods I just get
a:

Bad Request (400)

The javadoc documents I can find on WebdavResource are singularly
unhelpful :-(

I thought about trying Jackrabbit but as soon as I saw the comment "we
know we are desperately in need of documentation" I wondered why retire
Slide before Jackrabbit is ready for prime time?

signature.asc

Russel Winder

unread,
Jan 7, 2008, 12:28:27 PM1/7/08
to us...@groovy.codehaus.org
Getting close but not close enough :-( Anyone any ideas?

All my calls to WebdavResource.putMethod ( File ) are generating:

07-Jan-2008 17:21:03 org.apache.commons.httpclient.HttpMethodBase
processRedirectResponse
INFO: Redirect requested but followRedirects is disabled

and failing with status:

Moved Permanently (301)

I have forcibly set followRedirects to true in the WebdavResource
object, so I have no idea what is happening. Nor do I know what 301
really means in this case.

If we can just solve this I can release Gant 1.0.3.

signature.asc

Paul King

unread,
Jan 7, 2008, 3:15:54 PM1/7/08
to us...@groovy.codehaus.org
Russel Winder wrote:
> Getting close but not close enough :-( Anyone any ideas?
>
> All my calls to WebdavResource.putMethod ( File ) are generating:
>
> 07-Jan-2008 17:21:03 org.apache.commons.httpclient.HttpMethodBase
> processRedirectResponse
> INFO: Redirect requested but followRedirects is disabled

This part of it could just be a spurious warning. If WebdavResource
is handling redirects itself, you will get the warning regardless.
You can turn if off with an appropriate tweaks to a log4j.properties
file or safely ignore it.

> and failing with status:
>
> Moved Permanently (301)
>
> I have forcibly set followRedirects to true in the WebdavResource
> object, so I have no idea what is happening. Nor do I know what 301
> really means in this case.
>
> If we can just solve this I can release Gant 1.0.3.
>

Jürgen Hermann

unread,
Jan 8, 2008, 4:33:58 AM1/8/08
to us...@groovy.codehaus.org
> From: Russel Winder [mailto:russel...@concertant.com]
> Moved Permanently (301)

Use a trailing slash on your initial directory URL and you'll likely not get this.

That might also help:

System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpcliet", "debug");

Russel Winder

unread,
Jan 9, 2008, 3:07:13 AM1/9/08
to us...@groovy.codehaus.org
Jürgen,

Thanks for your continued help with this one, it is much appreciated.

On Tue, 2008-01-08 at 10:33 +0100, Jürgen Hermann wrote:
> > From: Russel Winder [mailto:russel...@concertant.com]
> > Moved Permanently (301)
>
> Use a trailing slash on your initial directory URL and you'll likely not get this.

Adding the trailing / on the URL certainly gets rid of the
followsRedirect message (but I have no idea why :-( It also changes the
overall result: instead of getting "Moved Permanently ( 301)", I am now
getting "Conflict (409)". I am not sure if this is progress -- I guess
I know too little of HTTP and WebDAV :-(

> That might also help:
>
> System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");

> System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");

I added these but they didn't seem to change anything.

signature.asc

Jürgen Hermann

unread,
Jan 9, 2008, 4:56:12 AM1/9/08
to us...@groovy.codehaus.org
> From: Russel Winder [mailto:russel...@concertant.com]
> Adding the trailing / on the URL certainly gets rid of the
> followsRedirect message (but I have no idea why :-(

because a webdav store enforces the urls to its resources to be canonical. in the case of dirs that means a trailing slash.

> It also
> changes the
> overall result: instead of getting "Moved Permanently (
> 301)", I am now
> getting "Conflict (409)".

PUT or GET? If PUT, did you get a LOCK?

> I am not sure if this is progress

It is. But it might be time to get out WireShark / WinPcap / WinDump / tcpdump / etc. and log your traffic to the DAV server to get more insight.

Russel Winder

unread,
Jan 9, 2008, 5:24:42 AM1/9/08
to us...@groovy.codehaus.org

On Wed, 2008-01-09 at 10:56 +0100, Jürgen Hermann wrote:
> > From: Russel Winder [mailto:russel...@concertant.com]
> > Adding the trailing / on the URL certainly gets rid of the
> > followsRedirect message (but I have no idea why :-(
>
> because a webdav store enforces the urls to its resources to be canonical. in the case of dirs that means a trailing slash.

OK, that makes sense. :-)

> > It also
> > changes the
> > overall result: instead of getting "Moved Permanently (
> > 301)", I am now
> > getting "Conflict (409)".
>
> PUT or GET? If PUT, did you get a LOCK?

PUT. I guess then I cannot do a PUT until I have a LOCK?

The only example of code I could see easily on the Web only did GET and
that worked fine.



> > I am not sure if this is progress
>
> It is. But it might be time to get out WireShark / WinPcap / WinDump / tcpdump / etc. and log your traffic to the DAV server to get more insight.

I think from the names WinPcap and WinDump are out since I am on Ubuntu.
I guess this is a job for Ethereal or equivalent.

Thanks.

signature.asc

Paul King

unread,
Jan 9, 2008, 6:27:38 AM1/9/08
to us...@groovy.codehaus.org
Russel Winder wrote:
> On Wed, 2008-01-09 at 10:56 +0100, Jürgen Hermann wrote:
>>> From: Russel Winder [mailto:russel...@concertant.com]
>>> Adding the trailing / on the URL certainly gets rid of the
>>> followsRedirect message (but I have no idea why :-(
>> because a webdav store enforces the urls to its resources to be canonical. in the case of dirs that means a trailing slash.
>
> OK, that makes sense. :-)
>
>>> It also
>>> changes the
>>> overall result: instead of getting "Moved Permanently (
>>> 301)", I am now
>>> getting "Conflict (409)".
>> PUT or GET? If PUT, did you get a LOCK?
>
> PUT. I guess then I cannot do a PUT until I have a LOCK?
>
> The only example of code I could see easily on the Web only did GET and
> that worked fine.

I just sent you some example code off-list (just a warning in case you have
spam filters in place). There is both Java and Ant code for deploying files
to WebDav repos.

>>> I am not sure if this is progress
>> It is. But it might be time to get out WireShark / WinPcap / WinDump / tcpdump / etc. and log your traffic to the DAV server to get more insight.
>
> I think from the names WinPcap and WinDump are out since I am on Ubuntu.
> I guess this is a job for Ethereal or equivalent.

I think TCPMON is good enough for this.

Paul.

Russel Winder

unread,
Jan 10, 2008, 6:42:13 AM1/10/08
to us...@groovy.codehaus.org
Paul,

On Wed, 2008-01-09 at 21:27 +1000, Paul King wrote:

> I just sent you some example code off-list (just a warning in case you have
> spam filters in place). There is both Java and Ant code for deploying files
> to WebDav repos.

As far as I can tell apart from the transaction stuff, I had it all
right. I put the transaction stuff in just in case and I still get
"Conflict ( 409)".

> >>> I am not sure if this is progress
> >> It is. But it might be time to get out WireShark / WinPcap / WinDump / tcpdump / etc. and log your traffic to the DAV server to get more insight.
> >
> > I think from the names WinPcap and WinDump are out since I am on Ubuntu.
> > I guess this is a job for Ethereal or equivalent.
>
> I think TCPMON is good enough for this.

I guess I am not suing it right...

stream-8: java.net.SocketException: Socket closed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.net.SocketInputStream.read(SocketInputStream.java:90)
at tcpmon.StreamThread.copyStream(Unknown Source)
at tcpmon.StreamThread.run(Unknown Source)
10-Jan-2008 11:38:19 org.apache.commons.httpclient.HttpMethodBase
processRequest
INFO: Recoverable exception caught when processing request
10-Jan-2008 11:38:19 org.apache.commons.httpclient.HttpMethodBase
processRequest
WARNING: Recoverable exception caught but
MethodRetryHandler.retryMethod() returned false, rethrowing exception
null

signature.asc

Russel Winder

unread,
Jan 10, 2008, 8:31:43 AM1/10/08
to us...@groovy.codehaus.org

On Thu, 2008-01-10 at 11:42 +0000, Russel Winder wrote:
> Paul,
>
> On Wed, 2008-01-09 at 21:27 +1000, Paul King wrote:
>
> > I just sent you some example code off-list (just a warning in case you have
> > spam filters in place). There is both Java and Ant code for deploying files
> > to WebDav repos.
>
> As far as I can tell apart from the transaction stuff, I had it all
> right. I put the transaction stuff in just in case and I still get
> "Conflict ( 409)".

Oh no I don't :-)

Pouring over the code Paul sent me, I spotted the res.getPath ( ) and
finally twigged that in the putMethod ( String , File ) the String has
to be relative to the server not relative to the URL used to open the
connection. Fix that, fix everything.

I am now able to upload Gant distributions programmatically. The proof
is that 1.0.3-SNAPSHOT is on the server. I guess now would be a good
time to release 1.0.3 for real.

Thanks to Paul and Jürgen for helping through this mess. In the end the
code is straightforward. Which is good :-)

signature.asc
Reply all
Reply to author
Forward
0 new messages