File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Clarification on a mock question about Session Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Clarification on a mock question about Session Bean" Watch "Clarification on a mock question about Session Bean" New topic

Clarification on a mock question about Session Bean

germano giudici

Joined: Dec 01, 2008
Posts: 2
This is the question (from Enthuware):

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(name="ejb/S2", beanInterface=S2Local.class)

S2Local interface is as follows:

package com.enthu.ejbplus;
import javax.ejb.Local;
public interface SLocal {
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...

SessionContext sctx;

public String m1(){ return "hello!"; }

And this are the answers:

public class S2Bean implements S2Local {

public class S2Bean implements S2Local {

public class S2Bean {

public class S2Bean {

None of these.

Enthuware says that the correct answer is 2.

My dubt is for number 1, that is excluded with this reason:
This will not work because in the absence of 'name' in @Stateless, this bean will be associated with the name of S2Bean but S1 bean is looking for ejb/S2.

Binding the injected ejb by name, isn't done with beanName attribute??
The name attribut isn't used to bind an ejb reference to ENC entry name??


Consider Paul's rocket mass heater.
subject: Clarification on a mock question about Session Bean
Similar Threads
Enthuware Questio
EJB3.x XML overriding @EJB Annotation Injection
JNDI Lookup Failing
Hello World Program Not Running - Null Pointer Exception.