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

Native build: p:importConstants ClassNotFoundException #264

Closed
redddcyclone opened this issue Oct 24, 2024 · 41 comments · Fixed by #265
Closed

Native build: p:importConstants ClassNotFoundException #264

redddcyclone opened this issue Oct 24, 2024 · 41 comments · Fixed by #265
Labels
question Further information is requested

Comments

@redddcyclone
Copy link

Hello,

I'm getting the following error when trying to load a page containing <p:importConstants> when my app is compiled as a native image:

13:32:48,332 SEVERE [org.primefaces.application.exceptionhandler.PrimeExceptionHandler] com.blahblah.blah.constants.Dialog: java.lang.ClassNotFoundException: com.blahblah.blah.constants.Dialog
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:122)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:86)
        at [email protected]/java.lang.Class.forName(DynamicHub.java:1359)
        at [email protected]/java.lang.Class.forName(DynamicHub.java:1348)
        at org.primefaces.util.LangUtils.loadClassForName(LangUtils.java:323)
        at org.primefaces.component.importconstants.ImportConstantsTagHandler.getClassFromAttribute(ImportConstantsTagHandler.java:90)
        at org.primefaces.component.importconstants.ImportConstantsTagHandler.apply(ImportConstantsTagHandler.java:64)
        at jakarta.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
        at org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:67)
        at jakarta.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
        at jakarta.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
        at org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:49)
        at org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:523)
        at org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:579)
        at org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:556)
        at org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:216)
        at org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:138)
        at org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:67)
        at org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:49)
        at org.apache.myfaces.view.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:195)
        at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.buildView(FaceletViewDeclarationLanguage.java:423)
        at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:83)
        at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
        at jakarta.faces.webapp.FacesServlet.service(FacesServlet.java:225)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:63)
        at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:67)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:133)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:65)
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:247)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:111)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:108)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$9$1.call(UndertowDeploymentRecorder.java:645)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:152)
        at io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$1.handleRequest(UndertowDeploymentRecorder.java:126)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:284)
        at io.undertow.server.DefaultExchangeHandler.handle(DefaultExchangeHandler.java:18)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$5$2.run(UndertowDeploymentRecorder.java:445)
        at [email protected]/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
        at [email protected]/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at [email protected]/java.lang.Thread.runWith(Thread.java:1596)
        at [email protected]/java.lang.Thread.run(Thread.java:1583)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:896)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:872)

On this .xhtml template, I have:

<p:importConstants type="com.blahblah.blah.constants.Dialog" />

This code works normally when the app is executed via jar or dev mode.

Does anyone know what might be happening or if I did something wrong?

Thanks a lot!

@melloware
Copy link
Contributor

melloware commented Oct 24, 2024

Yep so you can see it works Native here: https://quarkus-faces-melloware-8a6a34c1.koyeb.app/ui/misc/importConstants.xhtml?jfwid=bb1bc

What that means is you need to register that for reflection @RegisterForReflection else Native mode will compile it out of the final build.

package com.blahblah.blah.constants;

import java.io.Serializable;
import java.util.Objects;

import io.quarkus.runtime.annotations.RegisterForReflection;

@RegisterForReflection
public class Dialog implements Serializable {

@melloware melloware added the question Further information is requested label Oct 24, 2024
@redddcyclone
Copy link
Author

@melloware thanks for the help! That fixed this error but now I get another one, don't know if it's related though, could you help?

14:03:54,452 SEVERE [org.primefaces.application.exceptionhandler.PrimeExceptionHandler] Method not found: class java.lang.StringBuffer.toString(): jakarta.el.MethodNotFoundException: Method not found: class java.lang.StringBuffer.toString()
        at jakarta.el.ELUtil.findWrapper(ELUtil.java:342)
        at jakarta.el.ELUtil.findMethod(ELUtil.java:238)
        at jakarta.el.ELUtil.findMethod(ELUtil.java:203)
        at jakarta.el.BeanELResolver.invoke(BeanELResolver.java:477)
        at jakarta.el.CompositeELResolver.invoke(CompositeELResolver.java:198)
        at org.apache.el.parser.AstValue.getValue(AstValue.java:159)
        at org.apache.el.parser.AstNot.getValue(AstNot.java:43)
        at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:190)
        at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getValue(ContextAwareTagValueExpression.java:100)
        at org.apache.myfaces.view.facelets.tag.TagAttributeImpl.getObject(TagAttributeImpl.java:462)
        at org.apache.myfaces.view.facelets.tag.TagAttributeImpl.getBoolean(TagAttributeImpl.java:138)
        at org.apache.myfaces.view.facelets.tag.jstl.core.IfHandler.apply(IfHandler.java:111)
        at jakarta.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
        at jakarta.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:57)
        at org.apache.myfaces.view.facelets.tag.faces.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:362)
        at jakarta.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:52)
        at jakarta.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
        at org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:67)
        at jakarta.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
        at jakarta.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
        at org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:49)
        at org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:523)
        at org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:579)
        at org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:556)
        at org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:216)
        at org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:138)
        at org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:67)
        at org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:49)
        at org.apache.myfaces.view.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:195)
        at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.buildView(FaceletViewDeclarationLanguage.java:423)
        at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:83)
        at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
        at jakarta.faces.webapp.FacesServlet.service(FacesServlet.java:225)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:63)
        at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:67)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:133)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:65)
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:247)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:111)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:108)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$9$1.call(UndertowDeploymentRecorder.java:645)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:152)
        at io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$1.handleRequest(UndertowDeploymentRecorder.java:126)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:284)
        at io.undertow.server.DefaultExchangeHandler.handle(DefaultExchangeHandler.java:18)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$5$2.run(UndertowDeploymentRecorder.java:445)
        at [email protected]/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
        at [email protected]/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at [email protected]/java.lang.Thread.runWith(Thread.java:1596)
        at [email protected]/java.lang.Thread.run(Thread.java:1583)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:896)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:872)

@melloware
Copy link
Contributor

melloware commented Oct 24, 2024

Yep now you have to register java.lang.StringBuffer for reflection welcome to Native world!

Try

import io.quarkus.runtime.annotations.RegisterForReflection;

@RegisterForReflection(targets = { java.lang.StringBuffer.class }, methods = true)
public class ReflectionConfig {
}

@redddcyclone
Copy link
Author

Thanks again! I'll try this anytime a see a related error. Now, is this one related to reflection too?

14:30:42,837 SEVERE [org.primefaces.application.exceptionhandler.PrimeExceptionHandler] SerializationConstructorAccessor class not found for declaringClass: jakarta.faces.component._AttachedStateWrapper (targetConstructorClass: java.lang.Object). Usually adding jakarta.faces.component._AttachedStateWrapper to serialization-config.json fixes the problem.: com.oracle.svm.core.jdk.UnsupportedFeatureError: SerializationConstructorAccessor class not found for declaringClass: jakarta.faces.component._AttachedStateWrapper (targetConstructorClass: java.lang.Object). Usually adding jakarta.faces.component._AttachedStateWrapper to serialization-config.json fixes the problem.
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:121)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.reflect.serialize.SerializationSupport.getSerializationConstructorAccessor(SerializationSupport.java:163)
        at [email protected]/jdk.internal.reflect.MethodAccessorGenerator.generateSerializationConstructor(MethodAccessorGenerator.java:66)
        at [email protected]/jdk.internal.reflect.MethodAccessorGenerator.generateSerializationConstructor(MethodAccessorGenerator.java:54)
        at [email protected]/jdk.internal.reflect.ReflectionFactory.generateConstructor(ReflectionFactory.java:420)
        at [email protected]/jdk.internal.reflect.ReflectionFactory.newConstructorForSerialization(ReflectionFactory.java:412)
        at [email protected]/java.io.ObjectStreamClass.getSerializableConstructor(ObjectStreamClass.java:1445)
        at [email protected]/java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:413)
        at [email protected]/java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:385)
        at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:129)
        at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:319)
        at [email protected]/java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:385)
        at [email protected]/java.io.ObjectStreamClass$Caches$1.computeValue(ObjectStreamClass.java:111)
        at [email protected]/java.io.ObjectStreamClass$Caches$1.computeValue(ObjectStreamClass.java:108)
        at [email protected]/java.io.ClassCache$1.computeValue(ClassCache.java:73)
        at [email protected]/java.io.ClassCache$1.computeValue(ClassCache.java:70)
        at [email protected]/java.lang.ClassValue.get(JavaLangSubstitutions.java:764)
        at [email protected]/java.io.ClassCache.get(ClassCache.java:84)
        at [email protected]/java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:92)
        at [email protected]/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
        at [email protected]/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:358)
        at [email protected]/java.util.HashMap.internalWriteEntries(HashMap.java:1952)
        at [email protected]/java.util.HashMap.writeObject(HashMap.java:1505)
        at [email protected]/java.lang.reflect.Method.invoke(Method.java:580)
        at [email protected]/java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1072)
        at [email protected]/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1529)
        at [email protected]/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1451)
        at [email protected]/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1194)
        at [email protected]/java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1394)
        at [email protected]/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1190)
        at [email protected]/java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1394)
        at [email protected]/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1190)
        at [email protected]/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:358)
        at org.apache.myfaces.spi.SerialFactory.toByteArray(SerialFactory.java:40)
        at org.apache.myfaces.application.viewstate.StateUtils.getAsByteArray(StateUtils.java:297)
        at org.apache.myfaces.application.viewstate.StateUtils.construct(StateUtils.java:260)
        at org.apache.myfaces.application.viewstate.StateTokenProcessorClientSide.encode(StateTokenProcessorClientSide.java:49)
        at org.apache.myfaces.renderkit.html.HtmlResponseStateManager.writeViewStateField(HtmlResponseStateManager.java:121)
        at org.apache.myfaces.renderkit.html.HtmlResponseStateManager.writeState(HtmlResponseStateManager.java:82)
        at org.apache.myfaces.application.StateManagerImpl.writeState(StateManagerImpl.java:52)
        at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1836)
        at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:316)
        at jakarta.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:74)
        at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:122)
        at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
        at jakarta.faces.webapp.FacesServlet.service(FacesServlet.java:225)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:63)
        at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:67)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:133)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:65)
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:247)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:111)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:108)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$9$1.call(UndertowDeploymentRecorder.java:645)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:152)
        at io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$1.handleRequest(UndertowDeploymentRecorder.java:126)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:284)
        at io.undertow.server.DefaultExchangeHandler.handle(DefaultExchangeHandler.java:18)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$5$2.run(UndertowDeploymentRecorder.java:445)
        at [email protected]/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
        at [email protected]/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at [email protected]/java.lang.Thread.runWith(Thread.java:1596)
        at [email protected]/java.lang.Thread.run(Thread.java:1583)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:896)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:872)

@melloware
Copy link
Contributor

melloware commented Oct 24, 2024

try this that is a Serialization issue

package org.primefaces.showcase;

import io.quarkus.runtime.annotations.RegisterForReflection;

@RegisterForReflection(
targets = {java.lang.StringBuffer.class}, 
classNames = {"jakarta.faces.component._AttachedStateWrapper"}, 
methods = true, 
serialization = true)
public class ReflectionConfig {
}

@melloware
Copy link
Contributor

Opened: https://issues.apache.org/jira/browse/MYFACES-4688 let me know if you discover any more

@redddcyclone
Copy link
Author

Oh, thanks, that solved it but yes, another one of this same error appeared, this time related to org.apache.myfaces.view.facelets.tag.faces.FaceletState.

I'll add it to the classNames and will keep reporting here if any more of those show up!

@melloware
Copy link
Contributor

aqesome i will keep updating my PR

@melloware
Copy link
Contributor

was org.apache.myfaces.view.facelets.tag.faces.FaceletState a serialization warning?

@redddcyclone
Copy link
Author

Yes, all the errors I'm getting now are "SerializationConstructorAccessor class not found". I got a few more now:

jakarta.faces.component._DeltaStateHelper$InternalMap
org.primefaces.model.SortMeta

So far I could fix all of them with your solution.

@melloware
Copy link
Contributor

awesome i am updating Quarkus PrimeFaces and MyFaces with these changes

@redddcyclone
Copy link
Author

Two more:

org.primefaces.model.FilterMeta
jakarta.el.Expression

I'm still fixing these and building until the errors stop showing up.

@redddcyclone
Copy link
Author

Three more:

jakarta.el.ValueExpression
org.primefaces.model.filter.StringFilterConstraint
org.primefaces.model.filter.ContainsFilterConstraint

I think it's gonna be a long way 'til I fix all of these, but let's keep going

@melloware
Copy link
Contributor

melloware commented Oct 24, 2024

all the primefaces models org.primefaces.model ones i fixed in one shot

 void registerForSerialization(PrimeFacesRecorder recorder, BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
            CombinedIndexBuildItem combinedIndex) {
        // All models
        final List<String> models = collectClassesInPackage(combinedIndex, "org.primefaces.model");
        models.remove(CommonsUploadedFile.class.getName());
        final List<String> classNames = new ArrayList<>(models);

        // Chart XDev models
        classNames.addAll(collectClassesInPackage(combinedIndex, "software.xdev.chartjs.model"));

        // serialization reflection
        reflectiveClass.produce(
                ReflectiveClassBuildItem.builder(classNames.toArray(new String[0])).methods().fields().serialization().build());
    }

@redddcyclone
Copy link
Author

I found another one not related to org.primefaces.model:

org.apache.myfaces.view.ViewScopeProxyMap

This was the last on one of my app's pages, now there are some more showing up, some related to org.primefaces.model. Is there something I can do here to take them all in one shot like you did?

@melloware
Copy link
Contributor

1 second... let me generate you a list to try. ONce we get this all working i can cut a PF Extension release and you can remove all that junk 😄 generating a list right now.

@melloware
Copy link
Contributor

here you go just quickly add all these..

[org.primefaces.model.filter.StringFilterConstraint, org.primefaces.model.filter.BetweenFilterConstraint, org.primefaces.model.filter.ExactFilterConstraint, org.primefaces.model.filter.LessThanEqualsFilterConstraint, org.primefaces.model.filter.StartsWithFilterConstraint, org.primefaces.model.filter.InFilterConstraint, org.primefaces.model.filter.FunctionFilterConstraint, org.primefaces.model.filter.GreaterThanEqualsFilterConstraint, org.primefaces.model.filter.FilterConstraints, org.primefaces.model.filter.GreaterThanFilterConstraint, org.primefaces.model.filter.LessThanFilterConstraint, org.primefaces.model.filter.EndsWithFilterConstraint, org.primefaces.model.filter.ContainsFilterConstraint, org.primefaces.model.filter.EqualsFilterConstraint, org.primefaces.model.filter.FilterConstraint, org.primefaces.model.filter.ComparableFilterConstraint, org.primefaces.model.filter.NegationFilterConstraintWrapper, org.primefaces.model.filter.GlobalFilterConstraint, org.primefaces.model.badge.DefaultBadgeModel$Builder, org.primefaces.model.badge.DefaultBadgeModel, org.primefaces.model.badge.BadgeModel, org.primefaces.model.rest.AutoCompleteSuggestionResponse, org.primefaces.model.rest.AutoCompleteSuggestion, org.primefaces.model.dashboard.DefaultDashboardColumn, org.primefaces.model.dashboard.DashboardWidget, org.primefaces.model.dashboard.DefaultDashboardModel, org.primefaces.model.dashboard.DashboardModel, org.primefaces.model.dashboard.DefaultDashboardWidget, org.primefaces.model.dashboard.DashboardColumn, org.primefaces.model.seo.JsonLDItem, org.primefaces.model.seo.JsonLDModel, org.primefaces.model.map.DefaultMapModel, org.primefaces.model.map.Point, org.primefaces.model.map.GeocodeResult, org.primefaces.model.map.Circle, org.primefaces.model.map.LatLngBounds, org.primefaces.model.map.LatLng, org.primefaces.model.map.MarkerLabel, org.primefaces.model.map.Overlay, org.primefaces.model.map.Polygon, org.primefaces.model.map.MapModel, org.primefaces.model.map.Animation, org.primefaces.model.map.Symbol, org.primefaces.model.map.Marker, org.primefaces.model.map.Rectangle, org.primefaces.model.map.Polyline, org.primefaces.model.terminal.TerminalAutoCompleteModel, org.primefaces.model.terminal.TerminalCommand, org.primefaces.model.terminal.TerminalAutoCompleteMatches, org.primefaces.model.charts.ChartModel, org.primefaces.model.charts.ChartFont, org.primefaces.model.charts.ChartOptions, org.primefaces.model.charts.ChartDataSet, org.primefaces.model.charts.ChartData, org.primefaces.model.menu.DefaultSeparator$Builder, org.primefaces.model.menu.MenuModel, org.primefaces.model.menu.DefaultMenuItem$Builder, org.primefaces.model.menu.Separator, org.primefaces.model.menu.DefaultMenuColumn, org.primefaces.model.menu.DefaultMenuColumn$Builder, org.primefaces.model.menu.MenuItem, org.primefaces.model.menu.DefaultSubMenu$Builder, org.primefaces.model.menu.DefaultMenuItem, org.primefaces.model.menu.MenuGroup, org.primefaces.model.menu.BaseMenuModel, org.primefaces.model.menu.Submenu, org.primefaces.model.menu.DefaultMenuModel, org.primefaces.model.menu.DefaultSeparator, org.primefaces.model.menu.DefaultSubMenu, org.primefaces.model.menu.MenuColumn, org.primefaces.model.menu.MenuElement, org.primefaces.model.mindmap.MindmapNode, org.primefaces.model.mindmap.DefaultMindmapNode, org.primefaces.model.file.AbstractUploadedFile, org.primefaces.model.file.UploadedFilesWrapper, org.primefaces.model.file.NativeUploadedFile, org.primefaces.model.file.UploadedFiles, org.primefaces.model.file.UploadedFileWrapper, org.primefaces.model.file.NIOUploadedFile, org.primefaces.model.file.UploadedFile, org.primefaces.model.tagcloud.TagCloudModel, org.primefaces.model.tagcloud.TagCloudItem, org.primefaces.model.tagcloud.DefaultTagCloudModel, org.primefaces.model.tagcloud.DefaultTagCloudItem, org.primefaces.model.datepicker.DateMetadataModel, org.primefaces.model.datepicker.LazyDateMetadataModel, org.primefaces.model.datepicker.DefaultDateMetadata$Builder, org.primefaces.model.datepicker.DefaultDateMetadata, org.primefaces.model.datepicker.DefaultDateMetadataModel, org.primefaces.model.datepicker.DateMetadata, org.primefaces.model.timeline.TimelineEventComparator, org.primefaces.model.timeline.TimelineGroup, org.primefaces.model.timeline.TimelineModel, org.primefaces.model.timeline.TimelineEvent, org.primefaces.model.timeline.TimelineEvent$Builder, org.primefaces.model.diagram.DiagramModel, org.primefaces.model.diagram.DefaultDiagramModel, org.primefaces.model.diagram.Element, org.primefaces.model.diagram.Connection, org.primefaces.model.diagram.ElementList, org.primefaces.model.JPALazyDataModel$QueryEnricher, org.primefaces.model.LazyDefaultTreeNode, org.primefaces.model.ColumnMeta, org.primefaces.model.DefaultLazyDataModel, org.primefaces.model.DefaultStreamedContent$Builder, org.primefaces.model.LazyDataModelIterator, org.primefaces.model.JPALazyDataModel$SortEnricher, org.primefaces.model.DefaultLazyDataModel$Builder, org.primefaces.model.NestedSelectItem, org.primefaces.model.LazyScheduleModel, org.primefaces.model.DefaultLazyDataModel$ValuesSupplier, org.primefaces.model.FilterMeta, org.primefaces.model.JPALazyDataModel, org.primefaces.model.DefaultScheduleEvent$Builder, org.primefaces.model.LazyTreeNode, org.primefaces.model.SortOrder, org.primefaces.model.LazyDataModel, org.primefaces.model.TreeNode, org.primefaces.model.TreeNodeList, org.primefaces.model.TreeNodeChildren, org.primefaces.model.DefaultStreamedContent, org.primefaces.model.SortMeta$Builder, org.primefaces.model.Visibility, org.primefaces.model.JPALazyDataModel$Builder, org.primefaces.model.DialogFrameworkOptions$Builder, org.primefaces.model.FilterMeta$Builder, org.primefaces.model.MatchMode, org.primefaces.model.JSObjectBuilder, org.primefaces.model.SelectableDataModel, org.primefaces.model.ScheduleModel, org.primefaces.model.CheckboxTreeNode, org.primefaces.model.ScheduleDisplayMode, org.primefaces.model.DefaultLazyDataModel$Sorter, org.primefaces.model.JPALazyDataModel$FilterEnricher, org.primefaces.model.ScheduleEvent, org.primefaces.model.JPALazyDataModel$1, org.primefaces.model.LazyDefaultTreeNode$LazyTreeNodeChildren, org.primefaces.model.DefaultTreeNode, org.primefaces.model.DefaultOrganigramNode, org.primefaces.model.StreamedContent, org.primefaces.model.DialogFrameworkOptions, org.primefaces.model.DefaultScheduleEvent, org.primefaces.model.CroppedImage, org.primefaces.model.CheckboxTreeNodeChildren, org.primefaces.model.DefaultScheduleModel, org.primefaces.model.ResponsiveOption, org.primefaces.model.OrganigramNode, org.primefaces.model.DualListModel, org.primefaces.model.SortMeta]

@redddcyclone
Copy link
Author

Wow, that's a lot! Thanks! I just added them all and started a new build.

Do you have any idea why this is happening? I mean, shouldn't it happen on the showcase native build too?

@melloware
Copy link
Contributor

so the thing with GraalVM is it walks all your code paths of code you are using and determines what to add in the final executable so it makes it as small as possible. My Quarkus Showcase is working 100% but that means I have added everything based on that Showcase which is pretty comprehensive.

You are now using a piece of code or logic the Showcase is NOT using and thus exposing this need. In general that is why there are extensions so as use cases come up we can solve Graal problems once and not make people reinvent the wheel.

@melloware
Copy link
Contributor

melloware commented Oct 24, 2024

As a note i was already registering org.primefaces.model for reflection but NOT for Serialization which is why you ran into this. So I just simply marked them all for serialization as well.

@redddcyclone
Copy link
Author

Ah yes, I understand. Thanks for the explanation!

I found three more classes requiring this fix:

jakarta.faces.view.Location
java.util.Collections$EmptySet
jakarta.faces.component._AttachedDeltaWrapper

Now I can at least browse between some of my application's pages, so I'm taking note of all errors I'm getting on all of them to fix them in a batch, as waiting 5 min for each build is a bit tiring.

I'll continue to test all pages possible, so if I found any more classes with this error, I'll be posting them here!

@melloware
Copy link
Contributor

yep its tedious but worth it when you get it all working.

@redddcyclone
Copy link
Author

Another one from PrimeFaces: org.primefaces.component.api.SavedState

@tandraschko
Copy link

Tbh i dont think its worth all the work and you will never catch all edge cases

Startup is bit faster but thats it.

@redddcyclone
Copy link
Author

redddcyclone commented Oct 24, 2024

Another one coming up, but this one is from Hibernate. Is it relevant?

org.hibernate.collection.spi.AbstractPersistentCollection

Also @melloware, I know it's a bit off topic, but do you know why AUTOMATIC_EXTENSIONLESS_MAPPING does not work on both JAR and native modes? I've seen this issue https://issues.apache.org/jira/browse/MYFACES-4336 but it applies to 2.3, maybe something broke on 4.0?

@melloware
Copy link
Contributor

That Hibernate one I have never seen if you are properly using Quarkus Hibernate. As for AUTOMATIC_EXTENSIONLESS_MAPPING the issue is here: quarkiverse/quarkus-omnifaces#45

its a bug in Quarkus Undertow you can read all about here: quarkusio/quarkus#28028

@redddcyclone
Copy link
Author

Isn't this the correct Hibernate dependency? What could I be doing wrong?

<dependency>
	<groupId>io.quarkus</groupId>
	<artifactId>quarkus-hibernate-orm</artifactId>
</dependency>

At least for now, I had to add these two classes:

org.hibernate.collection.spi.AbstractPersistentCollection
org.hibernate.collection.spi.PersistentBag

I'm on Quarkus 3.15.1, Hibernate 6.6.0

About AUTOMATIC_EXTENSIONLESS_MAPPING, ok, so we'll have to wait for a fix. Thanks!

@melloware
Copy link
Contributor

as for these

org.hibernate.collection.spi.AbstractPersistentCollection
org.hibernate.collection.spi.PersistentBag

I assume they are being used in your JSF code and stored somewhere not part of normal Hibernate behavior because i have never had a GraalVM issue with Hibernate so it is most likely something you have in your code.

@melloware
Copy link
Contributor

I am building 3.14.6.4 now so you should be able to remove all this code you added except for the hiberate and the com.blah stuff you added

@redddcyclone
Copy link
Author

Ok, thanks a lot for the help @melloware!

@melloware
Copy link
Contributor

Its in Maven Central if you want to give it a shot.

@redddcyclone
Copy link
Author

redddcyclone commented Oct 24, 2024

org.apache.myfaces.view.ViewScopeProxyMap

@melloware I tried it, but I think you forgot this one, it was mentioned on this issue. At least for now that's the only error I got. I added it manually again and I'm running a new build to test it.

Also, I don't know if it's relevant now and if I should keep reporting it, but I have also got this error with java.sql.Timestamp.

Edit: Yes, only this one was missed out. Everything else worked. Thanks a lot!

@melloware
Copy link
Contributor

melloware commented Oct 24, 2024

So only Java.sql.timestamp is missed ? Just confirming.

Or the ProxyMap? I think I did miss that one.

@redddcyclone
Copy link
Author

Sorry for the confusion. You missed ViewScopeProxyMap. I only got the problem with java.sql.Timestamp during my recent tests, as I haven't finished testing everything possible in my application. Should I report any other findings if more errors about serialization happen?

@melloware
Copy link
Contributor

Yes please. If you run into it others will too.

@redddcyclone
Copy link
Author

@melloware just to provide an update on this, I tested almost possible path on the application and no other class related to this issue showed up. I don't know if you already added org.apache.myfaces.view.ViewScopeProxyMap and java.sql.Timestamp, but those were the last ones.
I still don't know what may be causing the need for registering org.hibernate.collection.spi.AbstractPersistentCollection and org.hibernate.collection.spi.PersistentBag (these seem related to lazy fetching), but things are working fine anyway.

@melloware
Copy link
Contributor

java.sql.Timestamp i didn't add because its too generic but I did add the ViewScopeProxyMap because its related to MyFaces. The other i would just keep in your project.

@redddcyclone
Copy link
Author

Hi @melloware

After updating to quarkus-primefaces 3.14.7 and/or quarkus-jasperreports 1.0.3 (I don't know which of them caused it), I had to register jakarta.faces.component._AttachedDeltaWrapper for serialization.

I don't know if I should open a new issue for this.

@melloware
Copy link
Contributor

Yep you will have to add it back for now. Looks like it was missed in MyFaces.

@melloware
Copy link
Contributor

PR submitted: apache/myfaces#803

@redddcyclone
Copy link
Author

Thanks a lot @melloware!

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

Successfully merging a pull request may close this issue.

3 participants