Trace life cycle of stateless session bean using application client
I have created a very simple stateless session bean to understand the life cycle. but the j2ee verbose console does not display anything, when i invoke the create method from my application client.
j2ee console says "Application LifeCycle deployed"
Thru the second console when i run "java LifeCycleClient", there is no response on the server console. The second console reaches the prompt after executing the client.
BEAN CLASS
import javax.ejb.*;
public class LifeCycle implements SessionBean
{
public String hello()
{ return "hello";}
public void setSessionContext(SessionContext sc) {}
public void ejbActivate() { System.out.println("activated");}
public void ejbPassivate() { System.out.println("passivated");}
public void ejbRemove() {System.out.println("removed");}
public void ejbCreate() { System.out.println("created");}
}
HOME INTERFACE CLASS
import javax.ejb.*;
import java.rmi.*;
public interface LifeCycleHome extends EJBHome
{
public LifeCycleObject create() throws CreateException, RemoteException;
}
REMOTEINTERFACE CLASS
import javax.ejb.*;
import java.rmi.*;
public interface LifeCycleObject extends EJBObject
{
public String hello() throws RemoteException;
}
APLLICATION CLIENT class
import javax.naming.*;
import javax.rmi.*;
public class LifeCycleClient
{
public static void main(String[] ss)
{
try {
Context c = new InitialContext();
Object o = c.lookup("LifeCycleJndi");
LifeCycleHome home=(LifeCycleHome) PortableRemoteObject.narrow(o, LifeCycleHome.class);
LifeCycleObject lco = home.create();
lco.hello();
lco.remove();
}
catch(Exception e)
{}
}
}

