I'm running into a NullPointerException while iterating over a Collection, which was returned by a getXXX() method mapped to a one-to-many relationship.
Here's a snippet from my log:
15:55:12,873 DEBUG [TaskEJB] Executing SQL: SELECT ASR_ID, TASK_ID FROM ANNOTATION WHERE (TASK_ID=?)
15:55:12,881 ERROR [LogInterceptor] RuntimeException:
TaskEJBBean.getTaskAsrs() calls another TaskEJBBean method, which returns a Collection of AnnotationEJB objects; AnnotationEJB which has a CMP-mapped many-to-one relationship with TaskEJB. The SELECT statement in the log is executed when the getXXX() method is called; it returns a set of primary key values from the ANNOTATION table that match the foreign key from the TASK table into the ANNOTATION table.
So far, so good... But next, the TaskEJBBean.getTaskAsrs() gets an Iterator from the Collection, and enters a while (iter.hasNext()) loop. The first iter.hasNext() call returns true (as it should; the Collection should have one entry), but the first iter.next() call throws the NullPointerException.
Not sure what to make of this... I can't see anything in the log to indicate why this is happening.
Are you sure you use Local Interfaces for your CMR ?
This is a must.
I prefer to generate only the local interfaces for EntityBeans via XDoclet and always use session beans to access entity beans (SessionFascadePattern).