• 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

Sun Assessment Exam Question 3

 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh really this is the reason !
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks i got it..
 
You can't expect to wield supreme executive power just because
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic