Republish causes warning: Servlet Faces Servlet is currently unavailable - jsf

I'm using Mojarra 2.2 on Tomcat 8 and Eclipse 4.4.1 (Build id: 20140925-1800) without any additional plugins and no Maven.
Everything works fine, but in last few days I have the following problem:
I start Tomcat, can navigate and submit data, etc, everything works correct. Now if I change my Java code, then Tomcat republishes as usual, but if I try to refresh the page in browser via F5, then I get the following error:
HTTP Status 503 - Servlet Faces Servlet is currently unavailable
In Eclipse console the following appears:
Apr 27, 2015 5:18:27 PM org.apache.catalina.core.ApplicationDispatcher invoke
WARNUNG: Servlet Faces Servlet is currently unavailable
Now I have to restart Tomcat after every little change in Java source code in order to solve it.
I don't know since when I have this issue, but I am sure I haven't it before. I changed many things in the project, but I cannot figure out the cause of this problem.
Here's a snippet of my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
.....
.....
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/ps/*</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</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>
<context-param>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>0</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml,/WEB-INF/navigations.xml</param-value>
</context-param>
....
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
....
<security-constraint>
<display-name>Restrict XHTML Documents</display-name>
<web-resource-collection>
<web-resource-name>XHTML</web-resource-name>
<url-pattern>*.xhtml</url-pattern>
</web-resource-collection>
</security-constraint>
<session-config>
<session-timeout>60</session-timeout>
<tracking-mode>COOKIE</tracking-mode>
</session-config>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/index.jsp</location>
</error-page>
<locale-encoding-mapping-list>
<locale-encoding-mapping>
<locale>de</locale>
<encoding>UTF-8</encoding>
</locale-encoding-mapping>
</locale-encoding-mapping-list>
</web-app>
How is this caused and how can I solve it?

Related

HTTP Status 404 - (projectName)/faces/Login.xhtml - the requested resource not available

I am developing some software but I am facing this issue
HTTP Status 404 - (projectName)/faces/Login.xhtml - the requested resource not available
In my office laptop it is working fine, but in my home laptop I don't know what's the problem behind this.
I tried to clear, rebuild project again and again but the problem is not going.
My other projects are running good.
here is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>EMSLoginAndAttendanceModule</display-name>
<welcome-file-list>
<welcome-file>Login.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<session-config>
<session-timeout>45</session-timeout>
</session-config>
</web-app>
this is the structure of my Login.xhtml file
WebContent
|_META-INF
|_WEB-INF
|_faces-config.xml
|_web.xml
|_Login.xhtml
The error was because no libraries were included in the Deployment Assembly so after adding that error was resolved.
Steps to resolve the error:
properties of project than Deployment Assembly
click on Add from right pane than select Java Build path Entries
From there I added all my libs and error gone away.

HTTP Status 404 Tomcat 8

the server starts correctly, but when I run my project on the server it shows this error :
Etat HTTP 404 - /gestionParc/faces/login.xhtml type Rapport d'état
message /gestionParc/faces/login.xhtml description La ressource
demandée n''est pas disponible. Apache Tomcat/8.0.36
Here is the web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID"
version="3.1" metadata-complete="true">
<display-name>gestionParc</display-name>
<absolute-ordering></absolute-ordering>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>south-street</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: 'client' or
'server' (=default). See JSF Specification 2.5.2
</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
</web-app>
I tried to run it with Tomcat 7 it's not working too.
Can someone Help me?
Where is your login.xhtml file located. It should present directly under your application web contents i.e. on the same level as your WEB-INF folder.

How to set JSF welcome file in Spring-MVC and JSF mixed web application

I am working on a web project that both Spring MVC 3.1.1 and Primefaces 3.4.2 are mixed together. Spring MVC is used to serve REST services(using URL annotations) and PrimeFaces is used for user interfaces. So naturally, I have one configuration file for both of these components.
Here is my problem:
index.xhtml is already set as welcome file in web.xml but I can't access the home page through http://localhost:8080/SampleWebApplication/
But I can access the home page through http://localhost:8080/SampleWebApplication/index.xhtml
What I want to achieve is I want to set index.xhtml file as the project's welcome file so that when the user enters http://localhost:8080/SampleWebApplication/ the user must be directed to the welcome page.
This is my web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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_3_0.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>cupertino</param-value>
</context-param>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/applicationContext.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
11
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
</web-app>
The welcome file request of / matches your Spring MVC servlet which is mapped on / and is therefore never hitting the JSF servlet which is mapped on *.xhtml.
You need to map your Spring MVC servlet on a more specific URL pattern. E.g. /rest/* or /api/* or whatever folder covers all those REST service resources. Once done that, the JSF servlet will be hit.

I cannot access my simple jsf project after deployement

I do not understand why I am getting 404 error while trying to access my application
my index.xhtml is in (Web Content)
In my log I have no error
I created my project using eclipse : web dynamic project :
my url :
http://localhost:8080/jsf_getting_started/
I tried with eclipse with tomcat (Run On Server).
My web xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>jsf_getting_started</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
The problem is that you have set the mapping of the Faces Servlet as /faces/* so in order to access to your page and be parsed by this servlet you must access to it like
http://localhost:8080/jsf_getting_started/faces/index.xhtml
But the problem with the /faces/* configuration is that the Faces Servlet will even process non-JSF resources like images, JS, CSS scripts, etc.
The best solution would be to change the mapping to *.xhtml and remove all the pages in welcome file list to have only index.xhtml. Your web.xml file will look like this (note that I'm just posting the changes made on the parts described in this answer):
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
<!-- no need of the other files... -->
</welcome-file-list>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<!-- The relevant URL mapping when using Facelets and JSF -->
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
After changing the web.xml file, rebuild your project, make sure to undeploy it from Tomcat Server and try again.
You need to add index.xhtml in the welcome-file-list.

Error deploying jsf application in JBoss 5.1

I have a big problem when I deploy my application in jboss 5.1. When it starts, I get this:
org.jboss.web.jsf.integration.config.JBossJSFConfigureListener
com.sun.faces.config.ConfigurationException: It appears the JSP version of the container is older than 2.1 and unable to locate the EL RI expression factory, com.sun.el.ExpressionFactoryImpl. If not using JSP or the EL RI, make sure the context initialization parameter, com.sun.faces.expressionFactory, is properly set.
I read many things about this bug, and nothing works for me.
I haven't jsf-api and jsf-impl in my WEB-INF/lib.
Here 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">
<display-name>Personnes-Front</display-name>
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>
<!-- Mojarra JSF -->
<context-param>
<param-name>com.sun.faces.numberOfViewsInSession</param-name>
<param-value>1</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:net/blog/dev/front/applicationContext.xml
</param-value>
</context-param>
<context-param>
<param-name>facelets.BUFFER_SIZE</param-name>
<param-value>100000</param-value>
</context-param>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>facelets.REFRESH_PERIOD</param-name>
<param-value>0</param-value>
</context-param>
<!-- JSF -->
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</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>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<!-- Facelets -->
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>com.sun.facelets.FaceletViewHandler</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener
</listener-class>
</listener>
<!-- JSF -->
<listener>
<listener-class>com.sun.faces.config.ConfigureListener
</listener-class>
</listener>
<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<!-- FILTERS -->
<!-- RichFaces -->
<filter>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>FacesServlet</servlet-name>
</filter-mapping>
<!-- Page par défaut -->
<welcome-file-list>
<welcome-file>private/personnesList.xhtml</welcome-file>
</welcome-file-list>
</web-app>
I don't understand what is the problem.
Thanks for your help.
I have found the solution.
Jboss 5.1 come with JSF 1.2.12 and this version seem to not work with jboss el.
So I have added this in my web.xml:
<context-param>
<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
<param-value>true</param-value>
</context-param>
And in my pom.xml, I fixe a newer version (1.2.13 for exemple) for jsf-api and jsf-impl and I remove the scope provided.
The war is deploy with this own jsf version and all work fine.

Resources