Alhough I did what is written in this page, I still coould not achive this problem. the problem is that the changes in web.xml does not effect the application. By the way I am using ExceptionHandler (with using org.jboss.solder.exception.control.HandlesExceptions.HandlesExceptions annotation). I tried to add a method in my ExceptionHandler class but I could not import FacesFileNotFoundException. So here is my question, although the application throws an FacesFileNotFoundException, why I can not import FacesFileNotFoundException exception class in the page?
2 Answers
You have to add the error-page in the web.xml correctly, you have to put the complete exception and the target location where you redirect when the exception is thrown is html and not xhtml, this is very important, it has to be something like this
<error-page>
<exception-type>com.sun.faces.context.FacesFileNotFoundException</exception-type>
<location>/pagenotfound.html</location>
</error-page>
What I don't know is how to make the exception not shown on the console, but it works fine this way
-
Please re-read the question. OP is trying to create a custom exception handler. – BalusC Nov 16 '12 at 11:46
I tried to add a method in my ExceptionHandler class but I could not import FacesFileNotFoundException. So here is my question, although the application throws an FacesFileNotFoundException, why I can not import FacesFileNotFoundException exception class in the page?
The com.sun.*
package is specific to the JSF implementation Mojarra. Apparently you have had the JSF API JAR file in the compiletime classpath, but not the JSF implementation JAR file.
This should not be a big problem. You should try to not make your web application dependent on a particular JSF implementation. You should try to avoid importing/referencing implementation-specific classes. The FacesFileNotFoundException
extends from java.io.FileNotFoundException
, so I recommend to import that instead. Don't forget to unwrap the FacesException
. For some hints, see also the source code of OmniFaces' FullAjaxExceptionHandler
and FacesExceptionFilter
.
If you absolutely need to import the Mojarra-specific FacesFileNotFoundException
and want your code to compile, then you should add the JSF implementation JAR file to the compiletime classpath. How exactly to do that depends on the IDE used. In Eclipse, you should be referencing the JSF implementation JAR file from the appserver in the Build Path.
Please note that the JSF ExceptionHandler
does by default nothing with error page declarations in web.xml
.

- 1,082,665
- 372
- 3,610
- 3,555