最近学习hessian,没想到刚开始就碰到解决不了的事情,一个helloworld都没弄出
。以下是相关代码:
新建web project为hessian,将hessian-4.0.7.jar导入,服务端有接口Hello和实现HelloImpl,客户端测试代码ClientTest(客户端与服务端为同一project)以及web.xml配置如下:
Hello.java:
package server;
public interface Hello {
public void say(String str);
}
HelloImpl.java:
package server;
public class HelloImpl implements Hello {
@Override
public void say(String str) {
System.out.println("hello," + str + "!");
}
}
package client;
import server.Hello;
import com.caucho.hessian.client.HessianProxyFactory;
public class ClientTest {
public static void main(String [] args){
String url = "http://localhost:8080/hessian/hello";
HessianProxyFactory factory = new HessianProxyFactory();
try{
Hello hello = (Hello) factory.create(Hello.class,url);
hello.say("hessian");
}catch(Exception e){
e.printStackTrace();
}
}
}
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class>
<init-param>
<param-name>service-class</param-name>
<param-value>server.Hello</param-value>
</init-param> <!--init-param里可以做哪些相关配置-->
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/helloworld</url-pattern> <!--该项配置有何用?-->
</servlet-mapping>
</web-app>
问题:将hessian发布后,测试ClientTest后就出现com.caucho.hessian.client.HessianConnectionException异常,url(http://localhost:8080/hessian/hello)中应该没错吧,hessian为应用名,hello为<servlet-name>中配置,具体异常如下:
com.caucho.hessian.client.HessianConnectionException: HessianProxy cannot connect to 'http://localhost:8080/hessian/hello
at com.caucho.hessian.client.HessianURLConnection.sendRequest(HessianURLConnection.java:139)
at com.caucho.hessian.client.HessianProxy.sendRequest(HessianProxy.java:283)
at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:170)
at $Proxy0._hessian_getAttribute(Unknown Source)
at com.caucho.hessian.client.HessianProxyFactory.create(HessianProxyFactory.java:374)
at client.ClientTest.main(ClientTest.java:12)
Caused by: java.io.FileNotFoundException: http://localhost:8080/hessian/hello
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1296)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1290)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:944)
at com.caucho.hessian.client.HessianURLConnection.sendRequest(HessianURLConnection.java:122)
... 5 more
Caused by: java.io.FileNotFoundException: http://localhost:8080/hessian/hello
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1239)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
at com.caucho.hessian.client.HessianURLConnection.sendRequest(HessianURLConnection.java:109)
... 5 more
还请各位路过指点一下小弟,感谢!!!
分享到:
相关推荐
想学习Hessian的同志们,这个是一个简单的demo。比较简单,不过能够加深对Hessian的理解
这是一个Hessian入门学习的实例,程序包是一个web工程,使用intellij idea + Maven开发,其中通过两个方式展示了使用Hessian实现RMI的原理,一个是访问jsp页面,一个是在代码中手工创建client。对于Hessian Servlet...
hessian学习实例,hessian框架例子,与Spring集成。包括了server端和client端
Hessian的学习笔记
NULL 博文链接:https://wo-niu.iteye.com/blog/2200720
该案例有hessian java python,该案例有hessian java python,该案例有hessian java python
Hessian多个版本下载,包括Hessian3.1.6,Hessian3.2.1,Hessian4.0.7
hessian源码
hessian资料3hessian资料3hessian资料3hessian资料3hessian资料3
NULL 博文链接:https://qinghua0208.iteye.com/blog/493516
NULL 博文链接:https://otom31.iteye.com/blog/1175539
Hessian服务端 入门程序
NULL 博文链接:https://paopaochao3.iteye.com/blog/550771
基于Hessian的冠状动脉血管造影分割方法
1、开发环境:eclipse3.1 + jdk1.5; 2、样例说明: 1)spring + hessian; 2)hessian。 3、样例内容: 1)HashMap传递; 2)简单对象传递; 3)异常处理
dubbo-hessian协议http请求demo
Hessian android客户端异步请求访问包
多尺度hessian滤波器,图像增强,参考frangi的论文
hessian 服务端 客户端 可运行
Hessian案列代码