代码之家  ›  专栏  ›  技术社区  ›  Simon Tower

RESTEasy-Spring集成的webapp抛出了一个神秘的错误:NoResourceFoundFailure

  •  0
  • Simon Tower  · 技术社区  · 16 年前

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

    下面是一个web.xml片段,详细介绍了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
    

    我找不到关于这件事的任何细节 无资源失败

    1 回复  |  直到 16 年前
        1
  •  1
  •   Simon Tower    16 年前

    答案来自于订购问题。

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

    ResteasyHandlerMapping处理RESTEasy资源的映射,它位于JBoss包含的sprincmvc-RESTEasy.xml文件中。此映射也没有“order”属性。 这导致两个映射具有相同的排序优先级,并且由于RESTEasy映射在XML中是第一个,所以它尝试处理所有请求。

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

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