persistence@glassfish.java.net

Re: WARNING: "IOP00810257: (MARSHAL) Could not load class mypackage.MyClass"

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Tue, 17 Mar 2009 15:19:52 -0700

Hi Marian,

Can you check if commenting out serialVersionUID solves the problem?

Your problem can be result of bytecode weaving of one version of the class and
as-is use of the other.

thanks,
-marina

miro-zet wrote:
> Hi Mitesh,
>
> thanks for the answer. I have added ejb.jar to the WEB-INF/lib folder of the
> web application. I have also deployed ejb to the application server.
>
> When I created objects (in the web application) that should be persisted,
> all classes (Order, Product) were loaded by WebappClassLoader. These objects
> were sent to the EJB:
> orderDAO.addOrder(order)
>
> The order object is then probably serialized and sent to the implementation
> of the specific (OrderDAOImpl) EJB bean. EJBClassLoader then (I suppose)
> converts these serialized objects to the instances of classes (Order). Am I
> right?
>
> Is it possible to set, that both - the web application and also ejb use the
> same classloader?
> And back to my my original problem - I guess that it somehow related the
> serialization of the ArrayList.
> When I define in my EJB (OrderRemote) method:
>
> void doSomething(List<Product> list){
> ....do something
> }
>
> and in my client (web application) a create:
>
> orderDAO = (OrderRemote) ic.lookup("orderDAO");
> List<Product> list = new ArrayList<Product>()
> list.add(new Product())
> orderDAO.doSomething(list)
>
> glassfish throws an exception (Could not load class
> sk.kedros.osol.ejb.model.Product...) - even before doSometing method in the
> bean implementation is entered.
> Do you know why is this happening?
> Thanks,
> Marian
>
>
>
>
>
> Mitesh Meswani wrote:
>
>>Hi Marian,
>>
>>Are you positive that the sk.kedros.osol.ejb.model.Product class is
>>packaged such that the web application has visibility to it? The
>>marshalling code is just using the context class loader, which should be
>>set to the application class loader for the web invocation.
>>
>>Thanks,
>>Mitesh
>>miro-zet wrote:
>>
>>>Hi,
>>>
>>>i am developing a simple j2ee application that consists of one EJB jar
>>>and
>>>one web application war archive. For some reasons i cannot put them in
>>>one
>>>EAR application.
>>>EJB contains some persistent entities and stateless beans. To be more
>>>specific, i put here some code:
>>>
>>>@Entity
>>>public class Product implements Serializable {
>>>
>>>@Id
>>>@GeneratedValue(strategy = GenerationType.AUTO)
>>>private long id;
>>>
>>>private String name;
>>>
>>>private String description;
>>>
>>>private String enduserType;
>>>
>>>private String licenseType;
>>>
>>>private String productType;
>>>
>>>private long price;
>>>
>>>@ManyToMany(mappedBy = "productList")
>>>private List<Order> orderList;
>>>
>>>... some getters and setters
>>>}
>>>
>>>@Entity
>>>public class Order implements Serializable {
>>>
>>>
>>>private static final long serialVersionUID = 877211619374038853L;
>>>
>>>@Id
>>>@GeneratedValue(strategy = GenerationType.AUTO)
>>>private long id;
>>>
>>>@Temporal(TemporalType.DATE)
>>>private Date date;
>>>
>>>@OneToOne
>>>private EndUser endUser;
>>>
>>>private long userId;
>>>
>>>private long dealerId;
>>>
>>>
>>>@ManyToMany
>>>@JoinTable(name = "order_product", joinColumns = @JoinColumn(name =
>>>"order_id", referencedColumnName = "ID"), inverseJoinColumns =
>>>@JoinColumn(name = "product_id", referencedColumnName = "ID"))
>>>private List<Product> productList;
>>>
>>>...some getters and setters
>>>
>>>}
>>>
>>>EJB also contains method how to persist these entities:
>>>
>>>@Stateless(name = "orderDAO", mappedName = "orderDAO")
>>>public class OrderDAOImpl implements OrderLocal, OrderRemote {
>>>
>>>@PersistenceContext(name = "lportal")
>>>private EntityManager em;
>>>
>>>public void createOrder(Order order) {
>>>em.merge(order);
>>>}
>>>
>>>...some other methods
>>>
>>>}
>>>
>>>I can deploy EJB and webapplication withou any problems.
>>>
>>>Since EJB and web application arent in the same entreprise (EAR)
>>>application, i put the EJB jar file alse into the web application
>>>WEB-INF/lib directory. Everything works fine - I can persist, merge, find
>>>everything - apart from one case.
>>>
>>>The problem happens when I try to persist Order entity which contain List
>>>od
>>>products (ManyToMany relation). When the List is empty everything works.
>>>Let
>>>me again put here some code. Web application contains this class for the
>>>access to the EJB:
>>>
>>>public class DbUtils {
>>>
>>>private OrderRemote orderDAO;
>>>
>>>private ProductRemote productDAO;
>>>
>>>public DbUtils() {
>>>try {
>>>InitialContext ic = new InitialContext();
>>>orderDAO = (OrderRemote) ic.lookup("orderDAO");
>>>productDAO = (ProductRemote) ic.lookup("productDAO");
>>>} catch (Exception e) {
>>>e.printStackTrace();
>>>}
>>>}
>>>
>>>public void createOrder(){
>>>Order o = new Order();
>>>
>>>o.getProductList().add(productDAO.findProduct(Long.valueOf(10)));
>>>o.getProductList().add(productDAO.findProduct(Long.valueOf(20)));
>>>o.setDate(new Date());
>>>o.setDealerId(2);
>>>o.setUserId(3);
>>>
>>>orderDAO.createOrder(o);
>>>}
>>>
>>>}
>>>
>>>when the list is empty, everything works, but when the list contains some
>>>elements i get following error:
>>>
>>>WARNING: "IOP00810257: (MARSHAL) Could not load class
>>>sk.kedros.osol.ejb.model.Product"
>>>org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe
>>>at
>>>com.sun.corba.ee.impl.logging.ORBUtilSystemException.couldNotFindClass(ORBUtilSystemException.java:9679)
>>>at
>>>com.sun.corba.ee.impl.logging.ORBUtilSystemException.couldNotFindClass(ORBUtilSystemException.java:9694)
>>>at
>>>com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1042)
>>>at
>>>com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:896)
>>>at
>>>com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_abstract_interface(CDRInputStream_1_0.java:890)
>>>at
>>>com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_abstract_interface(CDRInputStream_1_0.java:880)
>>>at
>>>com.sun.corba.ee.impl.encoding.CDRInputStream.read_abstract_interface(CDRInputStream.java:511)
>>>at
>>>com.sun.corba.ee.impl.io.IIOPInputStream.readObjectDelegate(IIOPInputStream.java:386)
>>>at
>>>com.sun.corba.ee.impl.io.IIOPInputStream.readObjectOverride(IIOPInputStream.java:547)
>>>at java.io.ObjectInputStream.readObject(ObjectInputStream.java:345)
>>>at java.util.ArrayList.readObject(ArrayList.java:593)
>>>at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>at
>>>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>at
>>>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>at java.lang.reflect.Method.invoke(Method.java:597)
>>>at
>>>com.sun.corba.ee.impl.io.IIOPInputStream.invokeObjectReader(IIOPInputStream.java:1688)
>>>at
>>>com.sun.corba.ee.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1211)
>>>at
>>>com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:422)
>>>at
>>>com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:362)
>>>at
>>>com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:328)
>>>at
>>>com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.readRMIIIOPValueType(CDRInputStream_1_0.java:966)
>>>at
>>>com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1052)
>>>at
>>>com.sun.corba.ee.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:475)
>>>at
>>>com.sun.corba.ee.impl.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:1983)
>>>at
>>>com.sun.corba.ee.impl.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:2208)
>>>at
>>>com.sun.corba.ee.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1220)
>>>at
>>>com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:422)
>>>at
>>>com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:362)
>>>at
>>>com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:328)
>>>at
>>>com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.readRMIIIOPValueType(CDRInputStream_1_0.java:966)
>>>at
>>>com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1052)
>>>at
>>>com.sun.corba.ee.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:475)
>>>at
>>>com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl$14.read(DynamicMethodMarshallerImpl.java:368)
>>>at
>>>com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.readArguments(DynamicMethodMarshallerImpl.java:435)
>>>at
>>>com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:152)
>>>at
>>>com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
>>>at
>>>com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
>>>at
>>>com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
>>>at
>>>com.sun.corba.ee.impl.protocol.SharedCDRClientRequestDispatcherImpl.marshalingComplete(SharedCDRClientRequestDispatcherImpl.java:183)
>>>at
>>>com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:219)
>>>at
>>>com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:192)
>>>at
>>>com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152)
>>>at
>>>com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:225)
>>>at
>>>sk.kedros.osol.ejb.dao.__OrderRemote_Remote_DynamicStub.createOrder(sk/kedros/osol/ejb/dao/__OrderRemote_Remote_DynamicStub.java)
>>>at
>>>sk.kedros.osol.ejb.dao._OrderRemote_Wrapper.createOrder(sk/kedros/osol/ejb/dao/_OrderRemote_Wrapper.java)
>>>at sk.kedros.ejbtest.util.DbUtils.createOrder(DbUtils.java:36)
>>>at org.apache.jsp.index_jsp._jspService(index_jsp.java from :48)
>>>at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBa
>>>
>>>...stackstrace continues further...
>>>
>>>Can somebody explain me what i am doing wrong?
>>>I would like to repeat, that everything is working fine, when both EJB
>>>and
>>>webapplication are in the same EAR application, but i cannot do this in
>>>my
>>>project.
>>>
>>>Thanks in advance,
>>>Marian
>>>
>>
>>
>