try {
CustomerHome home = (CustomerHome) new InitialContext().lookup("java:comp/env/ejb/bank/Customer");
Collection customers = home.findAll();
for (Iterator customersInBank = customers.iterator(); customersInBank.hasNext();) {
Customer customer = (Customer) customersInBank.next();
customer.talkTo();
}
}
catch (NamingException e) {
throw new EJBException("Unable to find any customers: " + e.getMessage());
}