Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

whizlabs question..

 
mallika shah
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that the stateless session bean does not have a dd, which of the following stateless sb implementation will not be deployed successfully in the EJB 3.0 container?
a.
@Stateless
public class PaymentSessionBean implements PaymentBean{
public void process(Payment pay)
{
//buss logic
}
}

b.
public class PaymentSessionBean extends javax.eb.SessionBean implements PaymentBean{
public void process(Payment pay)
{
//buss logic
}
}

c.
@Stateless
public class PaymentSessionBean extends javax.ejb.SessionBean implements PaymentBean{
public void process(Payment pay)
{
//buss logic
}
}
d.
@Stateless
public class PaymentSessionBean implements PaymentBean{
public void process(Payment pay)
{
//buss logic
}
}

Ans d,a

HOW??
Please help explaining the reason behind the answers.

thanks,
mallika
 
mallika shah
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
correction to the above option d:
there was an ejbCreate() method in it.

d.
@Stateless
public class PaymentSessionBean implements PaymentBean{
public void process(Payment pay)
{
//buss logic
}
public void ejbCreate()
{//impl
}
}
 
Uchana Jackson
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just created all four of these SLSB's in eclipse.

b and c are having compiler errors due to the session bean class extending (instead of implementing) the javax.ebj.SessionBean interface.

also, this is from 4.3.10.2 of ejb core spec doc:

"If the stateless session bean instance has an ejbCreate method, the container treats the ejbCreate
method as the instance�s PostConstruct method, and, in this case, the PostConstruct annotation
(or deployment descriptor metadata) can only be applied to the bean�s ejbCreate method."

so I understand what the problem is with d or a... a and d should both deploy fine.

have you tried deploying a and d as an EAR in a JavaEE app server?
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The answer should be b and c.

Assuming that the stateless session bean does not have a dd, which of the following stateless sb implementation will not be deployed successfully in the EJB 3.0 container?


Thanks
 
mallika shah
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Sean and Narendra for your reply.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic