简体   繁体   中英

How to Send Object to EJB through Remote Interface

Hello i have a Web Application Which has Class Library which with remote interfaces, EJB module with beans and Struts 2 web application. Whenever i try to send a custom object to EJB through Remote Interface i get following Exception.

javax.ejb.EJBException: java.rmi.MarshalException: CORBA MARSHAL 1330446393 Maybe; nested exception is: 
    org.omg.CORBA.MARSHAL: ----------BEGIN server-side stack trace----------
org.omg.CORBA.MARSHAL: WARNING: 00810057: Could not load class newp.Employee  vmcid: OMG  minor code: 57 completed: Maybe
    at com.sun.proxy.$Proxy225.couldNotFindClass(Unknown Source)

Can not pass any custom object. Classes implements serializable. IT works fine when retrieve objects from ejb through interface. Can anybody help?

as @Spyros k said you should first include your custom classes structure into your server. This means simply that you must put CustomObject.java classes of your own into your server. You should know that sending object by EJB is not sending exact class object , it's just a reference for server which is needed to be cast a class type. All of the Java standard classes are in server because of JVM but if you have a custom class sending a reference is not enough and you must have the class structure on the other side to cast the received reference . So in server side you should have something like this :

YourCustomObject obj = (YourCustomObject) EjbObject.returnRefernce();

If you don't have YourCustomObject.java class on the other side so how could you cast to it? I suggest read about RMI to find more about this structure.

The class newp.Employee should be included in the classpath of the Server side. The server needs the class definition to deserialize the input.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM