java - EJB Timer Service error -
i'm trying use ejb timer service, have class named timerbean carries methods schedule timer , handle timeout, implements timerbeanremote interface class.
in session bean have following:
timerbeanremote service = (timerbeanremote) new initialcontext().lookup("timerbean/remote"); when try run on server error:
javax.naming.namingexception: lookup failed 'timerbean/remote' in serialcontext [root exception javax.naming.namenotfoundexception: timerbean]
any ideas why can't find it? thanks!
following comments -if trying access timerbeanremote within same container can inject @remote ejb in servlet or jsf backing bean else can locate ejb through jndi lookup.
suppose timerbean is: com.mypackage.timer.timerbeanremote per explanation above can either inject or lookup:
injection
public class myservlet ...{
@ejb
com.mypackage.timer.timerbeanremote timerbean;
}jndi lookup:
properties props = new properties();
props.setproperty(context.initial_context_factory, "com.sun.enterprise.naming.serialinitcontextfactory");
string[] serverdetails = server.split(":");
props.setproperty("org.omg.corba.orbinitialhost", myhost);
props.setproperty("org.omg.corba.orbinitialport", myport);
initialcontext ic = new initialcontext(props);<br> timerbeanremote timerbean = (timerbeanremote)ic.lookup("com.mypackage.timer.timerbeanremote"); you can read following articles further details: http://download.oracle.com/javaee/1.4/tutorial/doc/session5.html
http://www.javabeat.net/articles/3-ejb-30-timer-services-an-overview-1.html
Comments
Post a Comment