• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Statelsess Beans

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a simple question in place.
Can we use SessionContext object in ejbCreate() of a stateless bean to get a ref to EJBObject? ?

In HFEJB it says YES...but i want to know how?...as the ejbCreate() is calld at the will of container and I believ EJBObject won't be created until client makes a call.

Pls advice

Thanks
 
Sheriff
Posts: 3064
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer is yes, you can. Why? That's still unclear to me. I've posed the question in several places, including this forum, and I haven't got a satisfactory answer, except that the spec says you can do it, so you can do it.
 
Mike Pandey
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Greg,

thnx for replying back.

Well..Just a step further I guess I have got the ans to this..In the EJB 2.0 spec, on page 90 it says
"Invoking getEJBObject is disallowed if the session object identity is not associated with the bean instance and shud throw IllegalStateException cause the access to this particular SessionContext methd is not allowd"

which means if the container goes on creating a pool before any request comes..then this stmt will hold true.

What say?

As am just a starter, hope we r going the correct way!!
Others please share ur thoughts!!
Thanks a lot!!
 
Greg Charles
Sheriff
Posts: 3064
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Mike,

Well, that's not exactly what it says. Yes, any calls on the session context not allowed in table 3 (also on page 90) should cause an IllegalStateException. Also from that page:


Invoking the getEJBObject and getEJBLocalObject methods is disallowed in the session
bean methods in which there is no session object identity associated with the instance.



However, that is just explaining why getEJBObject is not allowed by table 3 in certain places. Although, it would seem to be true for ejbCreate, table 3 specifically allows getEJBObject in ejbCreate. That doesn't make sense to me, and so far no one has been able to explain it, not even the people who claim it makes sense to them.

The practical consequences aren't very important. For the test, just memorize what the spec says for this case. For real life, don't access getEJBObject from the ejbCreate method for stateless session beans. There's no particular reason you'd have to anyway.
 
Seriously Rick? Seriously? You might as well just read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic