• Post Reply Bookmark Topic Watch Topic
  • New Topic

Resource manager access

 
Diana Finis
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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
 
hover cheng
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • 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,
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!