h:inputFile on WildFly 32.0.1 throws java.lang.NoSuchMethodException: io.undertow.servlet.spec.PartImpl.() during restore view

I currently have a JSF application running on Wildfly 32.0.1 with Java 21, Mojarra 4.0.7 and Omnifaces 4.4.1.

Some of the pages allow the user to upload a file.

As long as there are no input validation errors, everything works as it should. The problem occurs when the user forgets to enter a required value and the input file has already been uploaded. In this case, the following exception is thrown:

11:20:58,866 ERROR [io.undertow.request] (default task-9) UT005023: Exception handling request to /mywebapp/test/attachmentTest.xhtml: jakarta.servlet.ServletException: java.lang.InstantiationException: io.undertow.servlet.spec.PartImpl
        at [email protected]//jakarta.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:709)
        at [email protected]//jakarta.faces.webapp.FacesServlet.service(FacesServlet.java:449)
        at [email protected]//io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
        at [email protected]//io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
        at [email protected]//io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
        at [email protected]//io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at [email protected]//org.wildfly.elytron.web.undertow.server.ElytronRunAsHandler.lambda$handleRequest$1(ElytronRunAsHandler.java:68)
        at [email protected]//org.wildfly.security.auth.server.FlexibleIdentityAssociation.runAsFunctionEx(FlexibleIdentityAssociation.java:103)
        at [email protected]//org.wildfly.security.auth.server.Scoped.runAsFunctionEx(Scoped.java:161)
        at [email protected]//org.wildfly.security.auth.server.Scoped.runAs(Scoped.java:73)
        at [email protected]//org.wildfly.elytron.web.undertow.server.ElytronRunAsHandler.handleRequest(ElytronRunAsHandler.java:67)
        at [email protected]//io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)
        at [email protected]//io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:117)
        at [email protected]//io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at [email protected]//io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53)
        at [email protected]//io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at [email protected]//io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
        at [email protected]//io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:60)
        at [email protected]//io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at org.wildfly.security.elytron-web.undertow-server-servlet@4.1.0.Final//org.wildfly.elytron.web.undertow.server.servlet.CleanUpHandler.handleRequest(CleanUpHandler.java:38)
        at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at [email protected]//org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:44)
        at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at [email protected]//org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:51)
        at [email protected]//io.undertow.servlet.handlers.SendErrorPageHandler.handleRequest(SendErrorPageHandler.java:52)
        at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:276)
        at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
        at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:132)
        at [email protected]//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
        at [email protected]//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1421)
        at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1421)
        at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1421)
        at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1421)
        at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1421)
        at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:256)
        at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:101)
        at [email protected]//io.undertow.server.Connectors.executeRootHandler(Connectors.java:393)
        at [email protected]//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859)
        at [email protected]//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at [email protected]//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
        at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
        at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
        at [email protected]//org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
        at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.IllegalStateException: java.lang.InstantiationException: io.undertow.servlet.spec.PartImpl
        at [email protected]//jakarta.faces.component.StateHolderSaver.restore(StateHolderSaver.java:129)
        at [email protected]//jakarta.faces.component.ComponentStateHelper.restoreState(ComponentStateHelper.java:321)
        at [email protected]//jakarta.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1232)
        at [email protected]//jakarta.faces.component.UIOutput.restoreState(UIOutput.java:235)
        at [email protected]//jakarta.faces.component.UIInput.restoreState(UIInput.java:1284)
        at [email protected]//com.sun.faces.application.view.FaceletPartialStateManagementStrategy.lambda$restoreView$1(FaceletPartialStateManagementStrategy.java:357)
        at [email protected]//com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:125)
        at [email protected]//jakarta.faces.component.UIComponent.visitTree(UIComponent.java:1266)
        at [email protected]//jakarta.faces.component.UIComponent.visitTree(UIComponent.java:1278)
        at [email protected]//jakarta.faces.component.UIForm.visitTree(UIForm.java:344)
        at [email protected]//jakarta.faces.component.UIComponent.visitTree(UIComponent.java:1278)
        at [email protected]//jakarta.faces.component.UIComponent.visitTree(UIComponent.java:1278)
        at [email protected]//com.sun.faces.application.view.FaceletPartialStateManagementStrategy.restoreView(FaceletPartialStateManagementStrategy.java:346)
        at [email protected]//com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:90)
        at [email protected]//com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:258)
        at [email protected]//com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:126)
        at [email protected]//jakarta.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:96)
        at [email protected]//jakarta.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:96)
        at deployment.myapp.ear.mywebapp.war//org.omnifaces.viewhandler.OmniViewHandler.restoreView(OmniViewHandler.java:128)
        at [email protected]//com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:162)
        at [email protected]//com.sun.faces.lifecycle.Phase.doPhase(Phase.java:72)
        at [email protected]//com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:96)
        at [email protected]//com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:131)
        at [email protected]//jakarta.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:691)
        ... 46 more
Caused by: java.lang.InstantiationException: io.undertow.servlet.spec.PartImpl
        at java.base/java.lang.Class.newInstance(Class.java:719)
        at [email protected]//jakarta.faces.component.StateHolderSaver.restore(StateHolderSaver.java:127)
        ... 69 more
Caused by: java.lang.NoSuchMethodException: io.undertow.servlet.spec.PartImpl.<init>()
        at java.base/java.lang.Class.getConstructor0(Class.java:3761)
        at java.base/java.lang.Class.newInstance(Class.java:706)
        ... 70 more

I already tried using the o:inputFile from Omnifaces, but the behaviour is the same.

Page Bean

package com.test;

import java.io.Serializable;

import jakarta.faces.view.ViewScoped;
import jakarta.inject.Named;
import jakarta.servlet.http.Part;

@Named
@ViewScoped
public class AttachmentTest implements Serializable
{

    private static final long serialVersionUID = 1L;

    private String description;

    private Part uploadedFile;

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Part getUploadedFile() {
        return uploadedFile;
    }

    public void setUploadedFile(Part uploadedFile) {
        this.uploadedFile = uploadedFile;
    }

    public String doSomething() {
        // do something with uploaded file;
        return "attachmentTest";
    }

}

View

<!DOCTYPE html>
<html   xmlns="http://www.w3.org/1999/xhtml"
        xmlns:f="jakarta.faces.core"
        xmlns:ui="jakarta.faces.facelets"
        xmlns:h="jakarta.faces.html"
        xmlns:a="jakarta.faces.passthrough">

    <h:head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    </h:head>

    <h:body>

        <h:form enctype="multipart/form-data">
            <div>
                <label for="description">Description</label>
                <h:inputText id="description" value="#{attachmentTest.description}" required="true" requiredMessage="Required value"/>
                <h:message for="description"/>
            </div>
        
            <div>
                <label for="uploadedFile">Attachment</label>
                <h:inputFile id="uploadedFile" value="#{attachmentTest.uploadedFile}"/>
                <h:message for="uploadedFile"/>
            </div>
            
            <div>
                <h:commandButton action="#{attachmentTest.doSomething}" value="Do Something"/>
            </div>
            
        </h:form>

    </h:body>

</html>

Scenario

  1. User uploads file on form and does not enter description (required input)
  2. Form validation fails because a required value was not set
  3. User enters description
  4. User uploads file
  5. User submits form
  6. Exception is thrown

Is there a way around this problem?

Is this a bug or am I missing something here?

Any help would be greatly appreciated!

Thank you!

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật