views:

195

answers:

1

I am working on a webapp that uses both the Spring Framework and RESTEasy. The app has been configured to send REST requests for some time, but I recently set it up to receive REST requests as well. I configured my web.xml appropriately, and the app has received and processed REST requests with no problem.

here is a web.xml snippet, detailing the REST setup:

<listener>
    <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>

<listener>
    <listener-class>
        org.jboss.resteasy.plugins.spring.SpringContextLoaderListener
    </listener-class>
</listener>

...

<servlet>
    <servlet-name>Resteasy</servlet-name>
    <servlet-class>
        org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
    </servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Resteasy</servlet-name>
    <url-pattern>/AutomatedProcessing/rest/*</url-pattern>
</servlet-mapping>

However, when I walk around the app in a browser, I keep seeing these exceptions in the log:

    org.jboss.resteasy.springmvc.ResteasyHandlerMapping - Resource Not Found: Could not find resource for relative :
org.jboss.resteasy.spi.NoResourceFoundFailure: Could not find resource for relative : /AccountManagement/login.do of full path: https://dev.produceredge.com:7002/AccountManagement/login.do

It seems to me like REST is suddenly trying to handle all requests, not just requests that match the /AutomatedProcessing/rest/* URL pattern. I have found no details on the NoResourceFoundFailure exception, or why REST would be trying to handle requests outside of its assigned URL pattern. The exception isn't fatal to the user, but I think it might be destroying something I don't know about. Plus, exceptions in the logs are never fun. I would greatly appreciate any insight on this exception!

+1  A: 

The answer came from an ordering issue.

I had another UrlHandlerMapping set up in a config.xml file:

<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="interceptors">
            <list>
                <ref bean="openPersistenceManagerInView"/>
            </list>
        </property>
        <property name="mappings">
            <value>
                **/AccountManagement/login.do=flowController
                **/AccountManagement/createAccount.do=flowController
                **/AccountManagement/manageAccount.do=flowController
            </value>
        </property>
        <property name="alwaysUseFullPath" value="true"/>
    </bean>

This mapping did not have an "order" property, meaning that the order was set at the default value. The ResteasyHandlerMapping, which handles mapping RESTEasy resources, was found in the JBoss included sprincmvc-resteasy.xml file. This mapping also did not have the "order" property. This lead to both mappings having the same ordering priority, and since the RESTEasy mapping came first in the XML, it tried to handle all requests.

Solution: add this property to your default url mapper:

<property name="order" value="0"/>
Getimoliver