import java.rmi.RemoteException;
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
/**
 * A simple client for accessing a Cart.
 */
public class EntityClient
{
        public static void main(String[] args)
        {
                try
                {
                        /**
                         * Create access to the naming context.
                         */
                        Context context = new InitialContext();

                        /**
                         * Lookup the CartHome object. The reference should be retrieved from the
                         * application-local context (java:comp/env, the variable is
                         * specified in the assembly descriptor; META-INF/application-client.xml)
                         * but for simplicity we use a global variable.
                         */
                        Object homeObject = context.lookup("Entity");

                        // Narrow the reference to a CartHome.
                        EntityHome home = (EntityHome)PortableRemoteObject.narrow(homeObject, EntityHome.class);

                        //Does not Work                                                                                   
                        //
                        Entity 
                          one = (Entity) PortableRemoteObject.narrow(home.create("One"), Entity.class);
                          
                        //Works                                                                             
                        //
                        //Entity 
                        //  one = (Entity) PortableRemoteObject.narrow(home.create(1, "One"), Entity.class);
                          
                }
                catch(RemoteException e)
                {
                        System.err.println("System/communication error: " + e.getMessage());
                }
                catch(NamingException e)
                {
                        System.err.println("Communication error: " + e.getMessage());
                }
                catch(CreateException e)
                {
                        System.err.println("Error creating cart: " + e.getMessage());
                }
        }
}
