This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A CMR collection may only be used within the transction in which it was created

 
Jolie Lee
Ranch Hand
Posts: 87
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got the error above when i trying to get the collection size in my java bean.



and this is declared in my EJB:


my relationship in ejb-jar.xml:


any advise pls?
 
Karthik Guru
Ranch Hand
Posts: 1209
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that you are accessing the entity beans from within a stateless session bean, make the transaction attribute as 'REQUIRED' for all the beans. That way you will be accessing the CMR in the same transaction in which you acquired it in the first place.
 
Jolie Lee
Ranch Hand
Posts: 87
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've already set the transaction as "Required"..

 
Karthik Guru
Ranch Hand
Posts: 1209
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you accessing the CMR? If its from within a java-bean and not an 'enteprise java bean' (SLSB for eg) then you will run into this error, because you probably are not starting a transaction before accessing the 'entity bean' in your 'java bean'. The entity bean , since it has a transaction attribute of 'required' will start a new trsnactoin. The CMR will be created in that transaction. but you are trying to access that CMR in a 'java-bean' which is NOT in the same transaction.

Enclosing the java bean method in a transaction may fix this issue



or better why dont you access the entity bean from with a SLSB facade as is the norm
 
Jolie Lee
Ranch Hand
Posts: 87
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm accessing the CMR within a java-bean and not the EJB. reason being is my jsp page is reffering to my java-bean. How can i point my jsp page to directly get the value from the EJB?

anyway, i've tried the code u given and it works!! thanks a lot.

another question is, how do i display the collection? it should consists packageId and softwareID in this.packagesSoftware.

i've done something like this but it gives me error:


pls advise. Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic