jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "McAuley, Tim" <T.McAu...@emuse-tech.com>
Subject RE: Controlling transactions during unit tests
Date Wed, 09 Oct 2002 16:38:04 GMT
That's the thing that is bugging me! It reports exactly the same error. Very
weird. 

I emailed the JBoss lists with the same request but have not got a reply
back yet. 

The error message is:
 java.lang.IllegalStateException: A CMR collection may only be used within
the transction in which it was created

I have reverted back to JBoss 3.0.0 (which allowed you away with the above
error) just to make sure this test works okay, and everything is running
fine.

I'm guessing JBoss must be ignoring the userTransaction but don't know why.
Is it alright for it to be used inside a servlet (what cactus will be
deploying the test as)?

Tim

> -----Original Message-----
> From: Nicholas Lesiecki [mailto:nick@eblox.com]
> Sent: 09 October 2002 17:22
> To: Cactus Users List
> Subject: RE: Controlling transactions during unit tests
> 
> 
> How doesn't the included code help?--It's almost exactly what 
> I would have
> suggested. Does it still report the same error?
> 
> Cheers,
> Nick
> 
> > -----Original Message-----
> > From: Tim McAuley [mailto:mcauleyt@tcd.ie]
> > Sent: Wednesday, October 09, 2002 4:25 AM
> > To: cactus-user@jakarta.apache.org
> > Subject: Controlling transactions during unit tests
> >
> >
> > Hi,
> >
> > I am having a trouble with transactions during one of my 
> unit tests, using
> > JBoss 3. Someone
> > might be able to help.
> >
> > I have some code to update a member's interest in a topic. This will
> > retrieve the list of current interests, store them in a 
> cache (separate
> > collection) and update the specified interest when asked to 
> do so (both in
> > the cache and to the db currently).
> >
> > DB Layout:     Member 1 - N MemberInterest N - 1 Interest
> >
> > This call will be made through a session bean under normal
> > operation but for
> > the moment I would like to test it separately (using Cactus).
> >
> > Currently I get an exception, with the message:
> > "A CMR collection may only be used within the transaction 
> in which it was
> > created"
> >
> > This happens when I want to load the list of member interests
> > into a cache.
> > This is done by retrieving the cmr collection and then iterating
> > through it
> > to create a separate collection in cache.
> >
> > How can I get this to run within the same transaction using
> > cactus, like it
> > would under normal operation using a session bean (I presume)?
> >
> > I have tried this code (within the unit test) but it does not
> > seem to help:
> >     uTrans = (UserTransaction)new
> >         InitialContext().lookup("UserTransaction");
> >     uTrans.begin();
> >     // Create the action... which will create the interest 
> cache on first
> > call
> >     interestAction = new 
> UpdateInterestAction(memberContext, interest,
> > value);
> >     uTrans.commit();
> >
> > This is the only reference I could find on the web to a 
> similar problem...
> > and suggesting to make sure to run everything within a 
> usertransaction.
> > http://www.jboss.org/forums/thread.jsp?forum=46&thread=20507&messa
> ge=3738688
> #3738688
> 
> I am using JBoss 3.0.2 (and 3.0.3), on Win 2K, accessing 
> Postgres 7.1.3
> 
> Many thanks,
> 
> Tim
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:cactus-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:cactus-user-help@jakarta.apache.org>
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:cactus-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:cactus-user-help@jakarta.apache.org>
> 
> 

--
To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>


Mime
View raw message