'java.lang.ClassCastException: Cannot cast com.vaadin.flow.di.LookupInitializer$LookupImpl to com.vaadin.flow.di.Lookup

I have migrated one of the projects from vaadin8 compatibility mode to vaadin flow 14. Now when I am trying to deploy the same, it is throwing some runtime exception at the time of deployment. The container is jboss-eap-7.3. Please find the stack trace below.

[2022-03-17 21:41:38,558] [ ] [ERROR] [ServerService Thread Pool -- 259] [org.jboss.msc.service.fail] [] [] [] [] MSC000001: Failed to start service jboss.deployment.subunit."appV14.ear"."appV14.war".undertow-deployment: org.jboss.msc.service.StartException in service jboss.deployment.subunit."appV14.ear"."appV14.war".undertow-deployment: java.lang.RuntimeException: java.lang.ClassCastException: Cannot cast com.vaadin.flow.di.LookupInitializer$LookupImpl to com.vaadin.flow.di.Lookup
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at [email protected]//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at [email protected]//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
    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 java.base/java.lang.Thread.run(Thread.java:834)
    at [email protected]//org.jboss.threads.JBossThread.run(JBossThread.java:485)
Caused by: java.lang.RuntimeException: java.lang.ClassCastException: Cannot cast com.vaadin.flow.di.LookupInitializer$LookupImpl to com.vaadin.flow.di.Lookup
    at [email protected]//io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:254)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:96)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)
    ... 8 more
Caused by: java.lang.ClassCastException: Cannot cast com.vaadin.flow.di.LookupInitializer$LookupImpl to com.vaadin.flow.di.Lookup
    at java.base/java.lang.Class.cast(Class.java:3605)
    at deployment.appV14.ear//com.vaadin.flow.server.VaadinServletContext.getAttribute(VaadinServletContext.java:76)
    at deployment.appV14.ear//com.vaadin.flow.server.VaadinContext.getAttribute(VaadinContext.java:58)
    at deployment.appV14.ear//com.vaadin.flow.server.startup.ClassLoaderAwareServletContainerInitializer.onStartup(ClassLoaderAwareServletContainerInitializer.java:112)
    at [email protected]//io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:204)
    at [email protected]//io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:186)
    at [email protected]//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
    at [email protected]//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    at [email protected]//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
    at [email protected]//io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:252)
    ... 10 more


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source