Hi,
I just got my first EJB working, yay! It's a very simple entity bean
with container managed persistence. Everything has worked so far, but I
noticed something I thought was odd.
The primary key is just an integer. If I construct a PK with a value
that isn't in the database, and then call findByPrimaryKey I'm not
seeing an exception thrown. Therefore my client continues on and I get a
ServerException when I try to call a "business method" on the bean
reference.
While the EJB spec seems to leave it up to the application as to what
exceptions are thrown by find methods, in the case of container managed
persistence I had expected that javax.ejb.ObjectNotFoundException would
be thrown. With the behaviour I'm seeing, I can't see an easy way to
work out if the find worked or not, other than actually trying to use
the bean. Any thoughts?
I'm using Jonas 1.5. Here are the gory details:
Thrown by the client:
Exception in thread "main" java.rmi.ServerException: RemoteException occurred in
server thread; nested exception is:
java.rmi.RemoteException: Failed to load bean from database; nested exception
is:
java.rmi.RemoteException: Failed to load bean from database
java.rmi.RemoteException: Failed to load bean from database; nested exception is:
java.rmi.RemoteException: Failed to load bean from database
java.rmi.RemoteException: Failed to load bean from database
at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:246)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:342)
at org.objectweb.jonas.rmifilters.RemoteStub.invoke(RemoteStub.java:88)
at
com.vetit.vzoo.JOnASNameBeanName_Stub.getName(JOnASNameBeanName_Stub.java:94)
at com.vetit.vzoo.NameTest.findName(NameTest.java:58)
at com.vetit.vzoo.NameTest.main(NameTest.java:30)
The relevant bit of NameTest.java:
57: Name name = nameHome.findByPrimaryKey(new NamePK(id));
58: System.out.println("Found name with id " + id + ": " + name.getName());
--
Lachlan O'Dea <mailto:[EMAIL PROTECTED]> Computer Associates Pty Ltd
Webmaster Vet - Anti-Virus Software
http://www.vet.com.au/
"With our combined strength, we can end this destructive
conflict and bring order to the galaxy." - Darth Vader