Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Problem with CMR : please help

 
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing a strange problem with CMR. I have an one-to-many relationship established between a branch bean and customer bean. i.e. one branch has multiple customers.I am trying to retrieve the collection of all customers names for a specific branch. The API, getBranchCustomers(String branchName) is defined a stateless session bean. In this method, firstly, i find the branch. Secondly, I get the collection of customers using getCustometrs () method where 'customers' is a CMR field. Then when i try to access the collection, I get the exception,
java.lang.IllegalStateException: Attempted to access the collection valued cmr-field, 'customers', for bean, 'BranchEJB', outside the scope of a transaction. All access to the collection must be performed during the transaction in which the collection was initially retrieved.
The code goes like this.................


public Collection getBranchCustomers(String branchName)
{
Vector vCustomers = null;
try
{
//look up branch home
...
Branch objBranch = objBranchHome.findByName(branchName);
if (objBranch != null)
{
//get customers
//'customers' is a CMR field, one-many CMR is defined between branch and customer
Collection cCustomers = objBranch.getCustomers();

vCustomers = new Vector(cCustomers.size()); //I get the exception at this line
Iterator itr = vCustomers.iterator();
//customer name collection to be returned
while (itr.hasNext())
...
...
...


both branch and customer EJB's have local interfaces only and all methods have tx attributes as 'NotSupported' . The API getBranchCustomers in session bean has the same tx attribute. so what is the problem here???
[ December 29, 2003: Message edited by: Rashmi Tambe ]
 
Rashmi Tambe
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybody answer this???
 
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Rashmi Tambe:
can anybody answer this???


Isn't it vacation time ?
You can find the following in the spec pg # 155

It is the responsibility of the Container to throw the java.lang.IllegalStateException
if an attempt is made to use a java.util.Iterator for a container-managed collection
in a transaction context other than that in which the iterator was obtained.


Why have you set the transaction attribute to 'NotSuppported'? Set it to 'Reauired'
 
Rashmi Tambe
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Pradeep !
I posted this and got the answer in SCBCD forum ...Anyways, thanks
and yess...i forgot..x'mas holidays r going on !
 
Pradeep bhatt
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Rashmi Tambe:
Thanks Pradeep !
I posted this and got the answer in SCBCD forum ...Anyways, thanks
and yess...i forgot..x'mas holidays r going on !


I did not see your post in SCBCD? Where is it?
And why are studying during holdays?
 
Rashmi Tambe
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi pradeep,
refer to this Post by Keith Rosenfield.
And yess, holidays r going on...but not for me
In india, we dont get a week holiday for x'mas...u must be knowing that !
So i have to work,,,and in between study too
[ December 30, 2003: Message edited by: Rashmi Tambe ]
 
Pradeep bhatt
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In india, we dont get a week holiday for x'mas...u must be knowing that !


Oh! Good luck
 
There's a way to do it better - find it. -Edison. A better tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic