政府机关WebSphere中间件

WebSphere下通过JNDI查找EJB

软件名称:开发工具RAD7.5,服务器WS7.0软件版本:RAD7.5,WS7.0环境平台:Windows问题描述:客户端测试代码为    try {     java.util.Properties properties =new   java.util.Properties();      properties.put(...显示全部
软件名称:开发工具RAD7.5,服务器WS7.0

软件版本:RAD7.5,WS7.0


环境平台:Windows

问题描述:客户端测试代码为
    try {
     java.util.Properties properties =new   java.util.Properties();
     properties.put(InitialContext.PROVIDER_URL,"iiop://localhost:2811");
     properties.put(InitialContext.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");
     //BidManager bidManager=(BidManager) ctx.lookup("ejb/ActionBazaar3EAR/ActionBazaar3.jar/BidManagerBean#ejb.bean.actionbazaar.ejb.BidManager");
     Object bidManager=ctx.lookup("ejb/ActionBazaar3EAR/ActionBazaar3.jar/BidManagerBean#ejb.bean.actionbazaar.ejb.BidManager");
     if(bidManager == null){
      System.out.println("bidManager is null");
     }else{
      System.out.println("bidManager is not null");
      BidManager result = (BidManager)javax.rmi.PortableRemoteObject.narrow(bidManager,BidManager.class);
      System.out.println(result.addBid(bid));
      System.out.println(bid.getBidderName());
      System.out.println(bid.getItemName());
      System.out.println(bid.getItemPrice());
      
     }
    } catch (NamingException e) {
     
     e.printStackTrace();
    }
}
运行后报异常:
Exception in thread "P=257593:O=0:CT" java.lang.ClassCastException: Unable to load class: ejb.bean.actionbazaar.ejb._BidManager_Stub
其中:ctx ,bidManager 都不为空。就是让我加载._BidManager_Stub,可是我没有写这个,不知道问题出在哪?希望高手指点收起
参与5

查看其它 4 个回答le0911的回答

le0911le0911技术经理农信银资金清算中心
看你的代码应该是 跨JVM调用,需要用createEJBStubs.bat,重新生成一个你部署的EJB的jar,这样才能调用
银行 · 2010-12-06
浏览1037

回答者

le0911
技术经理农信银资金清算中心

le0911 最近回答过的问题

回答状态

  • 发布时间:2010-12-06
  • 关注会员:0 人
  • 回答浏览:1037
  • X社区推广