java - How to integrate Spring project with Jersey? -


what i'm trying integrate simple spring project jersey. web part on spring works fine. problem jersey. endpoint not work. when send request via rest client http 200 no error , in response body html login form, , returns me 404 not found if send request rest end poind via browser.

after debugging have found jersey's endpoint method not invoke.

here security configuration:

<security:http auto-config="true" use-expressions="true">     <security:access-denied-handler error-page="/login"/>     <security:intercept-url pattern="/j_spring_security_check" access="isanonymous()"/>     <security:intercept-url pattern="/login" access="isanonymous()"/>     <security:intercept-url pattern="/**" access="hasrole('role_user')"/>      <security:form-login             login-page='/login'             default-target-url="/"             authentication-failure-url="/login?error=true"/>      <security:logout             invalidate-session="true"             logout-success-url="/login?logout=true"             logout-url="/j_spring_security_logout"/>      <security:remember-me/>     <security:csrf disabled="false"/> </security:http>  <security:authentication-manager>     <security:authentication-provider>         <security:user-service>             <security:user                     name="jack"                     password="secret"                     authorities="role_user"/>         </security:user-service>     </security:authentication-provider> </security:authentication-manager> 

my web.xml config:

<context-param>     <param-name>contextconfiglocation</param-name>     <param-value>         /web-inf/dispatcherservlet.xml         /web-inf/securitycontext.xml     </param-value> </context-param> <servlet>     <servlet-name>jersey-servlet</servlet-name>     <servlet-class>org.glassfish.jersey.servlet.servletcontainer</servlet-class>     <init-param>         <param-name>javax.ws.rs.application</param-name>         <param-value>ua.alex.csrf.poc.rest.jaxrsapplication</param-value>     </init-param>     <load-on-startup>1</load-on-startup> </servlet>  <filter>     <filter-name>springsecurityfilterchain</filter-name>     <filter-class>org.springframework.web.filter.delegatingfilterproxy</filter-class>         </filter> <servlet-mapping>     <servlet-name>jersey-servlet</servlet-name>     <url-pattern>/api/*</url-pattern> </servlet-mapping> <filter-mapping>     <filter-name>springsecurityfilterchain</filter-name>     <url-pattern>/*</url-pattern> </filter-mapping> <servlet>     <servlet-name>mvc-dispatcher</servlet-name>     <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>     <init-param>         <param-name>contextconfiglocation</param-name>         <param-value>/web-inf/dispatcherservlet.xml</param-value>     </init-param>     <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping>     <servlet-name>mvc-dispatcher</servlet-name>     <url-pattern>/</url-pattern> </servlet-mapping> 

my dispatcher servlet looks this

<mvc:annotation-driven/> <context:component-scan base-package="de.miho.rest.test"/>  <mvc:resources mapping="/static/**" location="/static/" />  <bean class="org.springframework.web.servlet.view.internalresourceviewresolver">     <property name="prefix" value="/web-inf/jsp/"/>     <property name="suffix" value=".jsp"/> </bean> 

my jersey application looks this:

public class jaxrsapplication extends resourceconfig {      public jaxrsapplication() {         register(requestcontextfilter.class);         register(myresource.class);         register(jacksonfeature.class);     } } 

my jersey endpoint

@component @path("/api") public class myresource {      @autowired     private userservice service;      @get     @path("/greeting")     @produces(mediatype.application_json)     public response hello1() {         string username = service.getusername();         return response.ok("hello, " + username).build();     }      @get     @produces(mediatype.application_json)     public response hello2() {         return response.ok("hello again!").build();     } } 

how can fix this?


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -