1 Reply Latest reply on Sep 13, 2009 9:52 PM by nmatrix nmatrix

    How to catch EntityNotFoundException

    peter irmstadt Newbie

      Hi!


      I am using a custom EntityHome<MyEntity> class that helps me to display some properties of certain Entities on a Facelets page. The Entity id is given by a page parameter and assigned to the id property of the Entity Home.


      If an invalid page parameter is given a org.jboss.seam.framework.EntityNotFoundException is thrown.


      In my pages.xml the exception is handled the following way:


      <exception class="org.jboss.seam.framework.EntityNotFoundException">
              <redirect view-id="/error.xhtml">
                  <message severity="warn">[my error message]</message>
              </redirect>
      </exception>



      But instead of handling that exception a ELException is handled (what means that the message of an ELException is shown):


      00:23:26,559 ERROR [Exceptions] handled and logged exception
      javax.el.ELException: org.jboss.seam.framework.EntityNotFoundException: entity not found: de.xxxxx.entity.MyEntity#14
           at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:339)
           at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:348)
           at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
           at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
           at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
           at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:175)
           at org.jboss.seam.navigation.Page.preRender(Page.java:311)
           at org.jboss.seam.navigation.Pages.preRender(Pages.java:350)
           
           [...]
           
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Unknown Source)
      Caused by: org.jboss.seam.framework.EntityNotFoundException: entity not found: de.xxxxx.entity.MyEntity#14
           at org.jboss.seam.framework.Home.handleNotFound(Home.java:201)
           at org.jboss.seam.framework.EntityHome.find(EntityHome.java:128)
           at org.jboss.seam.framework.Home.initInstance(Home.java:171)
           at org.jboss.seam.framework.Home.getInstance(Home.java:137)
      




      I accessed the page not by an EL call but wrote the URL with the wrong id parameter directly in the address bar of the browser. Why is an EL Exception thrown? Is there any way to differ between 'regular' EL Excpetions and that one?



      Thank you in advance!

        • 1. Re: How to catch EntityNotFoundException
          nmatrix nmatrix Newbie

          peter irmstadt wrote on Sep 13, 2009 00:44:


          Hi!

          I am using a custom EntityHome<MyEntity> class that helps me to display some properties of certain Entities on a Facelets page. The Entity id is given by a page parameter and assigned to the id property of the Entity Home.

          If an invalid page parameter is given a org.jboss.seam.framework.EntityNotFoundException is thrown.

          In my pages.xml the exception is handled the following way:

          <exception class="org.jboss.seam.framework.EntityNotFoundException">
                  <redirect view-id="/error.xhtml">
                      <message severity="warn">[my error message]</message>
                  </redirect>
          </exception>



          But instead of handling that exception a ELException is handled (what means that the message of an ELException is shown):

          00:23:26,559 ERROR [Exceptions] handled and logged exception
          javax.el.ELException: org.jboss.seam.framework.EntityNotFoundException: entity not found: de.xxxxx.entity.MyEntity#14
               at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:339)
               at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:348)
               at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
               at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
               at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
               at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:175)
               at org.jboss.seam.navigation.Page.preRender(Page.java:311)
               at org.jboss.seam.navigation.Pages.preRender(Pages.java:350)
               
               [...]
               
               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
               at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
               at java.lang.Thread.run(Unknown Source)
          Caused by: org.jboss.seam.framework.EntityNotFoundException: entity not found: de.xxxxx.entity.MyEntity#14
               at org.jboss.seam.framework.Home.handleNotFound(Home.java:201)
               at org.jboss.seam.framework.EntityHome.find(EntityHome.java:128)
               at org.jboss.seam.framework.Home.initInstance(Home.java:171)
               at org.jboss.seam.framework.Home.getInstance(Home.java:137)
          




          I accessed the page not by an EL call but wrote the URL with the wrong id parameter directly in the address bar of the browser. Why is an EL Exception thrown? Is there any way to differ between 'regular' EL Excpetions and that one?


          Thank you in advance!



          Hello peter irmstadt,


          I'm also having a similar issue with EnityNotFoundExceptions, but I believe it is caused by some sort of session, conversation mishmash conflicting with each other.  I'm trying to do absolutely simple CRUD operations (when user clicks on a name in datatable, brings them to another page to do crud operation).  And so far It's like the whole conversation feature bit is being a non-solution to a non-problem.  Conversations are simply getting in the way, If the user wants to open up that page in a new tab or their phone, great let them.  But going from A to B to C should not be overwhelming at least not like this.