users@jersey.java.net

Re: [Jersey] jersey not mapping requests

From: tarjei <tarjei_at_nu.no>
Date: Wed, 24 Sep 2008 11:15:50 +0200

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi, Thanks for helping me. I finally figured this out by using 0.11 and
removing any refrences to CXF.

One thing I am missing though is an updated example of both how the
pom.xml and web.xml files should look when using Sping. I've probably
wasted quite some time on this due to the namespace change done in an
earlier release.

PS: Also, why doesn't this work:

@Path("someresource")
class MyResource {

@GET
@Path("/")
public Sub myMethod() {}

But this does:
@GET
public Sub myMethod() {}

}

Kind regards,
Tarjei

Paul Sandoz wrote:
> Hi Tarjei,
>
> 0.9-ea-SNAPSHOT and 0.9-ea are on the repo, read the following as there
> has been some changes:
>
> https://jersey.dev.java.net/source/browse/*checkout*/jersey/branches/jersey-0.9/jersey/dependencies.html
>
>
> because for 0.9 we modularized things.
>
> However, i recommend you try 0.11-ea-SNAPSHOT:
>
> https://jersey.dev.java.net/source/browse/*checkout*/jersey/trunk/jersey/dependencies.html
>
>
> which is very close to becoming 1.0.
>
>
> 0.8 was released a while ago, so my memory is hazy. I think the issue is
> that the request URI has a slash at the end and in 0.8 such matching to
> non-slashed @Path annotated classes was not supported, but it is now.
>
> If you move to 0.9-ea or 0.11-ea-SNAPSHOT you will need to change
> @ProduceMime to @Produces.
>
> Also it is no longer necessary to declare the init-param
> "....resourceConfigClass", it will work with just the init-param
> "...packages".
>
> Hope this helps,
> Paul.
>
> On Sep 23, 2008, at 5:42 PM, Tarjei Huse wrote:
>
>> Hi, I'm testing out jersey, but I got a problem.
>>
>> I've added my servlet to jettys web.xml like this:
>>
>> <servlet>
>> <servlet-name>Jersey Web Application</servlet-name>
>>
>> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
>>
>> <init-param>
>> <description>
>>
>> </description>
>>
>> <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
>>
>>
>> <param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>
>> </init-param>
>> <init-param>
>>
>> <param-name>com.sun.jersey.config.property.packages</param-name>
>> <param-value>com.scanmine.newsletter</param-value>
>> </init-param>
>> <load-on-startup>1</load-on-startup>
>> </servlet>
>> <servlet-mapping>
>> <servlet-name>Jersey Web Application</servlet-name>
>> <url-pattern>/jersey/*</url-pattern>
>> </servlet-mapping>
>>
>> And I got a class:
>> @Path("/newsletter")
>> @ProduceMime("application/xml")
>> @Service("newsletterService")
>> public class NewsletterService {
>>
>> @GET
>> @Path("/")
>> public Newsletters listPages() {
>> if (rsspageDao == null) {
>> log.debug("Missing rsspage!");
>> }
>> return new Newsletters(rsspageDao.getAll());
>> }
>> ...
>> }
>>
>> When I try to access the class using the url:
>> http://localhost:8080/jersey/newsletter/
>>
>> I get a 404.
>>
>> In the logs, I find:
>> INFO: Root resource classes found:
>> class com.scanmine.newsletter.service.NewsletterService
>> class com.scanmine.newsletter.service.SubscriberService
>> Sep 23, 2008 5:35:38 PM com.sun.jersey.api.core.PackagesResourceConfig
>> init
>> INFO: Provider classes found:
>> Sep 23, 2008 5:35:38 PM org.apache.cxf.transport.servlet.CXFServlet
>> updateContext
>> INFO: Load the bus with application context
>> Sep 23, 2008 5:35:38 PM org.apache.cxf.bus.spring.BusApplicationContext
>> getConfigResources
>> INFO: No cxf.xml configuration file detected, relying on defaults.
>> Sep 23, 2008 5:35:38 PM
>> org.apache.cxf.transport.servlet.AbstractCXFServlet
>> replaceDestinationFactory
>> INFO: Servlet transport factory already registered
>> 2008-09-23 17:35:38.259:appfuse:INFO: Initializing Spring
>> FrameworkServlet 'dispatcher'
>> [INFO] Restart completed at Tue Sep 23 17:35:39 CEST 2008
>> 2008-09-23 17:35:43.782::WARN: /jersey/newsletter
>> java.lang.NullPointerException
>> at
>> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:266)
>>
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>> at
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
>> at
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
>>
>> at
>> com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
>>
>> at
>> com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
>>
>> at
>> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>>
>>
>>
>> So, why am I getting a 404 here?
>>
>> This service works when I use CXF, although it then has some other
>> problems.
>>
>> Also, when will 0.9 be uploaded to the maven repo? I tried to substitute
>> 0.8-ea-SNAPSHOT with 0.9-ea-SNAPSHOT but without luck.
>>
>> Kind regards,
>> Tarjei
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFI2gVGYVRKCnSvzfIRAu5YAJ98NezT8q5BPh9eF6yHIMDrGc3UCQCgnjHD
vBZYpJ+pvtqLJJ3bHG00ejI=
=U//e
-----END PGP SIGNATURE-----