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:

  1. injection
    public class myservlet ...{

    @ejb
    com.mypackage.timer.timerbeanremote timerbean;
    }

  2. 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

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -