This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sun Assessment Exam Question 3

 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
# 28. Given an interface:
#
# 4. @Local
# 5. public interface MyI {
# 6. public Set go(Set s);
# 7. }
# Given an excerpt from a stateful session bean that implements this business interface:
#
# 9. @Stateful
# 10. @TransactionAttribute(TransactionAttributeType.REQUIRED)
# 11. public class MyStatefulBean implements MyI {
# 12. @Resource SessionContext ctx;
# 13. public Set go(Set s) {
# 14. ctx.getRollbackOnly();
# 15. ctx.getEJBOjbect();
# 16. ctx.getEJBHome();
# 17. throw new Exception("Will I, won't I?");
# 18. }
# 50. }
# No deployment descriptor is used. Which statement is correct?
# An exception is thrown on line 14.
# An exception is thrown on line 15.
# An exception is thrown on line 16.
# An exception is thrown on line 17.


answer 2 is correct. Why not 4?
 
Rahul Babbar
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because getEJBObject(), getEJBHome() and a few other methods are obsolete, and should only be used for EJB 2 ...
So, exception is thrown at line 15..
 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh really this is the reason !
 
Javier Ramos
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason for this is because the interface is @local and you are trying to get the remote one.

public EJBHome getEJBHome()
Obtain the enterprise bean's remote home interface.
Returns:
The enterprise bean's remote home interface.
Throws:
IllegalStateException - if the enterprise bean does not have a remote home interface.


public EJBLocalHome getEJBLocalHome()
Obtain the enterprise bean's local home interface.
Returns:
The enterprise bean's local home interface.
Throws:
IllegalStateException - if the enterprise bean does not have a local home interface.
 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks i got it..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic