GeeCON Prague 2014*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Question on SLSB Contract - SCBCD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Question on SLSB Contract - SCBCD" Watch "Question on SLSB Contract - SCBCD" New topic

Question on SLSB Contract - SCBCD

Ravi Narala

Joined: Oct 23, 2007
Posts: 16
I am preparing for SCBCD. I have a doubt in regards to the question below. I was choosing B and D. Please correct me if I am wrong. I would appreciate if someone could shed some light on this.

public interface B1 {}
public interface B2 {}

A java class is defined as:

public class Bean implements B1 ,B2

Which two statements are correct for making this code work as a stateless session bean, considering that this session bean is NOT defined in a deployment descriptor and the interfaces do NOT have annotations? (Choose two.)

A - Only the interface for remote usage must be annotated.
B - The interfaces B1 and B2 can only be used locally without changing the code.
C - Both interfaces B1 and B2 must be annotated to make this a working stateless session bean.
D - The interfaces B1 and B2 can be annotated differently, one with @Local and the other with @Remote.


IBM Certified Websphere 6.1 Core Admin
IBM Certified SOA Solution Designer
SCEA Part 1
Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 844

Please let us know why you are chossing B & D. what are the correct answer.

My choice would go with A and B answer.

SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog-
Graeme Jenkinson

Joined: Sep 08, 2008
Posts: 27

I would answer C and D. I think C is correct because my understanding is that if a sesssion bean implements a single interface then it defaults to Local whereas if a session bean implements two (or more) interfaces there must be explicitly annotated or defined in the deployment descriptor. I think D is correct beacuse I can't see any issue with a seesion bean implementing both Local and Remote interfaces (I'm sure that the O'Reilly EJB 3.0 gives an example of this in Chapter 11).

I'll take a look at the spec to see whether my understanding is correct. Meanwhile if anybody knows for sure I'd be interested in the answer and the reasoning.


Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

I think correct answers are A,B and D.

I verified with the following code:

Bean interfaces similar to B1 and B2 in your case:

Bean class implementing bean interfaces

Accessing them from servlet to verify.

I am getting the output as :

Greeting from StatelessSessionBean1: Hello1,Dieter!
Greeting from StatelessSessionBean2: Hello2,Dieter!

Please correct me if i am wrong.


Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
Answer is very clear

See this quote of spec

• If bean class implements a single interface, that interface is assumed to be the business interface of the bean. This business interface will be a local interface unless the interface is designated as a remote business interface by use of the Remote annotation on the bean class or interface or by means of the deployment descriptor.

• A bean class is permitted to have more than one interface. If a bean class has more than one interface excluding the interfaces listed below—any business interface of the bean class must be explicitly designated as a business interface of the bean by means of the Local or Remote annotation on the bean class or interface or in the deployment descriptor.
Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
Hi Karnati Sudhakar,

Keep in mind that this behavior may be specific to a App Server (I guess this is jboss) . So be careful in the exam. exam totally focuses on the spec.

Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270


I verified the above code in Glassfish App server.I remember there is one question in Enthuware similar to this:

Consider the following interfaces and bean code:

Assuming appropriate package and import statements, what should the developer do to make sure that the bean exposes two local and one remote interfaces?

1) Add the following to XYBean before class declaration:

2) Add the following to XLocal, YLocal, and XRemote interfaces respectively:
@Local, @Local, @Remote

3) The developer can add @Local to either of the local interfaces but not both and @Remote to the remote interface.

4) This cannot be done.

5) This can only be done through deployment descriptor.

6) Only add @Remote to the remote interface. No need to do anything for the local interfaces.

Suppose if the question was asked as to expose three interfaces as Local what would be the answer for this question?

Why my codre is behainv differently as stated in the specs.

GeeCON Prague 2014
subject: Question on SLSB Contract - SCBCD