Timer issue in JAVA and J2EE


Basice idea for timer is for java prgoram u can use the java.util.timer to do that.

In EJB, it has javax.ejb.timer. As to J2EE in web server you have to have sth to start the timer  , you can create a context listener in ur app, then this context listener can start timer when u deploy and run your j2ee app.

Note: The
TimerHandle provides a serializable handle to a specific timer. There is a restriction that states that the
TimerHandle cannot be exposed though a remote interface (including a web service endpoint). The container provider is responsible for implementing this interface.

This means that if an EJB contains a timerhandler emthod, this EJB can not expose as a Webservice. (Because you will get JAXB error.)

and timer is sticky to persistence of container, this means even server crash ro reboot, timer still there.

 Collection timersList = timerService.getTimers ();
 for (Object timer: timersList) {
 if (timer instanceof Timer) {
 log.debug ("Timer still running, kill it : "+timer);
 ((Timer)timer).cancel ();


See here for them:






read parameter from backing bean

Read query string from backing bean  from  Hobione blog


FacesContext context = FacesContext.getCurrentInstance();

  1. Map<String, String> params = context.getExternalContext().getRequestParameterMap();
  2. String ID = params.get(“inputId”);

 FacesContext context = FacesContext.getCurrentInstance();
 Map<String, String> params = context.getExternalContext().getRequestParameterMap();
 String pID = params.get("packageId");

Now ID should have the value 1111

For ADF in faces-config.xml:


<description>Backing bean for tree example. </description>






<value>#{param.packageId}</value> <!–JSF injects query string value from request parameter –>



In TreeBean.java, I have a instance variable and getter and setter

view plain
copy to clipboard

private String packageId;

private String packageId;

Caution: Bean scope has to be request otherwise you get a nasty error like this.

view plain
copy to clipboard

javax.faces.FacesException: Problem in renderResponse: Unable to create managed

bean tree. The following problems were found:

– The scope of the object referenced by expression #{param.packageId}, request, is shorter than the

referring managed beans (tree) scope of session note

refer to :