0

I have been facing an issue with exposing the REST Api using Spring REST.

The api call reaches the invocation handler and properly identifies the method and beans.

But there is no further execution after the target method is invoked

2016-01-23 17:39:39,431 TRACE [o.s.w.s.DispatcherServlet] (http-bio-8080-exec-4:) Bound request context to thread: org.apache.catalina.connector.RequestFacade@46b2fc7d

2016-01-23 17:39:39,431 DEBUG [o.s.w.s.DispatcherServlet] (http-bio-8080-exec-4:) DispatcherServlet with name 'appServlet' processing GET request for [/rest/api/t1]

2016-01-23 17:39:39,431 TRACE [o.s.w.s.DispatcherServlet] (http-bio-8080-exec-4:) Testing handler map [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping@5ccada5] in DispatcherServlet with name 'appServlet'

2016-01-23 17:39:39,431 DEBUG [o.s.w.s.m.m.a.RequestMappingHandlerMapping] (http-bio-8080-exec-4:) Looking up handler method for path /t1

2016-01-23 17:39:39,431 TRACE [o.s.w.s.m.m.a.RequestMappingHandlerMapping] (http-bio-8080-exec-4:) Found 1 matching mapping(s) for [/t1] : [{[/t1]}]

2016-01-23 17:39:39,431 DEBUG [o.s.w.s.m.m.a.RequestMappingHandlerMapping] (http-bio-8080-exec-4:) Returning handler method [public java.lang.String com.tcl.gvg.rest.controller.TestController.test()]

2016-01-23 17:39:39,431 DEBUG [o.s.b.f.s.DefaultListableBeanFactory] (http-bio-8080-exec-4:) Returning cached instance of singleton bean 'testController'

2016-01-23 17:39:39,432 TRACE [o.s.w.s.DispatcherServlet] (http-bio-8080-exec-4:) Testing handler adapter [org.springframework.data.rest.webmvc.RepositoryRestHandlerAdapter@6ca97211]

2016-01-23 17:39:39,432 TRACE [o.s.w.s.DispatcherServlet] (http-bio-8080-exec-4:) Testing handler adapter [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter@437aae26]

2016-01-23 17:39:39,432 DEBUG [o.s.w.s.DispatcherServlet] (http-bio-8080-exec-4:) Last-Modified value for [/rest/api/t1] is: -1

2016-01-23 17:39:39,433 TRACE [o.s.w.s.m.m.a.ServletInvocableHandlerMethod] (http-bio-8080-exec-4:) Invoking [TestController.test] method with arguments []

Below is my web.xml.

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
           classpath:applicationContext.xml
        </param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
        <async-supported>true</async-supported>
    </servlet>
    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/api/*</url-pattern>
    </servlet-mapping>
    <filter>
        <filter-name>hibernateFilter</filter-name>
        <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
        <init-param>
            <param-name>entityManagerFactoryBeanName</param-name>
            <param-value>EntityManagerFactoryCMDB</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>hibernateFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

Here is the servlet-context.xml

<context:property-placeholder
    location="classpath:/application_config.properties"
    system-properties-mode="OVERRIDE" />
<!-- Enables the Spring MVC @Controller programming model -->
<!-- <annotation-driven /> -->
<beans:bean
    class="org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration" />
<beans:bean id="conversionService"
    class="org.springframework.format.support.FormattingConversionServiceFactoryBean" />
<beans:bean
    class="org.springframework.data.repository.support.DomainClassConverter">
    <beans:constructor-arg ref="conversionService" />
</beans:bean>
<annotation-driven conversion-service="conversionService">
    <argument-resolvers>
        <beans:bean id="pageableResolver"
            class="org.springframework.data.web.PageableHandlerMethodArgumentResolver" />
        <beans:bean id="sortResolver"
            class="org.springframework.data.web.SortHandlerMethodArgumentResolver" />
    </argument-resolvers>
    <message-converters>
        <beans:bean
            class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
            <beans:property name="objectMapper" ref="jacksonObjectMapper" />
        </beans:bean>
    </message-converters>
</annotation-driven>

<beans:bean id="jacksonObjectMapper" class="com.tcl.gvg.test.rest.config.MyJsonMapper" />

<!-- Handles HTTP GET requests for /resources/** by efficiently serving 
    up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources 
    in the /WEB-INF/views directory -->
<beans:bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".jsp" />
</beans:bean>

<context:component-scan base-package="com.tcl.gvg.test" />

<!--Enable AOP -->
<aop:aspectj-autoproxy proxy-target-class="true" />

Thanks in advance.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
iDroid
  • 1,140
  • 1
  • 13
  • 30

0 Answers0