2 Replies Latest reply on May 15, 2008 7:58 PM by Yuriy ZUbarev

    Ping functionality

    Yuriy ZUbarev Newbie


      My app should have a resource that monitoring service is pinging to see whether the app is alive or not.


      public class Ping {
        EntityManager entityManager;
        private Log log;
        public String ping() {
          try {
            entityManager.createQuery("from Widget where id = -1").getResultList();
            return "ok";
          } catch (Throwable ex) {
            log.error("Ping was not successful", ex);
            return "error";


        <page view-id="/system/ping.xhtml" login-required="false" action="#{ping.ping}">
          <navigation from-action="#{ping.ping}">
            <rule if-outcome="ok">
              <render view-id="/system/ping_ok.xhtml"/>
            <rule if-outcome="error">
              <render view-id="/system/ping_error.xhtml"/>

      When the database is actually down then the execution never even makes it to ping() method:

      ERROR 2008-05-14 14:03:20,177 org.jboss.seam.jsf.SeamPhaseListener - uncaught exception
      java.lang.IllegalStateException: Could not start transaction
              at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:581)
              at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:312)
              at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:140)
              at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:114)
              at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)

      I guess my configuration is a bit off as I don't see why there is a need to start a transaction there.

      Any tips?

      Thank you.