What is the difference between EJB 2.x and 3.0 ?

The changes between EJB 2.X and 3.0 are: • You are no longer required to create the EJB deployment descriptor files (such as ejb-jar.xml). You can now use metadata annotations in the bean file itself to configure metadata. You are still allowed, however, to use XML deployment descriptors if you want; in the case of conflicts, the deployment descriptor value overrides the annotation value. • The bean file can be a plain Java object (or POJO); it is no longer required to implement javax.ejb.SessionBean or javax.ejb.MessageDrivenBean.• As a result of not having to implement javax.ejb.SessionBean or javax.ejb.MessageDrivenBean, the bean file no longer has to implement the lifecycle callback methods, such as ejbCreate, ejbPassivate, and so on. If, however, you want to implement these callback methods, you can name them anything you want and then annotate them with the appropriate annotation, such as @javax.ejb.PostActivate.• The bean file is required to use a business interface. The bean file can either explicitly implement the business interface or it can specify it using the @javax.ejb.Remote or @javax.ejb.Local annotations.)• The business interface is a plain Java interface (or POJI); it should not extend javax.ejb.EJBObject or javax.ejb.EJBLocalObject.• The business interface methods should not throw java.rmi.RemoteException. New EJB 3.0 Features • Bean files can now use metadata annotations to configure metadata, thus eliminating the need for deployment descriptors. • The only required metadata annotation in your bean file is the one that specifies the type of EJB you are writing (@javax.ejb.Stateless, @javax.ejb.Stateful, @javax.ejb.MessageDriven, or @javax.persistence.Entity). The default value for all other annotations reflect typical and standard use of EJBs. This reduces the amount of code in your bean file in the case where you are programming a typical EJB; you only need to use additional annotations if the default values do not suit your needs.• Bean files supports dependency injection. Dependency injection is when the EJB container automatically supplies (or injects) a variable or setter method in the bean file with a reference to another EJB or resource or another environment entry in the bean's context. • Bean files support interceptors, which is a standard way of using aspect-oriented programming with EJB.• You can configure two types of interceptor methods: those that intercept business methods and those that intercept lifecycle callbacks. Y• You can configure multiple interceptor methods that execute in a chain in a particular order. • You can configure default interceptor methods that execute for all EJBs contained in a JAR file.