This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer (Exam 1Z0-830) Java SE 17 Developer (Exam 1Z0-829) Programmer’s Guide and have Khalid Mughal and Vasily Strelnikov on-line!
See this thread for details.
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

ejbCreate for SLSB

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to HF EJB page 228, stateless session bean method ejbCreate() and ejbRemove() cannot access a resource manager, so does it mean I cannot create a database connection in ejbCreate and close it in ejbRemove? Can someone explain this?
Thanks.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are right. You cannot access resource managers in the ejbCreate() and ejbRemove() methods. If i understand correctly, it is because these methods do not run in any transaction. And methods that do not run in a transaction cannot access resource managers or other enterprise beans.
Anyone, please correct me if i am wrong.
 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think it is the case that a method is running in a transaction to access a resource manager. With stateful session beans, resource managers can be accessed in ejbCreate and ejbRemove, although these methods do not run in a transaction.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For stateless Session bean the resource managers can be accessed only from the Business method. It can neither be accessed from ejbCreate() nor from ejbRemove() method.
[ February 12, 2004: Message edited by: Dilli raj ]
 
Li Xin
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But what is the reason for this?
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According a table 2 in teh ejb2.0 spec on page 80, you do hav access to
to Resource Manager in ebjCreate, ebjRemvoe, ebjPassivate, ebjAcitvate methods
 
Jack Zhou
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry, I din't realize that issue is about stateless session. the table 2 is about stateful session baean.
 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
keith wrote:

I don't think it is the case that a method is running in a transaction to access a resource manager. With stateful session beans, resource managers can be accessed in ejbCreate and ejbRemove, although these methods do not run in a transaction.


You're right. Running or not in client's transaction context doesn't imply that we may or not access the ressource manager.
For stateful session beans for example, ejbCreate() runs in a "unspecified Transaction Context", although we may access a database inside.
So why do we found such explanations in HFE, p.512, about afterCompletion() method.

You're no longer in a transaction! You can access ONLY your special JNDI context. It's not safe to access resource managers or other beans.


To put it in a nutshell, why do we have sometimes to take care if we are in transaction to access databases (afterBegin() or beforeCompletion() ) and somtimes not (for example ejbCreate() or ejbRemove()).
It's not very clear to me.
Thanks for your help,
Regards,
Cyril.
[ February 14, 2004: Message edited by: cyril vidal ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic