[jboss-user] [JBoss Seam] - Re: handling exceptions
efabiano
do-not-reply at jboss.com
Tue Jan 30 13:43:30 EST 2007
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
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4008441#4008441
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4008441
More information about the jboss-user
mailing list