users@jersey.java.net

Re: [Jersey] Re: AbstractMethodError on requesting resource

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 11 Feb 2009 10:35:27 +0100

On Feb 10, 2009, at 11:49 PM, Chris Winters wrote:

> On Tue, Feb 10, 2009 at 4:36 PM, Chris Winters <chris.winters_at_gmail.com
> > wrote:
>> ...
>> 4) This compiles and starts up fine, but on doing a GET I get the
>> exception:
>>
>> $ GET http://localhost:8080/VoiceConsole/r/device/248421104
>>
>> java.lang.AbstractMethodError:
>> javax.ws.rs.core.UriBuilder.replacePath(Ljava/lang/String;)Ljavax/
>> ws/rs/core/UriBuilder;
>> at
>> com
>> .sun
>> .jersey
>> .spi
>> .container.servlet.ServletContainer.service(ServletContainer.java:
>> 302)
>> at
>> com
>> .sun
>> .jersey
>> .spi
>> .container.servlet.ServletContainer.service(ServletContainer.java:
>> 239)
>> at
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
>> 502)
>> at org.mortbay.jetty.servlet.ServletHandler
>> $CachedChain.doFilter(ServletHandler.java:1124)
>> ...
>
> When in the debugger I noticed the likely issue -- the UriBuilder is
> from the Apache CXF, not Jersey. Gah! And it looks like the 0.8 is the
> version JSR-311 that the latest CXF uses (2.1.4, coincidentally
> released today).
>
> I assumed the CXF version is getting loaded first because it appears
> first in the classpath and therefore the ServiceLoader listing (or
> something similar), so I renamed 'cxf-2.1.4.jar' to 'z-cxf-2.1.4.jar'.
> It actually worked!
>
> It looks like I can fart around with providing the correct
> javax.ws.rs.ext.RuntimeDelegate implementation with a properties file
> somewhere or other ($java.home/lib -- really? ugh), so I'll try that.

Yes, ugh, not ideal. Another approach might be to register the Jersey
RuntimeDelegateImpl in that listener explicitly:

   RuntimeDelegate.setInstance(new
com.sun.jersey.server.impl.provider.RuntimeDelegateImpl());

You could do this using your own servlet context listener. Or override
the:

   com.sun.jersey.spi.container.servlet.ServlerContainer

and in the constructor set the runtime delegate instance.

Would it be possible to try the above? if it works we could support a
special feature, as an init-param, to explicitly set the runtime
delegate.


> But I wanted to post this so nobody wasted time on my earlier message.
>

Thanks,
Paul.