2

I am confused about creating EJB

I have seen many samples of EJB on the internet and also sample project in which an EJB is developed using SessionBean , EJBObject and the EJBHome interfaces. In some other examples EJB is created without these interfaces and using only one or two interfaces e.g. if its locally accessible, javax.ejb.Local interface is used while for remotely access javax.ejb.Remote is used.

So i am confused about creating EJB. What is the difference between these two type?

I know that first one is implementing EJB for remote Access but the other one is confusing me

Please Help Me...!!!

Ekta
  • 338
  • 2
  • 9
  • 26

2 Answers2

1

These are pre EJB 3.0 as seen in javadoc: http://docs.oracle.com/javaee/6/api/javax/ejb/package-summary.html

javax.ejb.EJBObject

Enterprise beans written to the EJB 3.0 and later APIs do not require a remote interface that extends the EJBObject interface. A remote business interface can be used instead.

javax.ejb.EJBHome

Enterprise beans written to the EJB 3.0 and later APIs do not require a home interface.

So if you are starting from scratch now, focus on learning the below as they are relevant in ejb 3.1

javax.ejb.Local
javax.ejb.Remote
javax.ejb.LocalBean

Here is a nice answer exaplaining the differences: https://stackoverflow.com/a/10896403/1418643

Community
  • 1
  • 1
Aksel Willgert
  • 11,367
  • 5
  • 53
  • 74
  • i am very much thankfull to clear me above confusion thanks and please some more question about this new EJB3.0 and above version is that 1) if suppose i need ejbCreate, ejbActivate and all other events so how can i get it from the new EJB3.0 and above ver. 2) i always have problem to find perticular xml file to alocate a JNDI name according to variety of Application Servers so is there any way that i can give JNDI name without xml file and can also be use a portable name that in every Application Server it can be findable of EJB deployed on app server remotly please Help me...!!! – Suryakant Kachhi Nov 17 '12 at 17:02
0

EJBHome and EJBObject are from older versions of EJB (before EJB 3.0).

You can igore them completely.

EJB 3.0 is quite straightforward and simple compared to the older versions.

jahroy
  • 22,322
  • 9
  • 59
  • 108
  • i am very much thankfull to clear me above confusion thanks and please some more question about this new EJB3.0 and above version is that 1) if suppose i need ejbCreate, ejbActivate and all other events so how can i get it from the new EJB3.0 and above ver. 2) i always have problem to find perticular xml file to alocate a JNDI name according to variety of Application Servers so is there any way that i can give JNDI name without xml file and can also be use a portable name that in every Application Server it can be findable of EJB deployed on app server remotly please Help me...!!! – Suryakant Kachhi Nov 17 '12 at 17:02
  • @jahroy et al., As EJB 3 does not implement `EJBObject`, does the container return a direct reference of a local bean to a local client? If so, there are dangers like the client can assign a null value to same and pool instances will disappear from SLSB pools. How is this handled? If client calls are routed through a proxy as in EJB 2.1, what is such a proxy type? – lupchiazoem Aug 03 '18 at 09:11