File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Sun Assessment Exam Question 3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Sun Assessment Exam Question 3" Watch "Sun Assessment Exam Question 3" New topic
Author

Sun Assessment Exam Question 3

Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 844
# 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?


SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog- http://rkydesigns.blogspot.com
Rahul Babbar
Ranch Hand

Joined: Jun 28, 2008
Posts: 210
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..


Rahul Babbar
Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 844
oh really this is the reason !
Javier Ramos
Greenhorn

Joined: Feb 15, 2009
Posts: 2
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

Joined: Jul 17, 2008
Posts: 844
thanks i got it..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sun Assessment Exam Question 3