• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've already set the transaction as "Required"..

 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic