4

好吧,这个根本想不通!

我正在使用 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 上运行得很好

4

2 回答 2

4

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

明确地说,当我有以下库时,上述配置和测试代码可以完美运行(注意,我假设 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
于 2012-05-15T07:46:08.040 回答
2

我的解决方案(在尝试了各种版本的 Hessian 之后)是使用:

org.springframework spring-remoting 2.0.8
org.springframework spring-webmvc/orm/(whatever) 3.1.1.RELEASE
com.caucho hessian 3.0.8

我在一个 Maven 项目中使用这些,所以这些是我正在使用的确切版本,问题就消失了。这绝对是 Spring 3.1.1 的版本。

对于它的价值,我将它与 Eclipse RCP 应用程序一起使用,它与 Eclipse RCP Hessian 包一起使用。

于 2012-05-14T17:53:40.150 回答