13 Replies Latest reply on Apr 13, 2007 12:43 PM by gavin.king

    handling exceptions

    efabiano

      What's the best way to handle referencial integrety exceptions?
      I´d like to show a friendly message to the user.
      I tried to use exception.xml but the only exception that I could catch was java.lang.RuntimeException.

      I´ve tried

      <redirect view-id="/logout.xhtml">Erro inesperado
      <end-conversation/>


      but it didn´t work

      tks emerson

        • 1. Re: handling exceptions
          efabiano

          sorry, the correct code is


          <redirect view-id="/logout.xhtml">Erro inesperado
          <end-conversation/>


          tks

          • 2. Re: handling exceptions
            efabiano

            again

            < exception class="javax.persistence.PersistenceException">
            <redirect view-id="/logout.xhtml">Erro inesperado
            <end-conversation/>
            < / exception>

            tks in advance

            • 3. Re: handling exceptions
              efabiano

              HI,
              maybe I wasn´t clear enough in my last post and I realy need a little help for this case. Then I´m sending more information about this problem.
              The problem is that I couldn´t handle an exception using exception.xml. For example, I need to handle a database (referencial integrety violation) exception and then I configured my exception.xml like this:

              < exceptions>
               < exception class="javax.persistence.PersistenceException">
               <render>Database access failed</render>
               <end-conversation/>
               < /exception>
               < exception class="org.jboss.seam.framework.EntityNotFoundException">
               <redirect view-id="/logout.xhtml">Unexpected failure</redirect>
               <end-conversation/>
               < /exception>
              < /exceptions>


              But, it didn´t work. The message in console was:

              18:17:26,620 INFO [Exceptions] reading exceptions.xml
              18:17:26,636 ERROR [SeamExceptionFilter] uncaught exception handled by Seam


              then I changed exception.xml to this

              <exception class="java.lang.RuntimeException">
               <redirect view-id="/home.xhtml">Erro inesperado</redirect>
               <end-conversation/>
               </exception>


              and it worked! I´ve tried several classes of exceptions, for example: org.hibernate.exception.ConstraintViolationException, javax.persistence.EntityExistsException, org.jboss.tm.JBossRollbackException and so..
              But the only exception seam could handle using exception.xml was java.lang.RuntimeException, which is too general for my goal.


              I´m using seam 1.1.1+ajax4jsf+facelets+myfaces+tomahawk

              Below is my web.xml:

              <?xml version="1.0" encoding="UTF-8"?>

              <web-app version="2.5"
              xmlns="http://java.sun.com/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

              <context-param>
              <param-name>javax.faces.CONFIG_FILES</param-name>
              <param-value>/WEB-INF/navigation.xml</param-value>
              </context-param>

              <!-- Ajax4jsf (must come first!) -->


              <display-name>Ajax4jsf Filter</display-name>
              <filter-name>ajax4jsf</filter-name>
              <filter-class>org.ajax4jsf.Filter</filter-class>


              <filter-mapping>
              <filter-name>ajax4jsf</filter-name>
              <url-pattern>*.seam</url-pattern>
              </filter-mapping>

              <context-param>
              <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
              <param-value>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</param-value>
              </context-param>

              <!-- Seam -->


              <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>


              <!-- Propagate conversations across redirects -->

              <filter-name>Seam Redirect Filter</filter-name>
              <filter-class>org.jboss.seam.servlet.SeamRedirectFilter</filter-class>


              <filter-mapping>
              <filter-name>Seam Redirect Filter</filter-name>
              <url-pattern>*.seam</url-pattern>
              </filter-mapping>


              <filter-name>Seam Exception Filter</filter-name>
              <filter-class>org.jboss.seam.servlet.SeamExceptionFilter</filter-class>


              <filter-mapping>
              <filter-name>Seam Exception Filter</filter-name>
              <url-pattern>*.seam</url-pattern>
              </filter-mapping>

              <!-- JSF -->

              <context-param>
              <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
              <param-value>server</param-value>
              </context-param>

              <context-param>
              <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
              <param-value>.xhtml</param-value>
              </context-param>

              <context-param>
              <param-name>facelets.DEVELOPMENT</param-name>
              <param-value>true</param-value>
              </context-param>


              <servlet-name>Faces Servlet</servlet-name>
              <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
              <load-on-startup>1</load-on-startup>


              <!-- Faces Servlet Mapping -->
              <servlet-mapping>
              <servlet-name>Faces Servlet</servlet-name>
              <url-pattern>*.seam</url-pattern>
              </servlet-mapping>

              <!-- MyFaces -->

              <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>


              <!-- JSF RI -->
              <!--

              <listener-class>com.sun.faces.config.ConfigureListener</listener-class>

              -->

              <!-- MyFaces Extensions-->

              <filter-name>MyFacesExtensionsFilter</filter-name>
              <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
              <init-param>
              <param-name>maxFileSize</param-name>
              <param-value>20m</param-value>
              </init-param>
              <init-param>
              <param-name>uploadMaxFileSize</param-name>
              <param-value>100m</param-value>
              <!--
              Set the size limit for uploaded files.
              Format: 10 - 10 bytes
              10k - 10 KB
              10m - 10 MB
              1g - 1 GB

              -->
              </init-param>
              <init-param>
              <param-name>uploadThresholdSize</param-name>
              <param-value>100k</param-value>
              <!--
              Set the threshold size - files
              below this limit are stored in memory, files above
              this limit are stored on disk.

              Format: 10 - 10 bytes
              10k - 10 KB
              10m - 10 MB
              1g - 1 GB

              -->
              </init-param>
              <!--
              <init-param>
              <param-name>uploadRepositoryPath</param-name>
              <param-value>/temp</param-value>
              Set the path where the intermediary files will be stored.

              </init-param>
              -->


              <!-- extension mapping for adding , , and other resource tags to JSF-pages -->
              <filter-mapping>
              <filter-name>MyFacesExtensionsFilter</filter-name>
              <!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->
              <servlet-name>Faces Servlet</servlet-name>
              </filter-mapping>

              <!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.) -->
              <filter-mapping>
              <filter-name>MyFacesExtensionsFilter</filter-name>
              <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
              </filter-mapping>

              <filter-mapping>
              <filter-name>MyFacesExtensionsFilter</filter-name>
              <url-pattern>*.jsf</url-pattern>
              </filter-mapping>
              <filter-mapping>
              <filter-name>MyFacesExtensionsFilter</filter-name>
              <url-pattern>*.jsp</url-pattern>
              </filter-mapping>
              <filter-mapping>
              <filter-name>MyFacesExtensionsFilter</filter-name>
              <url-pattern>/faces/*</url-pattern>
              </filter-mapping>

              <context-param>
              <param-name>facelets.LIBRARIES</param-name>
              <param-value>/WEB-INF/tomahawk.taglib.xml;/WEB-INF/mps.taglib.xml</param-value>
              </context-param>
              <context-param>
              <param-name>com.sun.faces.validateXml</param-name>
              <param-value>true</param-value>
              </context-param>
              <context-param>
              <param-name>com.sun.faces.verifyObjects</param-name>
              <param-value>true</param-value>
              </context-param>
              <context-param>
              <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
              <param-value>false</param-value>
              </context-param>

              <context-param>
              <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
              <param-value>true</param-value>
              </context-param>

              <context-param>
              <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
              <param-value>true</param-value>
              </context-param>


              <context-param>
              <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
              <param-value>false</param-value>
              </context-param>

              <context-param>
              <param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
              <param-value>true</param-value>
              </context-param>

              <context-param>
              <param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
              <param-value>org.apache.myfaces.renderkit.html.util.DefaultAddResource</param-value>
              </context-param>

              <context-param>
              <param-name>org.jboss.seam.core.init.debug</param-name>
              <param-value>false</param-value>
              </context-param>

              <!-- acesso remoto à EJBs via javascript -->

              <servlet-name>Seam Remoting</servlet-name>
              <servlet-class>org.jboss.seam.remoting.SeamRemotingServlet</servlet-class>


              <servlet-mapping>
              <servlet-name>Seam Remoting</servlet-name>
              <url-pattern>/seam/remoting/*</url-pattern>
              </servlet-mapping>

              <session-config>
              <session-timeout>300</session-timeout>
              </session-config>
              </web-app>

              Please, I really need a help.
              tks emerson

              • 4. Re: handling exceptions
                gavin.king

                Sounds like you have a classloading problem. Make sure you are not including jars in your ear that are already in the JBoss server.

                • 5. Re: handling exceptions
                  efabiano

                  OK gavin I´m checking this.
                  By the way, during Jboss instalation there is an option 'enable deployment isolation/call by value'. I didn´t check this option. Do you think I should´ve enabled this option?

                  tks

                  • 6. Re: handling exceptions
                    gavin.king

                    no, its not important

                    • 7. Re: handling exceptions
                      efabiano

                      Well, I´ve tried to reproduce this behavior using a seam booking example project
                      and the same error happened (I coudn´t catch the correct exception using exception.xml)

                      The steps I did were:

                      1. First, I installed a new Jboss AS 4.05 instalation with EJB 3.0
                      2. I downloaded new seam 1.1.5
                      3. I deployed contatc list and booking example aplications on new jboss
                      4. Using contact list, exception handling with exceptions.xml worked perfectly
                      5. I changed booking example (which my application was based) in order to use exception.xml

                      a) first I created exception.xml in the correct folder

                      b) then, I changed booking example so I could test referencial integrety exceptions

                      In main.xhtml I included this lines for hotels grid

                      <h:column>
                       <f:facet name="header">remove</f:facet>
                       <s:link id="remove" value="remove" action="#{hotelBooking.removeHotel(hot)}"/>
                       </h:column>


                      In HotelBookingAction I added this method:

                      public void removeHotel(Hotel selectedHotel)
                       {
                       em.remove(em.merge(selectedHotel));
                       hotel = new Hotel();
                       }


                      My exceptions.xml file:

                      < exceptions>
                      
                       < exception class="javax.persistence.PersistenceException">
                       <redirect view-id="/register.xhtml">Unexpected failure persistence</redirect>
                       <end-conversation/>
                       < /exception>
                      
                       < exception class="org.jboss.seam.framework.EntityNotFoundException">
                       <redirect view-id="/register.xhtml">Unexpected failure entity no found</redirect>
                       <end-conversation/>
                       < /exception>
                      
                       < exception class="org.hibernate.exception.GenericJDBCException">
                       <redirect view-id="/register.xhtml">Unexpected generic</redirect>
                       <end-conversation/>
                       < /exception>
                      
                       <exception class="org.jboss.tm.JBossRollbackException">
                       <redirect view-id="/register.xhtml">Unexpected failure rollback</redirect>
                       <end-conversation/>
                       </exception>
                      
                      
                       <exception class="java.lang.RuntimeException">
                       <redirect view-id="/register.xhtml">Unexpected failure run time</redirect>
                       <end-conversation/>
                       </exception>
                      
                      
                       <exception >
                       <redirect view-id="/register.xhtml">Unexpected failure geral</redirect>
                       <end-conversation/>
                       </exception>
                       </exceptions>

                      c) then, I run booking application and added some hotels bookings.

                      d) Finally, I tried remove a hotel with bookings in order to raise a referencial integrety exception. The exception.xml file was read by seam,
                      but the exception captured was java.lang.RuntimeException!!!


                      What do I need to do for seam exception handling works in this example?

                      tks in advance

                      emerson fabiano




                      • 8. Re: handling exceptions
                        gavin.king

                        Well, if you look at the stack trace, the reason is very clear:

                        Caused by: java.lang.RuntimeException: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=gavin-kings-computer.local/117, BranchQual=, localId=117] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update)
                         at org.jboss.aspects.tx.TxPolicy.handleEndTransactionException(TxPolicy.java:198)
                         at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:180)
                         at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
                         at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
                         at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                         at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
                         at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                         at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
                         at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                         at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
                         at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102)
                         at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                         at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
                         at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                         at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
                         at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                         at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:203)
                         at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
                         at $Proxy113.removeHotel(Unknown Source)
                         at org.jboss.seam.example.booking.HotelBooking$$FastClassByCGLIB$$c83b792d.invoke(<generated>)
                         at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
                         at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
                         at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:74)
                         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
                         at org.jboss.seam.example.booking.LoggedInInterceptor.checkLoggedIn(LoggedInInterceptor.java:25)
                         at sun.reflect.GeneratedMethodAccessor133.invoke(Unknown Source)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                         at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                         at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(RemoveInterceptor.java:40)
                         at sun.reflect.GeneratedMethodAccessor126.invoke(Unknown Source)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                         at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                         at org.jboss.seam.interceptors.ExceptionInterceptor.handleExceptions(ExceptionInterceptor.java:39)
                         at sun.reflect.GeneratedMethodAccessor125.invoke(Unknown Source)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                         at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                         at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
                         at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
                         at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
                         at org.jboss.seam.intercept.ClientSideInterceptor.interceptInvocation(ClientSideInterceptor.java:83)
                         at org.jboss.seam.intercept.ClientSideInterceptor.intercept(ClientSideInterceptor.java:52)
                         at org.jboss.seam.intercept.Proxy$$EnhancerByCGLIB$$3bf45ed2.removeHotel(<generated>)
                         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
                         ... 40 more
                        Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=gavin-kings-computer.local/117, BranchQual=, localId=117] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update)
                         at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:372)
                         at org.jboss.tm.TxManager.commit(TxManager.java:240)
                         at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
                         ... 94 more
                        Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
                         at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:647)
                         at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:524)
                         at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1491)
                         at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1110)
                         at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
                         ... 96 more
                        Caused by: org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
                         at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
                         at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
                         at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
                         at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
                         at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
                         at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
                         at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
                         at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
                         at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
                         at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
                         at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)
                         ... 99 more
                        Caused by: java.sql.BatchUpdateException: failed batch
                         at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
                         at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
                         at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:519)
                         at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
                         at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
                         ... 106 more


                        The exception occurs at transaction commit (flush) time, which means that you get whatever exception the JBoss EJB3 container throws. In this case, it throws a RuntimeException. (I'm not quite sure if I approve of that, but you can take that up with the EJB3 guys in the EJB3 forum.)

                        if you do an explicit flush() in your remove method, the exception will be handled as you expect.


                        • 9. Re: handling exceptions
                          gavin.king

                          Actually I lie, it still gets wrapped in an EJBException. Actually both cases should be wrapped by an EJBException, not a RuntimeException. That is a bug in EJB3.

                          What I could do is make the exception handling automagically unwrap EJBExceptions, which are anyway useless.

                          • 10. Re: handling exceptions
                            gavin.king

                            OK, I now have a great solution to these kinds of problems in CVS.

                            Now, when trying to match a handler to an exception, we search all wrapped exception, and try to match from most-nested to least-nested.

                            This will solve your problems.

                            • 11. Re: handling exceptions
                              markfoerstein

                              Gavin, Im facing the same problem. Im using 1.2.1GA

                              The only difference is that Im throwing in the stateful bean a specific exception I created...

                              @ApplicationException(rollback=true)
                              public class GeneralApplicationException extends RuntimeException {
                              
                               public GeneralApplicationException(String message) {
                               super(message);
                               }
                              }
                              


                              ...and digging into the stack to get the messages with a class I also created (ExceptionMessages):
                              try {
                               entityManager.persist(instance);
                               entityManager.flush();
                              } catch (RuntimeException e){
                               throw new GeneralApplicationException(ExceptionMessages.getMessage(e));
                              }
                              


                              Then the message from my GeneralApplicationException is nicely presented in a error page (fragment from pages.xml):
                               <exception class="com.sphere.consultoria.exceptions.GeneralApplicationException">
                               <end-conversation/>
                               <redirect view-id="/error.xhtml">
                               <param name="icon" value="error_icon.gif"/>
                               </redirect>
                               </exception>
                              


                              My goal would be not having to use my GeneralApplicationException at all, and map every exception with their specific messages into pages.xml. Unfortunately, that's not possible, because the best I can get is the javax.persistence.PersistenceException or treat every else with a catch-all tag:
                               <exception>
                               <end-conversation/>
                               <redirect view-id="/error.xhtml">
                               <message>Ocorreu um erro inesperado. Se o problema persistir, consulte o administrador do sistema.</message>
                               <param name="icon" value="error_icon.gif"/>
                               </redirect>
                               </exception>
                              
                               <exception class="javax.persistence.PersistenceException">
                               <end-conversation/>
                               <redirect view-id="/error.xhtml">
                               <message>Ocorreu um erro ao tentar persistir as informações no banco de dados.</message>
                               <param name="icon" value="error_icon.gif"/>
                               </redirect>
                               </exception>
                              


                              It would be nice if I could map ContraintViolationException, for example, with its specific message.

                              Is it possible? I can't find a solution on this... tried searching the forum but only found similar posts...

                              Thanks for any help.

                              • 12. Re: handling exceptions
                                sammy8306

                                +1 on this...

                                • 13. Re: handling exceptions
                                  gavin.king

                                  Use #{org.jboss.seam.handledException.message} or whatever, I forget the precise name.