在我的EJB项目中,我有这个Session Bean(Stateful):
@Stateful
public class StatefulShopCart implements StatefulShopCartLocal, Serializable {
private static final long serialVersionUID = 1L;
private transient HashMap<Integer, Integer> cantitati;
private Vector<ProdusDTO> produse;
/**
* Default constructor.
*/
public StatefulShopCart() {
try{
cantitati = new HashMap<Integer, Integer>();
produse = new Vector<ProdusDTO>();
}catch(Exception ex) {
System.out.println("[[[ //// Error \\\\ ]]]: "+ex.getMessage());
System.out.println(ex.getStackTrace());
}
}
@Override
public void Adauga(int id) {
try {
InitialContext ctx = new InitialContext();
StatelessInterogareRemote bean = (StatelessInterogareRemote) ctx
.lookup("java:global/ShopEAP/ShopEJB/StatelessInterogare");
...
}catch(Exception ex) {
System.out.println("[[[ Error ]]]: "+ex.getMessage());
System.out.println(ex.getStackTrace());
}
}
@Override
public Vector<ProdusDTO> ProduseAdaugate() {
return produse;
}
//@Override
public HashMap<Integer, Integer> CantitatiProduse() {
return cantitati;
}
@Override
public double ValoareTotala() {
StatelessCartLocal beanCart = null;
try {
InitialContext ctx = new InitialContext();
beanCart = (StatelessCartLocal) ctx
.lookup("java:global/ShopEAP/ShopEJB/StatelessCart");
}catch(Exception ex) {
System.out.println("+++ Error +++ " + ex.getMessage() + "\r\n" + ex.getStackTrace());
}
return beanCart.Calculeaza(produse, cantitati);
}
}
接口StatefulShopCartLocal:
@Local
public interface StatefulShopCartLocal {
void Adauga(int id);
Vector<ProdusDTO> ProduseAdaugate();
HashMap<Integer, Integer> CantitatiProduse();
double ValoareTotala();
}
当我在Application Client Project中进行查找时:
InitialContext ctx = new InitialContext();
beanCart = (StatelessCartLocal) ctx
.lookup("java:global/ShopEAP/ShopEJB/StatelessCart");
我收到此错误:
Nov 1, 2011 1:15:46 PM com.sun.enterprise.transaction.JavaEETransactionManagerSimplified initDelegates
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
Nov 1, 2011 1:15:47 PM com.sun.enterprise.naming.impl.SerialContext lookup
SEVERE: enterprise_naming.serialctx_communication_exception
Nov 1, 2011 1:15:47 PM com.sun.enterprise.naming.impl.SerialContext lookup
SEVERE:
java.rmi.MarshalException: CORBA BAD_PARAM 1330446342 Maybe; nested exception is:
java.io.NotSerializableException: ----------BEGIN server-side stack trace----------
org.omg.CORBA.BAD_PARAM: vmcid: OMG minor code: 6 completed: Maybe
at com.sun.corba.ee.impl.logging.OMGSystemException.notSerializable(OMGSystemException.java:990)
at com.sun.corba.ee.impl.logging.OMGSystemException.notSerializable(OMGSystemException.java:1005)
at com.sun.corba.ee.impl.orbutil.ORBUtility.throwNotSerializableForCorba(ORBUtility.java:753)
at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_abstract_interface(CDROutputStream_1_0.java:765)
at com.sun.corba.ee.impl.encoding.CDROutputObject.write_abstract_interface(CDROutputObject.java:709)
...
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at Main.runTest(Main.java:49)
at Main.main(Main.java:17)
Caused by: java.io.NotSerializableException: ----------BEGIN server-side stack trace----------
org.omg.CORBA.BAD_PARAM: vmcid: OMG minor code: 6 completed: Maybe
at com.sun.corba.ee.impl.logging.OMGSystemException.notSerializable(OMGSystemException.java:990)
at com.sun.corba.ee.impl.logging.OMGSystemException.notSerializable(OMGSystemException.java:1005)
...
我认为这是会话bean的序列化问题,但是我做错了什么?
感谢。
答案 0 :(得分:0)
我在这里有一个如何访问会话bean的示例:
来自远程客户端和本地客户端。
对于同一应用程序服务器上的本地访问,您不再需要初始上下文,可以通过@EJB直接注入ejb