• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Resource manager access

 
Greenhorn
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
{
try
{
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.
Diana
 
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.
Regards,
reply
    Bookmark Topic Watch Topic
  • New Topic