Hessian中的Connection refused: connect 问题
现在在学习 Hessian 。遇到了问题,请大家帮忙。
我首先写了一个 接口 :IBasic 。代码:
public interface IBasic {
/**
* 测试字符串
* @return
*/
public String hello();
}
一个实现类 : BasicService 。代码:
public class BasicService implements IBasic {
private String hello = "Hello word !";
public String hello() {
// TODO Auto-generated method stub
return hello;
}
}
一个 client 端 测试 :BasicClient 。代码:
public class BasicClient {
/**
* @param args
* @throws MalformedURLException
*/
public static void main(String[] args) throws MalformedURLException {
// TODO Auto-generated method stub
String url = "http://127.0.0.1:8099/common/hello";
HessianProxyFactory factory = new HessianProxyFactory();
IBasic basic = (IBasic) factory.create(IBasic.class, url);
System.out.println("Hello : " + basic.hello());
}
}
在 WEB . XML 中的配置 :
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class>
<init-param>
<param-name>home-class</param-name>
<param-value>imp.BasicService</param-value>
</init-param>
<init-param>
<param-name>home-api</param-name>
<param-value>interfaces.IBasic</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
代码和配置就是这样的了,可是,当我运行的 时候,就会 抛出 这样的异常 :
Exception in thread "main" com.caucho.hessian.client.HessianRuntimeException: java.net.ConnectException: Connection refused: connect
at $Proxy0.getCar(Unknown Source)
Caused by: java.net.ConnectException: Connection refused: connect
我以为是 端口号的问题,可是当我 把端口号改为 8080 ,又抛出 FileNotFound 这样的异常。。。。。。
我没有办法 了, 请各位大侠帮小弟 分析分析吧。。。。。。。。。。。
谢谢~~~~~~~~~~~~~~~~~~~~~~~~