好吧,这个根本想不通!
我正在使用 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 中(开始时没有错误或警告),我将从另一个测试应用程序的 main 方法中调用所有这些;
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 上运行得很好