1
votes

I have an application with GWT on frontend and Spring on backend. I am trying to add one simple page with Spring MVC but there is some problem with mapping.

I have created controller:

@Controller
@RequestMapping("/jobrunner.rpc")
public class JobRunnerController {

    @RequestMapping(method = RequestMethod.GET)
    public String getStartPage() {
        return "jobrunner";
    }
}

When I launch my app, there is a line about mapping: [DefaultAnnotationHandlerMapping.registerHandler(411)] Mapped URL path [/jobrunner.rpc] onto handler 'jobRunnerController'

But when I am trying to open this page, I have 404 page and next line in log: [PageNotFound.noHandlerFound(947)] No mapping found for HTTP request with URI [/rds/jobrunner.rpc] in DispatcherServlet with name 'spring-rpc'

Maybe, there is a problem in web.xml and its filters? Here it is:

<session-config>
    <session-timeout>15</session-timeout>
</session-config>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
    <listener-class>com.db.gbs.gbsapps.rds.backend.servlet.listener.StartupListener</listener-class>
</listener>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring/application-config.xml</param-value>
</context-param>

<filter>
    <filter-name>AuthenticationFilter</filter-name>
    <filter-class>com.gft.riaframework.backend.api.filters.AuthenticationFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>AuthenticationFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>



<filter>
    <filter-name>AuthorizationFilter</filter-name>
    <filter-class>com.db.gbs.gbsapps.rds.backend.services.security.impl.live.CustomAuthorizationFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>AuthorizationFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<filter>
    <filter-name>ExpiryFilter</filter-name>
    <filter-class>com.db.gm.adk.server.filter.ExpiryFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>ExpiryFilter</filter-name>
    <url-pattern>*.html</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>ExpiryFilter</filter-name>
    <url-pattern>*.css</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>ExpiryFilter</filter-name>
    <url-pattern>*.js</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>ExpiryFilter</filter-name>
    <url-pattern>*.gif</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>ExpiryFilter</filter-name>
    <url-pattern>*.png</url-pattern>
</filter-mapping>

<filter>
    <filter-name>GZIPFilter</filter-name>
    <filter-class>com.db.gm.adk.server.filter.GZIPFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>GZIPFilter</filter-name>
    <url-pattern>*.html</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>GZIPFilter</filter-name>
    <url-pattern>*.css</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>GZIPFilter</filter-name>
    <url-pattern>*.js</url-pattern>
</filter-mapping>

<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> 

<filter>
    <filter-name>NoCacheFilter</filter-name>
    <filter-class>com.db.gbs.gbsapps.rds.backend.servlet.filter.NoCacheFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>NoCacheFilter</filter-name>
    <url-pattern>/index.html</url-pattern>
</filter-mapping>

<servlet>
    <servlet-name>spring-rpc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>spring-rpc</servlet-name>
    <url-pattern>*.rpc</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>eventServiceImpl</servlet-name>
    <servlet-class>de.novanic.eventservice.service.EventServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>eventServiceImpl</servlet-name>
    <url-pattern>/main/gwteventservice</url-pattern>
</servlet-mapping>

<error-page>
    <error-code>500</error-code>
    <location>/WEB-INF/jsp/error.jsp</location>
</error-page>

<error-page>
    <error-code>503</error-code>
    <location>/WEB-INF/jsp/error.jsp</location>
</error-page>

<error-page>
    <error-code>403</error-code>
    <location>/WEB-INF/jsp/403.jsp</location>
</error-page>

<error-page>
    <error-code>404</error-code>
    <location>/WEB-INF/jsp/404.jsp</location>
</error-page>

<error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/WEB-INF/jsp/error.jsp</location>
</error-page>

Thanks in advance for youe advice.

1

1 Answers

1
votes

Most likely is an issue with the suffix you use ".rpc"

Try doing the mapping without the ".rpc"

Have a look to the spring reference at

http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc-ann-requestmapping-suffix-pattern-match

Path Pattern Matching By Suffix

By default Spring MVC automatically performs "." suffix pattern matching so that a controller mapped to /person is also implicitly mapped to /person.. This allows indicating content types via file extensions, e.g. /person.pdf, /person.xml, etc. A common pitfall however is when the last path segment of the mapping is a URI variable, e.g. /person/{id}. While a request for /person/1.json would correctly result in path variable id=1 and extension ".json", when the id naturally contains a dot, e.g. /person/[email protected] the result does not match expectations. Clearly here ".com" is not a file extension.

The proper way to address this is to configure Spring MVC to only do suffix pattern matching against file extensions registered for content negotiation purposes. For more on this, first see Section 17.16.4, “Content Negotiation” and then Section 17.16.9, “Path Matching” showing how to enable suffix pattern matching along with how to use registered suffix patterns only.