| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 932 人关注过本帖
标题:[求助]哪位高手帮帮忙啊.EJB问题
只看楼主 加入收藏
night2005
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2005-3-16
收藏
 问题点数:0 回复次数:1 
[求助]哪位高手帮帮忙啊.EJB问题

Bean是: package warehouse;

import javax.ejb.SessionBean; import javax.ejb.SessionContext; import javax.ejb.CreateException; import java.util.Hashtable;

public class WareHouseBean implements SessionBean { SessionContext sessionContext; Hashtable stocks;

public void ejbCreate() throws CreateException { stocks=new Hashtable(); stocks.put("货物1",new Double(10)); stocks.put("货物2",new Double(60)); stocks.put("货物3",new Double(30)); stocks.put("货物4",new Double(50)); stocks.put("货物5",new Double(20)); }

public void ejbRemove() { }

public void ejbActivate() { }

public void ejbPassivate() { }

public void setSessionContext(SessionContext sessionContext) { this.sessionContext = sessionContext; }

public Hashtable getStocks() { return stocks; }

public void addStock(String stockName,double stockQuantity) throws StockException{ if(stockName.trim().length()==0) throw new StockException("货物的名字为空."); if(stocks.get(stockName)==null){ stocks.put(stockName,new Double(stockQuantity)); //而这里的方法在客户端测试有效. } else{ double oriStockQuantity=((Double)stocks.get(stockName)).doubleValue(); double sum=oriStockQuantity+stockQuantity; // stocks.put(stockName,new Double(sum)); //这里的方法在客户端测试时无效 } }

public void minusStock(String stockName,double stockQuantity) throws StockException{ if(stockName.trim().length()==0) throw new StockException("货物的名字为空."); if(stocks.get(stockName)==null) throw new StockException("找不到该货物."); double oriStockQuantity=((Double)stocks.get(stockName)).doubleValue(); if(stockQuantity>oriStockQuantity){ throw new StockException("该货物的库存不够."); }else{ stocks.put(stockName,new Double(oriStockQuantity-stockQuantity)); }

}

public void removeStock(String stockName) throws StockException{ if(stockName.trim().length()==0) throw new StockException("货物的名字为空."); if(stocks.get(stockName)==null) throw new StockException("找不到该货物."); stocks.remove(stockName); }

public double getStock(String stockName) throws StockException{ if(stockName.trim().length()==0) throw new StockException("货物的名字为空."); if(stocks.get(stockName)==null) throw new StockException("找不到该货物."); double stockQuantity=((Double)stocks.get(stockName)).doubleValue(); return stockQuantity; }

}

搜索更多相关主题的帖子: EJB 
2005-03-16 20:48
night2005
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2005-3-16
收藏
得分:0 
用JbuilderX 运行会报以下错误: <The Remote interface method: 'public abstract void warehouse.WareHouse.addStock(java.lang.String,double) throws warehouse.StockException,java.rmi.RemoteException' in EJB 'WareHouse' contains a parameter of type: 'double' which is not Serializable. Though the EJB 'WareHouse' has call-by-reference set to false, The Remote interface method: 'public abstract void warehouse.WareHouse.minusStock(java.lang.String,double) throws warehouse.StockException,java.rmi.RemoteException' in EJB 'WareHouse' contains a parameter of type: 'double' which is not Serializable. Though the EJB 'WareHouse' has call-by-reference set to false, this parameter is not Serializable and hence will be passed by reference. A parameter can be passed using call-by-value only if the parameter type is Serializable. Call-by-reference is not enabled for the EJB 'WareHouse'. The server will have better performance if it is enabled. To enable call-by-reference, set the enable-call-by-reference element to True in the weblogic-ejb-jar.xml deployment descriptor for this EJB
  • "WareHouse.jar": [J2EE:160127]ERROR: Could not delete previous archive: C:\Documents and Settings\Administrator.I-ROBOT\jbproject\WareHouse\WareHouse.jar 哪位前辈能帮忙看看啊.感激不尽.
2005-03-16 20:53
快速回复:[求助]哪位高手帮帮忙啊.EJB问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023359 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved