0

Recently, I have faced the problem related to scheduler as it is loading twice. I put a lot of effort to solve it but not able to fix it. Every question I found related to this question said it's an issue related to spring as scheduler load twice and it'll be solved if you are using latest version but I don't think so. Can someone told me the issue if so that I can fix it.

<?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">

    <error-page>
    <!-- Missing login -->
    <error-code>401</error-code>
    <location>/v1/error.xhtml</location>
</error-page>
<error-page>
    <!-- Forbidden directory listing -->
    <error-code>403</error-code>
    <location>/v1/error.xhtml</location>
</error-page>
<error-page>
    <!-- Missing resource -->
    <error-code>404</error-code>
    <location>/v1/error.xhtml</location>
</error-page>
<error-page>
    <!-- Uncaught exception -->
    <error-code>500</error-code>
    <location>/v1/error.xhtml</location>
</error-page>
<error-page>
    <!-- Unsupported servlet method -->
    <error-code>503</error-code>
    <location>/v1/error.xhtml</location>
</error-page>
<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/v1/login.xhtml</location>
</error-page>
<error-page>
    <exception-type>javax.servlet.ServletException</exception-type>
    <location>/v1/login.xhtml</location>
</error-page>
<display-name>IN UI</display-name>
<welcome-file-list>
    <welcome-file>/v1/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>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/v1/*</url-pattern>
</servlet-mapping>
<filter>
    <filter-name>ExpiresFilter</filter-name>
    <filter-class>org.apache.catalina.filters.ExpiresFilter</filter-class>
    <init-param>
        <param-name>ExpiresByType image</param-name>
        <param-value>access plus 10 minutes</param-value>
    </init-param>
    <init-param>
        <param-name>ExpiresByType text/css</param-name>
        <param-value>access plus 10 minutes</param-value>
    </init-param>
    <init-param>
        <param-name>ExpiresByType application/javascript</param-name>
        <param-value>access plus 10 minutes</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>ExpiresFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
</filter-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>contextConfigLocation</param-name>
    <param-value>
              /WEB-INF/spring-servlet.xml    
    </param-value>
</context-param>
<context-param>
    <param-name>primefaces.PUBLIC_CAPTCHA_KEY</param-name>
    <param-value>6LedGUAUAAAAAGap-5zdfoh_uEVC6ccuf_oL61Be</param-value>
</context-param>
<context-param>
    <param-name>primefaces.PRIVATE_CAPTCHA_KEY</param-name>
    <param-value>6LedGUAUAAAAAK6rMd7J1LDq-utm55Oc3mo645im</param-value>
</context-param>

javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE true com.sun.faces.config.ConfigureListener org.springframework.web.context.ContextLoaderListener

<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<mime-mapping>
    <extension>xhtml</extension>
    <mime-type>application/xml</mime-type>
</mime-mapping>

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216

1 Answers1

1

Ok, I have found some issues in web.xml as you are loading context two times one with Request Context Listener and one with Dispatcher Servlet. I think there is no need to load Dispatcher Servlet as you are loading Request Context Listener so please remove this from web.xml:

<servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

It'll solve your issue. For further details see this: contextloaderlistener vs dispatcherservlet

Ammar Ali
  • 692
  • 6
  • 20