rest - Jersey integration with Spring MVC -
i want create website able work rest android application. these rest-calls want make use of seperate servlet
web.xml
<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="webapp_id" version="2.5"> <display-name>stage xt-i</display-name> <welcome-file-list> <welcome-file>/web-inf/jsp/index.jsp</welcome-file> </welcome-file-list> <listener> <listener-class> org.springframework.web.context.contextloaderlistener </listener-class> </listener> <servlet> <servlet-name>spring</servlet-name> <servlet-class> org.springframework.web.servlet.dispatcherservlet </servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> <context-param> <param-name>contextconfiglocation</param-name> <param-value> /web-inf/spring-servlet.xml /web-inf/spring-security.xml </param-value> </context-param> <!-- spring security --> <filter> <filter-name>springsecurityfilterchain</filter-name> <filter-class>org.springframework.web.filter.delegatingfilterproxy</filter-class> </filter> <filter-mapping> <filter-name>springsecurityfilterchain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>jersey web application</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.servletcontainer</servlet-class> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>be.kdg.teamf</param-value> </init-param> <init-param> <param-name>com.sun.jersey.api.json.pojomappingfeature</param-name> <param-value>true</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>jersey web application</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping> </web-app>
as can see al jersey information passed using url: /rest/* when want string using url: localhost:9999/rest/user/sample work perfectly. when use @autowired jersey nullpointer exception.
java class:
@path("/user") public class userrest { @autowired private userservice userservice; @context uriinfo uriinfo; // "injected" object. allows use information that's // part of incoming request. // could, example, header information, or requestor's address. @context request request; // basic "is service running" test @get @produces(mediatype.text_plain) public string respondasready() { return "demo service ready!"; } @get @path("sample") @produces(mediatype.application_json) public user getuserjson() { user u = userservice.listusers().get(0); system.out.println("returning person"); return u; } }
does see problem?
thanks in advance.
use spring jersey integration servlet
com.sun.jersey.spi.spring.container.servlet.springservlet