首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

Http invoker求圣人指点

2012-09-25 
Http invoker求高人指点Http Invoker是否能返回对象?代码如下PrintApplay.java(服务端与客户端的都一样)Ja

Http invoker求高人指点
Http Invoker是否能返回对象?
代码如下

PrintApplay.java(服务端与客户端的都一样)

Java code
public class PrintApply implements Serializable {    private static final long serialVersionUID = 1L;    private String yybs;    private String sjbbs;    private String fqbs;        public String getYybs() {        return yybs;    }    public void setYybs(String yybs) {        this.yybs = yybs;    }    public String getSjbbs() {        return sjbbs;    }    public void setSjbbs(String sjbbs) {        this.sjbbs = sjbbs;    }    public String getFqbs() {        return fqbs;    }    public void setFqbs(String fqbs) {        this.fqbs = fqbs;    }

服务端interface
Java code
import com.hxsmart.sicard.si.model.PrintApply;public interface RemoteService {        public PrintApply receivePrintApply(String name,String idcd,String bankId,String nodeName,String nodeId);}

服务端实现类
Java code
public class RemoteServiceImpl implements RemoteService {         private ClientService clientService;         @Override         public PrintApply receivePrintApply(String name, String idcd, String bankId,            String nodeName, String nodeId) {                StringBuffer sb = new StringBuffer();                sb.append(name).append(idcd).append(bankid).append(nodeName).append(nodeId);                List<PrintApply> list = clientService.sentMsg(sb.toString());        PrintApply printApply = list.get(0);        return printApply;         }}

客户端调用服务端接口
Java code
public class RemoteExchgsvrServerImpl implements RemoteExchgsvrServer {    @Override    public List PrintInfoApply(String idcd, String name, String bankId,            String nodeId, String nodeName) {        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("remote.xml");                try {            RequestService service = (RequestService) applicationContext.getBean("remoteService");            PrintApply printApply = service.receivePrintApply(name, idcd, bankId, nodeName, nodeId);        } catch (Exception e) {            e.printStackTrace();        }        return null;    }}

报错代码:
Java code
PrintApply printApply = service.receivePrintApply(name, idcd, bankId, nodeName, nodeId);

客户端报错信息:
Caused by: java.lang.ClassNotFoundException: com.hxsmart.sicard.si.model.PrintApply
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604)
at org.springframework.remoting.rmi.CodebaseAwareObjectInputStream.resolveClass(CodebaseAwareObjectInputStream.java:79)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)


at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.doReadRemoteInvocationResult(AbstractHttpInvokerRequestExecutor.java:225)
at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.readRemoteInvocationResult(AbstractHttpInvokerRequestExecutor.java:174)
at org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor.doExecuteRequest(SimpleHttpInvokerRequestExecutor.java:64)
at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:69)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:146)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:120)
... 86 more


客户端是没有任何地方声明或使用com.hxsmart.sicard.si.model.PrintApply这个的,确定没有,可是为什么提示找不到这个呢?求解!

[解决办法]
在你的xml中是否有声明 PrintApply 这个类,如果没有你客户端肯定会报java.lang.ClassNotFoundException: com.hxsmart.sicard.si.model.PrintApply

因为这个类应该是在你的服务端的,但是你现在客户端要用到,不声明的话一定会报错

热点排行