Page 1 of 1

enthuware.oce-ejbd.v6.2.527

Posted: Sat May 14, 2016 9:23 am
by Manas Ranjan

Code: Select all

A stateless session bean S1 uses another stateless session bean S2 and requests a dependency injection using the following statement (contained in S1's code): @EJB(beanName="ejb/S2", beanInterface=S2Local.class) 

S2Local interface is as follows:  
package com.enthu.ejbplus;
import javax.ejb.Local;
 @Local 
public interface S2Local { String m1();    } 

 Given the above, complete the following S2Bean's code so that bean S1 will work as expected.  
package com.enthu.ejbplus;
 import javax.annotation.*; 
import javax.ejb.*; 
 // insert lines here...     
 @Resource     SessionContext sctx; 
  public String m1(){ return "hello!"; } }
Can i choose the below option as well ? Because the local business interface is annotated with @Local so i think if Bean hasn't implemented the interface then its ok. Please correct me if i am wrong.

@Stateless(name="ejb/S2")
public class S2Bean {

Re: enthuware.oce-ejbd.v6.2.527

Posted: Sun May 15, 2016 8:51 pm
by admin
No, as the explanation to this option says, "This is invalid because S2Bean neither has 'implements S2Local' part nor does it specifies its business interface using @Local or @Remote."

How will the container know that this bean implements the interface required by the client?

HTH,
Paul.