Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webapp fails to start with jakarta.faces.AUTOMATIC_EXTENSIONLESS_MAPPING set to true #5483

Open
jansohn opened this issue Aug 16, 2024 · 3 comments

Comments

@jansohn
Copy link

jansohn commented Aug 16, 2024

Describe the bug

I'm trying to deploy my web application on Tomcat 10.1 with Mojarra 4.0.x. Everything works if I use a webapp context like '/manager' (WAR file name manager.war) but fails if I rename the WAR to ROOT.war (empty/root webapp context '/').

16-Aug-2024 17:19:29.808 INFO [main] com.sun.faces.config.ConfigureListener.contextInitialized Initializing Mojarra 4.0.7 for context ''
16-Aug-2024 17:19:29.977 INFO [main] com.sun.faces.spi.InjectionProviderFactory.createInstance JSF1048: PostConstruct/PreDestroy annotations present.  ManagedBeans methods marked with these annotations will have said annotations processed.
16-Aug-2024 17:19:30.634 SEVERE [main] com.sun.faces.config.ConfigureListener.contextInitialized Critical error during deployment:
        java.lang.NullPointerException: Cannot invoke "java.util.Collection.size()" because "c" is null
                at java.base/java.util.ArrayDeque.addAll(ArrayDeque.java:321)
                at com.sun.faces.application.resource.ResourcePathsIterator.visit(ResourcePathsIterator.java:67)
                at com.sun.faces.application.resource.ResourcePathsIterator.tryTake(ResourcePathsIterator.java:79)
                at com.sun.faces.application.resource.ResourcePathsIterator.hasNext(ResourcePathsIterator.java:51)
                at java.base/java.util.Iterator.forEachRemaining(Iterator.java:132)
                at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
                at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
                at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
                at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
                at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
                at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
                at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
                at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
                at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
                at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
                at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
                at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
                at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
                at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
                at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
                at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
                at com.sun.faces.application.ApplicationAssociate$PostConstructApplicationListener.lambda$processEvent$1(ApplicationAssociate.java:325)
                at java.base/java.util.Optional.ifPresent(Optional.java:178)
                at com.sun.faces.application.ApplicationAssociate$PostConstructApplicationListener.processEvent(ApplicationAssociate.java:323)
                at jakarta.faces.event.SystemEvent.processListener(SystemEvent.java:124)
                at com.sun.faces.application.applicationimpl.Events.processListeners(Events.java:242)
                at com.sun.faces.application.applicationimpl.Events.invokeListenersFor(Events.java:221)
                at com.sun.faces.application.applicationimpl.Events.publishEvent(Events.java:104)
                at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:118)
                at jakarta.faces.application.ApplicationWrapper.publishEvent(ApplicationWrapper.java:672)
                at jakarta.faces.application.ApplicationWrapper.publishEvent(ApplicationWrapper.java:672)
                at com.sun.faces.config.ConfigManager.publishPostConfigEvent(ConfigManager.java:433)
                at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:233)
                at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3995)
                at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4424)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
                at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:599)
                at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:571)
                at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:654)
                at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:969)
                at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1911)
                at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
                at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
                at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
                at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:123)
                at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:771)
                at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:423)
                at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1629)
                at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
                at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:109)
                at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:385)
                at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:332)
                at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:776)
                at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:772)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
                at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203)
                at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193)
                at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
                at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
                at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
                at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:749)
                at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:203)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
                at org.apache.catalina.core.StandardService.startInternal(StandardService.java:415)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
                at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:874)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
                at org.apache.catalina.startup.Catalina.start(Catalina.java:757)
                at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
                at java.base/java.lang.reflect.Method.invoke(Method.java:580)
                at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
                at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473)

To Reproduce

Steps to reproduce the behavior:

  1. Deploy ROOT.war on Tomcat 10.1 with Mojarra 4.0.x

Expected behavior

no startup failures

@jansohn
Copy link
Author

jansohn commented Aug 19, 2024

After further tests this has nothing to do with deploying on root context or not. The webapp runs when started in a Tomcat container in Eclipse but fails if I package the WAR file and deploy it on a standalone Tomcat instance. I'll close and open a StackOverflow question instead...

@jansohn jansohn closed this as completed Aug 19, 2024
@jansohn
Copy link
Author

jansohn commented Aug 19, 2024

This is somehow caused by

<context-param>
    <param-name>jakarta.faces.AUTOMATIC_EXTENSIONLESS_MAPPING</param-name>
    <param-value>true</param-value>
</context-param>

If I set this to false then the application starts up correctly.

My complete web.xml for reference:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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-app_6_0.xsd" version="6.0">
    <display-name>Test_Webapp</display-name>

    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>test-blue-grey</param-value>
    </context-param>

    <context-param>
        <param-name>jakarta.faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>

    <context-param>
        <param-name>jakarta.faces.AUTOMATIC_EXTENSIONLESS_MAPPING</param-name>
        <param-value>true</param-value>
    </context-param>

    <context-param>
        <param-name>jakarta.faces.CLIENT_WINDOW_MODE</param-name>
        <param-value>url</param-value>
    </context-param>

    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>

    <listener>
        <listener-class>com.test.view.util.ApplicationContextListener</listener-class>
    </listener>

    <!-- https://github.com/eclipse-ee4j/mojarra/blob/4.0/README.md#controller -->
    <servlet>
        <servlet-name>facesServlet</servlet-name>
        <servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>facesServlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>

    <session-config>
        <session-timeout>120</session-timeout>
    </session-config>
</web-app>

@jansohn jansohn changed the title Webapp fails to start with root context '/' Webapp fails to start with jakarta.faces.AUTOMATIC_EXTENSIONLESS_MAPPING set to true Aug 19, 2024
@jansohn jansohn reopened this Aug 19, 2024
@BalusC
Copy link
Contributor

BalusC commented Aug 31, 2024

I copypasted your web.xml into an empty project targeted at Tomcat 10.1.23 having solely a index.xhtml (the project is of course not literally empty it's just the smallest possible project for a working Faces 4.0 app on Tomcat -- I used Weld as CDI impl btw)
Deployment immediately failed with java.lang.ClassNotFoundException: com.test.view.util.ApplicationContextListener.
After removing the com.test.view.util.ApplicationContextListener entry from web.xml it deploys fine.

The described issue is not reproducible based on the information provided so far.
Please make sure this is the case.
Try doing the same, start with the smallest possible project or try removing code/config from your project until it works ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants