• 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:

Vishu,This contradicts ur explonation

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please see this ... I am cut and pasting all that as that did not get enough hits and i didnt get the answer .

Ramakrishna Allam
greenhorn
Member # 69602
posted March 25, 2004 02:17 PM
--------------------------------------------------------------------------------
afterCompletion() has a clent security context . So , eventhough it doesnt have a transaction context , it should be able to accesss resource mgr and beans . but the specification(on pg 80) says not so!! please check this
--------------------------------------------------------------------------------
Posts: 11 | Registered: Mar 2004 | IP: Logged

Reid M. Pinchback
ranch hand
Member # 25669
posted March 25, 2004 06:43 PM
--------------------------------------------------------------------------------
There is no meaningful transaction context, hence no access to a resource manager. Resource managers always have a transaction context of some sort. Spec page 81.
--------------------
Reid - SCJP2 (April 2002)

--------------------------------------------------------------------------------
Posts: 371 | Registered: Jan 2002 | IP: Logged

Ramakrishna Allam
greenhorn
Member # 69602
posted March 26, 2004 04:10 AM
--------------------------------------------------------------------------------
Infact page 81 of the spec says that "Accessing resource managers and enterprise beans is disallowed in the session bean methods
for which the Container does not have a meaningful transaction context or client security context."
For ex , even ejbCreate() , ejbRemove(),ejbActivate() and ejbPassivate() methods of SFSB will be in unspecified transactional context . But they can access resource mgrs and other Enterprise beans because they have a security context attached with them . Its the same case with afterCompletion . ie.Though this doesnt have a transactional context , it has a security context (for ex , it can call getCallerPrincipal and isCallerInRole(String roleName)) . But i do not really understand why this afterCompletion(boolean isCommitted) can not access resource mgrs and other beans while ejbCreate() etc can access ...Please Clarify .

--------------------------------------------------------------------------------
Posts: 11 | Registered: Mar 2004 | IP: Logged
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, I also do not understand why afterCompletion() cannot access resource mgr and beans since it has client security context.
I searched through the forum, but there's no plausible answer for this.
Joyce
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it is true that the "beanness" for SFSB method afterCompletion(boolean) contradicts my understanding that access to resource managers/other enterprise beans requires either a meaningful transaction context or a security client context for the method.(EJB2.0 spec, p:80).

afterCompletion(boolean) method runs in an unspecified transaction context(p:76, sec7.5.7) and seems to have a valid security client context, but still access to resource managers/other beans is denied in this method unlike ejbCreate(), ejbRemove(), ejbActivate() and ejbPassivate() methods of SFSB.

This makes me believe that my understanding is not fully correct. afterCompletion(boolean) method seems like an odd case.
I guess accessing a resource manager or an enterprise bean in a method is more dependent on the existence of transaction context rather than a security context. Since ejbCreate(), ejbRemove(), ejbActivate(), ejbPassivate() execute in an unspecified transaction context, the Container is free to spawn a single transaction/multiple transaction(s) in the methods, quite transparent to the bean-provider with enough flexiblity provided by the specs in this regard.

Coming to SFSB's afterComletion(boolean) method, a CMT transaction(Required, RequiresNew, Mandatory) would have been created and already committed or rolled back for the business method(s) by the time, this method is called by the container. So the container may not spawn another transaction to support access to other resource managers/beans in this method. If it does, accounting for the failure of this transaction becomes difficult or rather confusing to the client.
This is my theory and could totally be wrong also.

I couldn't find much information in the specs, RMH or Ed Roman's book about the afterCompletion() method's behaviour. From Kathy's book, I found the foll. stmt in p:512, chapter 9. "SessionSynchronization special moments." The right-hand side column talks about the afterCompletion() method's behaviour.

Call methods on your SessionContext: get your home, EJBObject, get caller security info. You can't do any transaction-related things because 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.



I have been following most of the posts since last Nov and I don't remember having discussed this contradictory behaviour before. I searched for old posts with words "afterCompletion" and "SessionSynchronization" and the closest, I got was the foll. post in which Kathy had a typo mistake.
https://coderanch.com/t/157623/java-EJB-SCBCD/certification/accessing-EJB

A lot of people follow the stereo-type approach, memorize these things without questioning to pass the exam, that includes me also to some extent. Thanks Ramakrisha/Joyce. You have raised a good question. I think you are making the right efforts in getting your EJB basics right.
I look forward to Bert or Kathy to clarify the "bean-ness" of SFSB for afterCompletion method and also clarification of the spec statment on p:81,
sec 7.6.1,

Accessing resource managers and enterprise beans is disallowed in the session bean methods for which the Container does not have a meaningful transaction context or client security context.

 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Val & Seema,
The following stmt in the spec has been puzzling some of our ranchers for quite some time. Can you explain this stmt from the spec?

p:81, sec 7.6.1,

Accessing resource managers and enterprise beans is disallowed in the session bean methods for which the Container does not have a meaningful transaction context or client security context.


w.r.t to the ejbCreate(), ejbRemove(), ejbActivate(), ejbPassivate() methods of SFSB including the controversial method afterCompletion(boolean b)
 
reply
    Bookmark Topic Watch Topic
  • New Topic