Java Entity Bean

April 26, 2012    beans blog EJB school

Entity Bean lab for Distributed Computing using Java class. The purpose of this lab is to develop an EJB application that uses the entity bean which is used for accessing data inside of a database.


Wrong type is entered for customer id.

The code given in the lab is old and uses string as customer id.

<% InitialContext ic = new InitialContext();
Object o = ic.lookup(CustomerSessionRemote.class.getName());
CustomerSessionRemote custSession = (CustomerSessionRemote) o;

Customerinfo customer = custSession.searchForCustomerRemote(“120”);


Unable to receive customer information from the database table.



Change the id to an integer.

Customerinfo customer = custSession.searchForCustomerRemote(120);
// Also have to change the methods to receive an integer for it to work.
public interface CustomerSessionRemote {

  Customerinfo searchForCustomerRemote(Integer id);



public class CustomerSessionBean implements CustomerSessionRemote, CustomerSessionLocal {

  private EntityManager em ;

  public Customerinfo searchForCustomerLocal(Integer id) {
    Customerinfo cust = (Customerinfo)em.find(Customerinfo.class, id);
    return cust;