enthuware.oce-ejbd.v6.2.527

Moderator: admin

Post Reply
Manas Ranjan
Posts: 2
Joined: Sat May 14, 2016 9:11 am
Contact:

enthuware.oce-ejbd.v6.2.527

Post 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 {

admin
Site Admin
Posts: 10034
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: enthuware.oce-ejbd.v6.2.527

Post 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.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests