Hi, I managed to delete Pauls answer to my earlier questions, but I hope
I mange to keep the posts in the thread.
Paul wrote:
> 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.
Now, I read that document, and updated my dependencies to 0.11-ea-SNAPSHOT. This worked with regard to maven. However, I did not mange to get everything working,
and I got some new questions:
1. The document states:
Spring
Maven developers, using Spring 2.0.x or Spring 2.5.x, require a
dependency on the jersey-spring <
http://download.java.net/maven/2/com/sun/jersey/jersey-spring/0.11-ea-SNAPSHOT/jersey-spring-0.11-ea-SNAPSHOT.pom>
module.
The servlet:
com.sun.jersey.spi.spring.container.servlet.SpringContainer
is required to be referenced in the web.xml of the Spring-based
Web application.
Does this mean the servlet should be referenced on top of the normal com.sun.jersey.spi.container.servlet.ServletContainer or alongside it?
I would be greatfull if you could provide example configurations for this in the document as several variants exist on the net[1] that seem to be wrong.
I ended up with the following:
<servlet>
<servlet-name>Jersey Spring</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringContainer</servlet-class>
<init-param>
<param-value>com.sun.ws.rest.api.core.PackagesResourceConfig</param-value>
</init-param>
<init-param>
<param-name>com.sun.ws.rest.config.property.packages</param-name>
<param-value>your.resource.package</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Spring</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
2. When I tried to use the following dependencies:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>0.11-ea-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>0.11-ea-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-spring</artifactId>
<version>0.11-ea-SNAPSHOT</version>
</dependency>
I get a number of interesting exceptions:
2008-09-24 10:44:32.242:/:INFO: Initializing Spring root WebApplicationContext
2008-09-24 10:46:27.585::WARN: EXCEPTION
java.lang.ClassNotFoundException: com.sun.jersey.spi.spring.container.servlet.SpringContainer
I have also tried:
com.sun.ws.rest.spring.SpringServlet
as per [1].
Links:
1.
http://www.javakaffee.de/blog/2008/04/21/jersey-spring-integration-mostly-complete/
So, what am I doing wrong now?
Kind regards,
Tarjei
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
>
>