com.sun.faces.application.view.ViewHandlingStrategyNotFoundException after session expires

165 views Asked by At

I am in the process of upgrading my application

JDK 8 to JDK 17

JSF 2.2 > Jakarta Faces 4

Glassfish 4.1 > 7.0.11

Earlier, this issue never occurred(before this upgrade process). I have searched over the internet and found nothing.

I have set the session time to 1 minute for testing.

This error log is particularly seen, when I log in to my application, and then wait for a minute until the session expires, and I am thrown back to the login page and re-login.

StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception
com.sun.faces.application.view.ViewHandlingStrategyNotFoundException
    at java.base/java.util.Optional.orElseThrow(Optional.java:403)
    at com.sun.faces.application.view.ViewHandlingStrategyManager.getStrategy(ViewHandlingStrategyManager.java:57)
    at com.sun.faces.application.view.ViewDeclarationLanguageFactoryImpl.getViewDeclarationLanguage(ViewDeclarationLanguageFactoryImpl.java:45)
    at com.sun.faces.application.view.MultiViewHandler.getViewDeclarationLanguage(MultiViewHandler.java:408)
    at jakarta.faces.application.ViewHandlerWrapper.getViewDeclarationLanguage(ViewHandlerWrapper.java:335)
    at jakarta.faces.application.ViewHandlerWrapper.getViewDeclarationLanguage(ViewHandlerWrapper.java:335)
    at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:179)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:72)
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:95)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:131)
    at jakarta.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:691)
    at jakarta.faces.webapp.FacesServlet.service(FacesServlet.java:449)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1368)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:120)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:562)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:503)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:71)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:121)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:295)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:188)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:425)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:144)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:174)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:153)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:196)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:88)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:246)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:178)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:118)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:96)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:51)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:510)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:82)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:83)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:101)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:535)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:515)
    at java.base/java.lang.Thread.run(Thread.java:840)
|#]

This is my faces-config.xml

<?xml version='1.0' encoding='UTF-8'?>
<faces-config
    xmlns="https://jakarta.ee/xml/ns/jakartaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-facesconfig_4_0.xsd"
    version="4.0">
    
    <application>
        <action-listener>org.primefaces.application.DialogActionListener</action-listener>
        <navigation-handler>org.primefaces.application.DialogNavigationHandler</navigation-handler>
        <view-handler>org.primefaces.application.DialogViewHandler</view-handler>
    </application>
    <lifecycle>
        <phase-listener>
            com.sample.accessHandlers.SessionCheckPhaseListener
        </phase-listener>
        <phase-listener>
            com.sample.accessHandlers.DirectAccessHandler
        </phase-listener>
    </lifecycle>
</faces-config>

I have tried creating a class extending ViewHandlerWrapper such as

import jakarta.faces.application.ViewHandler;
import jakarta.faces.application.ViewHandlerWrapper;
import jakarta.faces.context.FacesContext;
import jakarta.faces.view.ViewDeclarationLanguage;

public class CustomViewHandler extends ViewHandlerWrapper {

    private ViewHandler parent;

    public CustomViewHandler(ViewHandler parent) {
        this.parent = parent;
    }

    @Override
    public ViewHandler getWrapped() {
        return parent;
    }

    @Override
    public ViewDeclarationLanguage getViewDeclarationLanguage(FacesContext context, String viewId) {
        return super.getViewDeclarationLanguage(context, viewId);
    }

}

And including it in faces-config.xml

<application>
        <view-handler>com.sample.sessionchecker.CustomViewHandler</view-handler>
</application>

Nothing has helped so far.

0

There are 0 answers