How to catch EntityNotFoundException
germandev.net-seam.wje-online.de Sep 13, 2009 12:44 AMHi!
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!