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

JSF deployment failure due to UnsupportedOperationException when javax.faces.FACELETS_VIEW_MAPPINGS is defined #4735

Closed
RanabirChakraborty opened this issue Aug 23, 2020 · 5 comments

Comments

@RanabirChakraborty
Copy link
Contributor

RanabirChakraborty commented Aug 23, 2020

  1. Configure the following javax.faces.FACELETS_VIEW_MAPPINGS setting in web.xml of your JSF application (For example, add the following web.xml to tasks-jsf in JBoss EAP QuickStarts):
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"                  
         version="4.0">
    <context-param>
        <param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
        <param-value>*.jsp</param-value>
    </context-param>
</web-app>
  1. Start Wildfly 20.0.1.Final and Deploy the application

  2. You will see the deployment failure due to "UnsupportedOperationException: UT010042: This method cannot be called from a servlet context listener that has been added programmatically"

SEVERE [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 84) Critical error during deployment: : java.lang.UnsupportedOperationException: UT010042: This method cannot be called from a servlet context listener that has been added programatically
	at io.undertow.servlet.spec.ServletContextImpl.ensureNotProgramaticListener(ServletContextImpl.java:976)
	at io.undertow.servlet.spec.ServletContextImpl.getServletRegistrations(ServletContextImpl.java:584)
	at com.sun.faces.util.Util.getExistingFacesServletRegistration(Util.java:160)
	at com.sun.faces.util.Util.getFacesServletMappings(Util.java:150)
	at com.sun.faces.util.Util.isResourceExactMappedToFacesServlet(Util.java:1158)
	at com.sun.faces.util.Util.isViewIdExactMappedToFacesServlet(Util.java:1139)
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.handlesViewId(FaceletViewHandlingStrategy.java:946)
	at com.sun.faces.application.view.ViewHandlingStrategyManager.getStrategy(ViewHandlingStrategyManager.java:76)
	at com.sun.faces.application.view.ViewDeclarationLanguageFactoryImpl.getViewDeclarationLanguage(ViewDeclarationLanguageFactoryImpl.java:47)
	at com.sun.faces.application.view.MultiViewHandler.getViewDeclarationLanguage(MultiViewHandler.java:446)
	at javax.faces.application.ViewHandlerWrapper.getViewDeclarationLanguage(ViewHandlerWrapper.java:346)
	at javax.faces.application.ViewHandlerWrapper.getViewDeclarationLanguage(ViewHandlerWrapper.java:346)
	at 

Widlfy issue is here

RanabirChakraborty pushed a commit to RanabirChakraborty/mojarra-1 that referenced this issue Aug 25, 2020
…ationException when javax.faces.FACELETS_VIEW_MAPPINGS is defined
RanabirChakraborty pushed a commit to RanabirChakraborty/mojarra-1 that referenced this issue Aug 25, 2020
…ationException when javax.faces.FACELETS_VIEW_MAPPINGS is defined
RanabirChakraborty pushed a commit to RanabirChakraborty/mojarra-1 that referenced this issue Aug 25, 2020
…ionException when javax.faces.FACELETS_VIEW_MAPPINGS is defined

Signed-off-by: Ranabir Chakraborty rchakrab@redhat.com
RanabirChakraborty pushed a commit to RanabirChakraborty/mojarra-1 that referenced this issue Aug 25, 2020
…ionException when javax.faces.FACELETS_VIEW_MAPPINGS is defined

Signed-off-by: Ranabir Chakraborty rchakrab@redhat.com
RanabirChakraborty pushed a commit to RanabirChakraborty/mojarra-1 that referenced this issue Aug 25, 2020
…ionException when javax.faces.FACELETS_VIEW_MAPPINGS is defined

Signed-off-by: Ranabir Chakraborty <rchakrab@redhat.com>
RanabirChakraborty added a commit to RanabirChakraborty/mojarra-1 that referenced this issue Sep 14, 2020
…ionException when javax.faces.FACELETS_VIEW_MAPPINGS is defined

Signed-off-by: Ranabir Chakraborty <rchakrab@redhat.com>
@rmartinc
Copy link
Contributor

rmartinc commented Oct 8, 2020

Just some context about this issue. Wildfly/undertow added a feature recently to better follow the servlet 4.0 spec and now it forbids the usage of the ServletContext.getServletRegistrations method when the registration is programmatic. This is also valid for servlet context listeners that are registered using a TLD, like the ConfigureListener in the mojarra implementation. Check the servlet 4.0 spec in chapter 8.3 - JSP container pluggability:

Any ServletContextListeners that were discovered in a TLD and registered programmatically are limited in the functionality they provide. Any attempt to call a ServletContext API methods on them that was added since Servlet 3.0 will result in an UnsupportedOperationException.

Don't know if this happens in other javaee servers but in wildfly adding the parameter FACELETS_VIEW_MAPPINGS (not containing the *.xhtml value) triggers this issue. The ConfigureListener finally calls getServletRegistrations in the ServletContext. See the stack-trace in the issue. In the associated PR @RanabirChakraborty is saving the FacesServlet mappings in a servlet attribute during initialization (like the impl is doing now for the annotated classes for example) to avoid the call from the listener. Another solution would be modifying in the ApplicationAssociate to not use xhtml directly but using something got from the parameter.

@arjantijms WDYT? The workaround is more or less easy but this can trigger a lot of noise in wildfly users...

@fjuma
Copy link

fjuma commented Oct 26, 2020

@arjantijms Would you be able to take a look at the PR that @RanabirChakraborty created for this issue? Thanks!

@BalusC
Copy link
Contributor

BalusC commented Apr 5, 2021

All merged.

Ive already made sure it's in 2.3/3.0/4.0.

@BalusC BalusC closed this as completed Apr 5, 2021
@BalusC
Copy link
Contributor

BalusC commented Apr 5, 2021

Thank you for your contribution!

@BalusC
Copy link
Contributor

BalusC commented Apr 5, 2021

All existing tests have passed in 2.3 👍

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

4 participants