好吧,完全搞不懂这个!
我正在使用 Spring 3.1.1 和 Hessian 4.0.7 部署到 Tomcat 6.0.29
我创建了一个简单的 Hessian 远程接口(interface),但我的测试一直失败;
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
testapp 肯定会到达 webapp 服务器,就好像我输入了 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
关于java - HessianConnectionException : (HTTP) 500 error when using Hessian 4. 0.7 和 Spring 3.1.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10553046/