Forums Register Login

How to access CMR-fields in SessionBeans

+Pie Number of slices to send: Send
Hi !
Iam accessing a cmr-field in an entity bean,inside a session bean.But iam thrown an IllegalStateException while doing this.The error message was 'attempted to access a collection valued cmr-field outside the scope of transaction.'
Can anybody help me solving this?
Thank You --- Tina
[ November 23, 2003: Message edited by: tina kinger ]
+Pie Number of slices to send: Send
Make sure your Session bean methods and your Entity bean methods all have a transaction attribute of "required".
Kyle
+Pie Number of slices to send: Send
Thank you
It worked well.
I have previously set the attribute value of the sessionbean to 'supports'.
Can u please explain why is it necessary to set the attribute value to required.
+Pie Number of slices to send: Send
Well, this gets into why CMT (Container managed transactions) are necessary. If you set the attribute to "Supports" then you're saying "If there's already a transaction around, I'll use it, but if there's not I don't care". That means that your Entity bean methods run outside of a transaction, since you didn't create one, which caused your error.
By using "Required" you changed that to "If there is a transaction, I'll use it, but if not, then I'll start one".
Kyle
+Pie Number of slices to send: Send
Thank you Kyle.
Tina
+Pie Number of slices to send: Send
I am getting the same error when I try to access a cmr field from my jsp. I am retrieving the collection in my action class and passing it to the jsp as a request parameter. All my bean methods have their transaction attribute set to "required". I do not know how to make my jsp use the same transaction. Did anybody face this problem. Any help would be greatly appreciated.
Thanks,
+Pie Number of slices to send: Send
You can't return a collection of EJB's retrieved from a CMR outside of your Session bean. When you do that it places the access of that collection outside of the transaction scope of your session bean.
You should only ever return collections of Value Objects (Data Transfer Objects) from Session beans. See this article for an example.
Kyle
+Pie Number of slices to send: Send
Hi Kyle,
Have u published any books using Weblogic? If yes let me know their names.
If possible let us know the books published by u so far other than the one mentioned in ur post.
Seetesh
+Pie Number of slices to send: Send
Not able to access ur site http://www.kyle-brown.com/ from India.
Seetesh
+Pie Number of slices to send: Send
It is accessible from Chennai, India
+Pie Number of slices to send: Send
I am not using a Session Facade pattern. There is no Session bean between my entity bean and jsp. All I have is a struts action class.
+Pie Number of slices to send: Send
 

Originally posted by Sany Bel:
I am not using a Session Facade pattern. There is no Session bean between my entity bean and jsp. All I have is a struts action class.



Yes, and that is the cause of your problem. You cannot access CMR relationships outside of a transaction. Thus, you need a Session bean to act as a Facade.
Kyle
I think I'll just lie down here for a second. And ponder this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 736 times.
Similar Threads
Spec Question
Container trying to save CMR field
Many to one unidirectional relationship and ejbCreate
new question of ejb exam
CMP-CMR problem
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 22:35:39.