users@jersey.java.net

Re: [Jersey] jsersey 1.1.2 and spring beans defined in xml

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 21 Oct 2009 14:43:19 +0200

Hi,

Do you know if the Spring configuration was successful? i.e is the
following really in the class path?

   classpath:resources/frontendContext.xml

Can you send the server side log?

Paul.


On Oct 21, 2009, at 2:30 PM, gabriele renzi wrote:

> Hi everyone,
>
> sorry if this question is actually answered elsewhere, I spent a few
> hours digging into google results spanning the last year and a half,
> but in the end I am still unable to reach my goal: expose a bean I
> define in spring's XML, using jersey-bundle-1.1.2-ea and
> jersey-spring-1.1.2-ea.
>
> Basically I have code like in resources/frontendContext.xml
>
> <bean id="HttpFacadeBean" class="my.servlet.spring.SpringHttpFacade"
> scope="singleton">
> <constructor-arg ref="aBean" />
> <constructor-arg ref="otherBean" />
> <constructor-arg ref="other" />
> ...
> </bean>
>
> and the SpringHttpFacade is something like
>
> @Path("/spring")
> // @Singleton //I tried with and without this annotation but my I
> believe it should not be needed
> public class SpringHttpFacade extends AbstractFacade {
> public SpringHttpFacade(Foo foo, Bar bar, Baz baz..) {
> super(foo, bar, baz, ...);
> }
> @Override
> protected something(){.. }
> }
>
>
> according to the docs at
> https://jersey.dev.java.net/nonav/apidocs/1.1.2-ea/contribs/jersey-spring/com/sun/jersey/spi/spring/container/servlet/SpringServlet.html
>
> this should work with the following web.xml
>
> <web-app>
> <context-param>
> <param-name>contextConfigLocation</param-name>
> <param-value>classpath:resources/frontendContext.xml</param-value>
> </context-param>
> <listener>
> <listener-class>org.springframework.web.context.ContextLoaderListener
> </listener-class>
> </listener>
> <display-name>Spring</display-name>
> <servlet>
> <servlet-name>SpringFacade</servlet-name>
> <servlet-
> class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</
> servlet-class>
> <load-on-startup>1</load-on-startup>
> </servlet>
> <servlet-mapping>
> <servlet-name>SpringFacade</servlet-name>
> <url-pattern>/spring/*</url-pattern>
> </servlet-mapping>
> </web-app>
>
> quoting:
> "Any root resource classes or provider classes declared by Spring (in
> the XML configuration or by auto-wiring) will be automatically
> registered."
>
> I then packaged the war, and dumped the jersey and spring libs in
> jetty's shared lib/ directory.
>
> if I start the standalone jetty process with start.jar, though, I do
> not get the familiar
> "Root resource classes found" message.
> and if I try to access the defined urls I get a 503 error.
>
> I tryed tweaking the web.xml config, and adding @Singleton/_at_Component
> to my class, but i am unable to workaround this issue, any suggestion
> would be greatly appreciated, and excuse me if this was explained
> elsewhere.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>