RESTEasy-Spring 集成 web 应用程序抛出神秘错误:NoResourceFoundFailure

发布于 2024-09-07 12:07:37 字数 1555 浏览 2 评论 0原文

我正在开发一个同时使用 Spring 框架和 RESTEasy 的 Web 应用程序。该应用程序已配置为发送 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

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

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

断念 2024-09-14 12:07:37

答案来自订购问题。

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

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

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

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

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"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文