• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Resource manager access

Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Recently I was going through some mock exam and faced the following question:
"Consider the following method of a stateless session bean. Which of the given options are correct regarding this method?"

Code :

public xxxx() throws
InitialContext ctx = new InitialContext();
QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) ctx.lookup("java:comp/env/jms/myQueueConnectionFactory");
...//other valid code.
catch(Exception e)
throw new EJBException(e.getMessage());

Options :

Select 1 correct option.

1. It may be ejbCreate() method.

2. It may be ejbRemove() method.

3. It may be a business method.

4. It may be setSessionContext() method.

5. This code is invalid in any stateless session bean method.
The correct answer was "3. It may be a business method."
For me it doesn't look rigth. Resource Manager is registered via resource-ref tag, hence it's available in "java:/comp/env" scope. And JNDI access to "java:/comp/env" IS ALLOWED for all methods listed above.
Can somebody clarify this point to me?
Thanks in advance.
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Diana
In chapter "7.8.2 Operations allowed in the methods of a stateless session bean class" of EJB spec 2.0, it has a clear restriction on which methods could be accessed regarding EJBContext, Transaction, JNDI and resource manager. Comparing with that, the 3rd answer is quite right.
The only taste of success some people get is to take a bite out of you. Or this tiny ad:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic