Hello All:
I have run into an unexpected problem that is causing us some grief. It
seems that Castor persistent objects are not serializable. I am trying
to return an object as the result of an EJB session bean method call.
In my Session EJB, I have something like the following:
public Pick getPick(boolean assign) throws java.rmi.RemoteException {
Pick pick = null;
db.begin();
...
pick = (Pick)db.load(Pick.class, oid);
db.commit();
return(pick);
}
My Pick class is a Plain Old Java Object, looking something like this:
public class Pick implements Serializable {
public long oid;
public Folder folder;
public Pick() {
this.oid = System.currentTimeMillis();
this.folder = null;
}
public long getOid() {
return oid;
}
public void setOid(long oid) {
this.oid = oid;
}
public Folder getFolder() {
return folder;
}
public void setFolder(Folder folder) {
this.folder = folder;
}
}
The problem is simply that the Pick object, when created within a
transaction is not serializable. I get this stack trace:
java.lang.reflect.UndeclaredThrowableException
at $Proxy20.getPick(Unknown Source)
at voxware.app.ejb.DispatchTest.main(DispatchTest.java:43)
Caused by: java.io.NotSerializableException: voxware.app.jdo.Pick
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
at java.rmi.MarshalledObject.<init>(MarshalledObject.java:92)
at
org.openejb.core.ivm.BaseEjbProxyHandler.copyObj(BaseEjbProxyHandler.java:413)
at
org.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:312)
at
org.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:89)
... 2 more
If I simply "new up" a non-persistent Pick object and return it from my
getPick() Session EJB method, No Problem.
Does this mean that Castor objects, even really simple ones, are not
serializable? I can see that if I were to use a transient Pick object
as a data transfer object and return that from getPick() that I could
get this to work. But there would be a lot of copying needed in the
bean. Is there a better way to deal with this? Is it possible to
transform a Castor persistent object into transient one so that it can
be serialized?
Thanks in advance,
craig vanderborgh
voxware incorporated
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev