浏览 6352 次
该帖已经被评为新手帖
|
|
---|---|
作者 | 正文 |
发表时间:2007-06-15
请教一下们,在此先谢了!! 程序完整代码: 1,对外暴露的业务接口 package com.neoman.hession; public interface BasicAPI { public String hello(); } 2,服务器端实现 package com.neoman.hession; import com.caucho.hessian.server.HessianServlet; public class BasicService extends HessianServlet implements BasicAPI { private String str="Hello World"; public void setStr(String str) { this.str = str; } public String hello() { // TODO Auto-generated method stub return str; } } 3,客户端测试代码 package com.neoman.hession; import java.net.MalformedURLException; import com.caucho.hessian.client.HessianProxyFactory; public class Test { /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { // TODO Auto-generated method stub String url = "http://localhost:8080/HessionTest/hello"; HessianProxyFactory factory = new HessianProxyFactory(); BasicAPI basic=(BasicAPI) factory.create(BasicAPI.class, url); System.out.println("hello(): " + basic.hello()); } } 4, web.xml配置 <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <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>com.neoman.hession.BasicService</param-value> </init-param> <init-param> <param-name>home-api</param-name> <param-value>com.neoman.hession.BasicAPI</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>hello</servlet-name> <url-pattern>/hello</url-pattern> </servlet-mapping> </web-app> 报的错误:Exception in thread "main" com.caucho.hessian.client.HessianRuntimeException: com.caucho.hessian.io.HessianProtocolException: 500: java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/HessionTest/hello at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:183) at $Proxy0.hello(Unknown Source) at com.neoman.hession.Test.main(Test.java:21) Caused by: com.caucho.hessian.io.HessianProtocolException: 500: java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/HessionTest/hello at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:167) ... 2 more Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/HessionTest/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:494) at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1227) at java.security.AccessController.doPrivileged(Native Method) at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1221) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:910) at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:149) ... 2 more Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/HessionTest/hello at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1174) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:367) at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:140) ... 2 more 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-06-15
http://localhost:8080/HessionTest/hello
# <servlet-mapping> # <servlet-name>hello</servlet-name> # <url-pattern>/hello</url-pattern> # </servlet-mapping> mapping is wrong ... look again... |
|
返回顶楼 | |
发表时间:2007-06-15
我的工程名字是HessianTest
那映射写成:<url-pattern>/HessianTest/hello</url-pattern> 么??? 能否直接点,谢谢啦 |
|
返回顶楼 | |
发表时间:2007-06-18
老田...看来又是JNDI问题,那么象EJB的....
|
|
返回顶楼 | |
发表时间:2007-11-28
web.xml改成:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <servlet> <servlet-name>hello</servlet-name> <servlet-class>com.neoman.hession.BasicService </servlet-class> </servlet> <servlet-mapping> <servlet-name>hello</servlet-name> <url-pattern>/hello</url-pattern> </servlet-mapping> </web-app> |
|
返回顶楼 | |