我用的开发工具是RAD7.5,服务器是WebSphere Application Server7.0
java.util.Properties properties =new java.util.Properties();
properties.put(javax.naming.Context.PROVIDER_URL,"iiop://192.168.2.99:2811");
properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
InitialContext ctx = new InitialContext(properties);
if(ctx == null){
System.out.println("ctx is null");
}else{
System.out.println("ctx is not null");
}
System.out.println(ctx.getNameInNamespace());
BidManager bidManager=(BidManager) ctx.lookup("ejb.bean.actionbazaar.ejb.BidManager");
上面代码中红色的部分,我不知道错在哪,希望高手们指点一下,在线等,很急。默认端口本来是2809,可是在我机子上被占用了,分配成了2811,我就换成了2811.
异常的代码如下:[/color]Exception in thread "P=242750:O=0:CT" java.lang.ClassCastException: org.omg.stub.java.rmi._Remote_Stub incompatible with ejb.bean.actionbazaar.ejb.BidManager
at ejb.bean.actionbazaar.client.BidManagerClient.main(BidManagerClient.java:36)
------解决方案--------------------------------------------------------
PortableRemoteObject.narrow(lookup(...)); 呢?