wood burning stoves*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Difference between @EJB and @Resource 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 "Difference between @EJB and @Resource" Watch "Difference between @EJB and @Resource" New topic
Author

Difference between @EJB and @Resource

shabarish vai
Ranch Hand

Joined: May 26, 2008
Posts: 79
hi all,
Please differentiate between @EJB and @Resource

am not understanding this dependancy injection,

what do you mean by @Resource(name="abc")
Vignesh Murali Natarajan
Ranch Hand

Joined: Jul 24, 2006
Posts: 65

@EJB is used to inject an EJB Remote/local interface. Whilst @Resource is what you would use to inject any resource from your "jndi:comp/env" environment. This could be a datasource, email connection, jms connectionfactory etc


ThanQ,
Vignesh Murali N
www.vigneshmurali.com
SCJP(95%), SCWCD(92%), SCBCD(97%), SCDJWS(97%), SCBCD5(100%), OCMJEA
shabarish vai
Ranch Hand

Joined: May 26, 2008
Posts: 79
thanks Vignesh Murali Natarajan,
i have read that @EJB is not supported by and we need to explicitly do a loop up(only GlassFish servers support),what and where to configure this JNDI stuff's if am using jboss server.i want to know about this JNDI
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hi Shabarish

AS the name said the @EJB is used only to inject beans. The resource is used to inject other resources (like EJBContext). But the most important aspect here is that the both @EJB and the @Resources are supported by all the application servers and both uses in background JNDI to locate the needed components.

Regards,
Mihai


SCJP, SCJD, SCWCD, OCPJBCD
 
 
subject: Difference between @EJB and @Resource
 
Similar Threads
difference between resource-ref and resource-env-ref
Difference between resource-ref and resource-env-ref?
Doubt with resource-ref
Need :Microsoft Distributed interNetwork Architect (DNA) Information
How different between resource-ref and resource-env-ref?