This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Can't we have more than 1 @Resource annotation specified on bean class ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Can Watch "Can New topic
Author

Can't we have more than 1 @Resource annotation specified on bean class ?

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

i specified 2 @Resource annotations on a bean class. the name attribute of both the resource were different but still eclipse gave an error that duplicate Resource annotation exists.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1638
    
  23

Hi,

Yes you can have more resources of a class. Just like defining more @EJB's on a class is done with @EJBs, multiple resource can be declared bij using @Resources, for example (from: Oracle EE5 tutorial):

Regards,
Frits
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

Thanks a tonne Frits
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can't we have more than 1 @Resource annotation specified on bean class ?
 
Similar Threads
@Autowired, @Qualifier and @Resource annotation
Subclassing rules for Session beans
Contradicting statements
Question on @Resource Annotation
The place where we define Annotations inside the EJB Bean class