Bugs item #523560, was opened at 2002-02-27 12:09
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=376685&aid=523560&group_id=22866

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Thomas Phan (twhphan)
Assigned to: Nobody/Anonymous (nobody)
Summary: IllegalStateException in a valid place

Initial Comment:
When adding (setting) a relation after all beans have 
completed ejbCreate, JBoss throws 
IllegalStateException with message, A CMR field cannot 
be set or added to a relationship in ejbCreate; this 
should be done in the ejbPostCreate method instead 
[EJB 2.0 Spec. 10.5.2].

refer to: http://main.jboss.org/thread.jsp?
forum=46&thread=9761

Test case:
Try putting the following code (a business method) in 
a many-to-many entity bean, say UserBean:

public void setRoleData(Collection roles) throws 
Exception {
  RoleLocalHome roleLocalHome = getRoleLocalHome();
  getRoles().clear();
  for (Iterator i = roles.iterator(); i.hasNext() {
  addRole((RoleLocal) i.next());
}

where roles is a collection of RoleLocal. In order to 
get the exception, you may need to add more than 1 
RoleLocal in the collection. In my execution, I have 2 
elements in roles, JBoss deletes 2 elements from the 
database, then adds my first element in the 
collection, then throws the exception. I don't 
understand how this could happen. But without JBoss' 
checking code, I think my code works. It may happen 
because JBoss didn't set its state after the first add

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=376685&aid=523560&group_id=22866

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to