【问题标题】:RESTEasy-Spring integrated webapp throws cryptic error: NoResourceFoundFailureRESTEasy-Spring 集成 webapp 抛出神秘错误:NoResourceFoundFailure
【发布时间】:2010-06-23 21:43:23
【问题描述】:

我正在开发一个同时使用 Spring Framework 和 RESTEasy 的 webapp。该应用程序已配置为发送 REST 请求有一段时间了,但我最近将其设置为也接收 REST 请求。我适当地配置了我的 web.xml,并且应用程序已经毫无问题地接收并处理了 REST 请求

这是一个 web.xml sn-p,详细说明了 REST 设置:

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

但是,当我在浏览器中浏览应用程序时,我不断在日志中看到这些异常:

    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

在我看来,REST 突然尝试处理所有请求,不仅仅是匹配 /AutomatedProcessing/rest/* URL 模式的请求。 我没有找到关于 NoResourceFoundFailure 异常的详细信息,或者 REST 为何会尝试处理其分配的 URL 模式之外的请求。该异常对用户来说不是致命的,但我认为它可能会破坏我不知道的东西。另外,日志中的异常永远不会有趣。我将非常感谢您对此异常的任何见解!

【问题讨论】:

    标签: java spring spring-mvc resteasy


    【解决方案1】:

    答案来自订购问题。

    我在 config.xml 文件中设置了另一个 UrlHandlerMapping:

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

    此映射没有“订单”属性,这意味着订单设置为默认值。 在 JBoss 包含的 sprincmvc-resteasy.xml 文件中可以找到处理映射 RESTEasy 资源的 ResteasyHandlerMapping。此映射也没有“顺序”属性。 这导致两个映射具有相同的排序优先级,并且由于 RESTEasy 映射在 XML 中排在第一位,因此它尝试处理所有请求。

    解决方案:将此属性添加到您的默认 url 映射器:

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

    【讨论】:

      猜你喜欢
      • 2012-01-24
      • 1970-01-01
      • 2019-07-05
      • 2013-12-03
      • 1970-01-01
      • 2012-12-27
      • 2018-02-23
      • 2015-03-13
      • 2017-04-20
      相关资源
      最近更新 更多