В моем EJB-проекте у меня есть Session Bean (с состоянием):
@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();
}
Когда я выполняю поиск в Project 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)
...
Я думаю, что это проблема с сериализацией этого сессионного компонента, но что я делаю неправильно?
Спасибо.