Java SpringHTTP调用:构建服务器上的测试崩溃

Java SpringHTTP调用:构建服务器上的测试崩溃,java,spring,maven,http,invocation,Java,Spring,Maven,Http,Invocation,我通过SpringHTTP调用构建了一个API。我的config.xml如下所示: <bean id="apiUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="/remoteapi/boat">

我通过SpringHTTP调用构建了一个API。我的config.xml如下所示:

<bean id="apiUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="mappings">
        <props>
            <prop key="/remoteapi/boat">boatEndpointExporter</prop>
        </props>
    </property>
</bean>

<bean id="boatEndpointExporter" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
    <property name="service" ref="rApiBoatEndpointImpl"/>
    <property name="serviceInterface" value="xxx.RApiBoatEndpoint"/>
</bean>
测试在我的IDE中本地通过,并通过maven。 我可以手动调用api,也可以从客户端应用程序调用api

但我们的构建服务器一直说它不工作:

org.springframework.remoting.RemoteAccessException: Could not access HTTP invoker remote service at [http://xxxx/remoteapi/boat]; nested exception is org.apache.http.NoHttpResponseException: Did not receive successful HTTP response: status code = 404, status message = [Not Found]
at org.springframework.remoting.httpinvoker.HttpComponentsHttpInvokerRequestExecutor.validateResponse(HttpComponentsHttpInvokerRequestExecutor.java:233)
at org.springframework.remoting.httpinvoker.HttpComponentsHttpInvokerRequestExecutor.doExecuteRequest(HttpComponentsHttpInvokerRequestExecutor.java:149)
at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:138)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:194)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:176)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:144)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy36.ping(Unknown Source)

有什么解决问题的建议吗?

经过几天乏味的错误查找,我们找到了解决方案: 我们的构建服务器以不同于本地maven的顺序加载文件,因此我们永远无法在本地复制bug

我们的配置文件包括:

<mvc:default-servlet-handler/>

我们的构建服务器首先加载这个配置文件,然后加载api配置文件

解决方案是让我们的SimpleUrlHandler在一开始就注册,给它一个非常低的顺序:

<bean id="apiUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="order" value="-1" />
    <property name="mappings">
        <props>
            <prop key="/remoteapi/boat">boatEndpointExporter</prop>
        </props>
    </property>
</bean>

船运出口商

我认为这是您例外情况下的xxxx实际上很重要的情况。那是本地主机吗?如果没有,那是什么?当您在浏览器中打开该URL时会发生什么?它真的是HTTP404吗?当您的测试运行时,该URL上真的有服务器吗?@SergGr xxx是相应构建节点的名称,如下所示:。它在每个构建节点的context.xml中配置。测试通过maven运行,maven启动cargo。还有一些其他测试(在同一个包中)也需要运行的服务器,这些测试通过。因此,我认为这不是一般性的问题,而是关于我的测试设置/config的问题。通常我不能调用url,因为此服务器只运行(selenium)测试。但我会尝试在下次服务器构建时调用它。。。也许我会发现一些启发。@SergGr注意到一些奇怪的事情:http_response.log说:POST:/xxx/remoteapi/boat status:200,但access_日志说:(通过org.apache.catalina.valves.AccessLogValve)“POST/xxx/remoteapi/boat http/1.1”404
<bean id="apiUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="order" value="-1" />
    <property name="mappings">
        <props>
            <prop key="/remoteapi/boat">boatEndpointExporter</prop>
        </props>
    </property>
</bean>