HessianConnectionException:使用 Hessian 4.0.7 和 Spring 3.1.1 时出现 (HTTP) 500 错误

2023-12-30

好吧,完全搞不懂这个!

我正在使用 Spring 3.1.1 和 Hessian 4.0.7 部署到 Tomcat 6.0.29

我创建了一个简单的 Hessian 远程接口,但我的测试一直失败;

Exception in thread "main" com.caucho.hessian.client.HessianConnectionException: 500: java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/client/remote/RemoteService
    at com.caucho.hessian.client.HessianURLConnection.sendRequest(HessianURLConnection.java:142)
    at com.caucho.hessian.client.HessianProxy.sendRequest(HessianProxy.java:283)
    at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:170)
    at $Proxy0.testConnection(Unknown Source)
    at com.qualificationcheck.testserver.TestServer.main(TestServer.java:15)
Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/client/remote/remoteservice
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at com.caucho.hessian.client.HessianURLConnection.sendRequest(HessianURLConnection.java:122)
    ... 4 more
Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/client/remote/RemoteService
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    at com.caucho.hessian.client.HessianURLConnection.sendRequest(HessianURLConnection.java:109)
    ... 4 more

我的界面是;

public interface QCClientRemoteService {
    public String testConnection(String param);
}

我的意思是;

public class QCClientRemoteServiceImpl implements QCClientRemoteService {
    public String testConnection(String param) {
        return "Recieved param of >" + param + "< successfully.";
    }
}

web.xml 包含;

<servlet>
    <servlet-name>remoting</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/config/web-app-config.xml</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>remoting</servlet-name>
    <url-pattern>/remote/*</url-pattern>
</servlet-mapping>

您看到的 web-app-config.xml 包含(通过从另一个 xml 导入的方式);

<bean id="remoteService" class="com.example.QCClientRemoteServiceImpl">
    <!-- any additional properties, maybe a DAO? -->
</bean>

<bean name="/RemoteService" class="org.springframework.remoting.caucho.HessianServiceExporter">
    <property name="service" ref="remoteService"/>
    <property name="serviceInterface" value="com.example.QCClientRemoteService"/>
</bean>

最后,一旦将其部署到 tomcat 中(开始时没有错误或警告),我将从另一个测试应用程序中的主方法中调用所有这些内容;

String url = "http://localhost:8080/client/remote/RemoteService";

HessianProxyFactory factory = new HessianProxyFactory();
QCClientRemoteService basic = (QCClientRemoteService) factory.create(QCClientRemoteService.class, url);

System.out.println(basic.testConnection("Input 123"));

有什么想法为什么这行不通吗?非常令人沮丧! 下面的人似乎也有同样的问题,但 Caucho 没有回复;http://forum.caucho.com/showthread.php?t=14906 http://forum.caucho.com/showthread.php?t=14906

testapp 肯定会到达 webapp 服务器,就像我 munge url 然后 testapp 抱怨 URL 不正确一样。但是,服务器根本没有记录任何日志或警告,甚至没有记录任何调试信息。 500 在实际的 Impl 之前就被扔掉了!?

最重要的是,上面相同的代码集成到我们在 Spring 2.0.5 上运行的旧服务器中,可以在 Burlap 2.1.12 上正常工作


问题是我有一个 spring-remoting 2.0.8 库,这在某个地方(默默地)发生冲突。删除它立即解决了我的问题。

只是为了明确起见,当我有以下库时,上面的配置和测试代码可以完美工作(注意,我假设 Hessian/Spring 解决方案并不需要所有这些库,它们在我的项目中用于其他用途,但为了完整性我已在此处列出);

spring-core-3.1.1.RELEASE
spring-asm-3.1.1.RELEASE
spring-web-3.1.1.RELEASE
spring-beans-3.1.1.RELEASE
spring-context-3.1.1.RELEASE
spring-aop-3.1.1.RELEASE
spring-webmvc-3.1.1.RELEASE
spring-context-support-3.1.1.RELEASE
spring-expression-3.1.1.RELEASE
hessian-4.0.7
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

HessianConnectionException:使用 Hessian 4.0.7 和 Spring 3.1.1 时出现 (HTTP) 500 错误 的相关文章

随机推荐