File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Any idea what's going on? NoSuchObjectLocalException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Any idea what Watch "Any idea what New topic

Any idea what's going on? NoSuchObjectLocalException

Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
I have a bean "Orders" which has a collection of OrderItem beans. The OrderItem has a compound primary key of: OrderId + ProductId. It also has a quantity attribute.

When i create the orders in an init method, and then check them in that same method, everything is fine.

When I call a "findOrdersByCustomer" method, it finds a collection of orders and then when I'm looping through the OrderItems for the first order, the following occurs:

1. I get the item via;
2. I pull the product out of the orderitem via orderItem.getProduct();
3. I print out the primary key for the item via orderItem.getPrimaryKey();
3a. It prints out (for primary key): OrderId[3],ProductId[2]
4. I call orderItem.getQuantity()

At #4, it throws:
javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=OrderId[3],ProductId[2]

What's going on? Just one method call earlier, the object returned that same exact primary key! Does anyone have any idea what I might be doing wrong?

Plus, if I do findByPrimaryKey(), it finds the OrderItem, but again, if I call getQuantity() it throws that same exception! What could be going on here?
[ September 22, 2005: Message edited by: Dan Bizman ]
wood burning stoves
subject: Any idea what's going on? NoSuchObjectLocalException
It's not a secret anymore!