tandraschko / quarkus-myfaces

26 stars 6 forks source link

facesContext.externalContext.flash.keepMessages not working in jar mode #4

Closed rmpestano closed 5 years ago

rmpestano commented 5 years ago

When running code below in java -jar mode (also see #3) the bean method is not called:

<p:commandButton value="property action listener" action="#{dtLazyView.save}">
                    <f:setPropertyActionListener value="true"
                                                 target="#{facesContext.externalContext.flash.keepMessages}"/>
                </p:commandButton>

save method is simple as:

 public void save() {
        FacesMessage msg = new FacesMessage("Hello Quarkus!");
        FacesContext.getCurrentInstance().addMessage(null, msg);
    }

Note that setting properties on MB is working, only when I try to set a property on facesContext that it doesnt work. No exception is raised, I only was able to get the stacktrace using a custom exception handler, the exception is the following:

rmpestano@oss-powerhouse:~/projects/quarkus-myfaces/quarkus-myfaces-showcase$ java -jar target/quarkus-myfaces-showcase-1.0-SNAPSHOT-runner.jar 
Locale name in faces-config.xml null or empty, setting locale to default locale : en_US
MyFaces Core Bean Validation support disabled
MyFaces Core CDI support enabled
MyFaces Core EL 3.0 support enabled
MyFaces Core Servlet 4.0 support enabled
Running on PrimeFaces 7.0

********************************************************************
*** WARNING: Apache MyFaces Core is running in DEVELOPMENT mode. ***
***                                            ^^^^^^^^^^^       ***
*** Do NOT deploy to your live server(s) without changing this.  ***
*** See Application#getProjectStage() for more information.      ***
********************************************************************

MyFaces Core has started, it took [741] ms.
Quarkus 0.15.0 started in 1.855s. Listening on: http://[::]:8080
Installed features: [cdi, myfaces]

java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    org/apache/myfaces/cdi/JsfArtifactProducer_ProducerMethod_getFacesContext_6432ec49e096ea975e673cec96a0eaae1039fc21_ClientProxy.getNamingContainerSeparatorChar()C @7: areturn
  Reason:
    Type integer (current frame, stack[0]) is not assignable to reference type
  Current Frame:
    bci: @7
    flags: { }
    locals: { 'org/apache/myfaces/cdi/JsfArtifactProducer_ProducerMethod_getFacesContext_6432ec49e096ea975e673cec96a0eaae1039fc21_ClientProxy' }
    stack: { integer }
  Bytecode:
    0x0000000: 2ab6 000e b600 28b0                    

        at org.apache.myfaces.cdi.JsfArtifactProducer_ProducerMethod_getFacesContext_6432ec49e096ea975e673cec96a0eaae1039fc21_Bean$$function$$30.get(Unknown Source)
        at io.quarkus.arc.LazyValue.get(LazyValue.java:42)
        at org.apache.myfaces.cdi.JsfArtifactProducer_ProducerMethod_getFacesContext_6432ec49e096ea975e673cec96a0eaae1039fc21_Bean.get(Unknown Source)
        at org.apache.myfaces.cdi.JsfArtifactProducer_ProducerMethod_getFacesContext_6432ec49e096ea975e673cec96a0eaae1039fc21_Bean.get(Unknown Source)
        at io.quarkus.arc.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:310)
        at io.quarkus.arc.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:322)
        at io.quarkus.arc.BeanManagerImpl.getReference(BeanManagerImpl.java:74)
        at io.quarkus.myfaces.runtime.myfaces.QuarkusCdiELResolver.getValue(QuarkusCdiELResolver.java:88)
        at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:62)
        at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:94)
        at org.apache.el.parser.AstValue.getTarget(AstValue.java:70)
        at org.apache.el.parser.AstValue.getType(AstValue.java:58)
        at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:174)
        at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getType(ContextAwareTagValueExpression.java:76)
        at org.apache.myfaces.view.facelets.tag.jsf.core.SetPropertyActionListenerHandler$SetPropertyListener.processAction(SetPropertyActionListenerHandler.java:125)
        at javax.faces.event.ActionEvent.processListener(ActionEvent.java:58)
        at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:412)
        at javax.faces.component.UICommand.broadcast(UICommand.java:55)
        at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:1238)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:411)
        at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1722)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:918)
        at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:43)
        at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:164)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:207)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
        at com.github.adminfaces.template.session.AdminFilter.doFilter(AdminFilter.java:128)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
        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.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
        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:64)
        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.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:292)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
        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.UndertowDeploymentTemplate$7$1$1.call(UndertowDeploymentTemplate.java:437)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:364)
        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1538)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1429)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:32)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)
UT005023: Exception handling request to /index.xhtml
tandraschko commented 5 years ago

See: https://github.com/quarkusio/quarkus/issues/2714

rmpestano commented 5 years ago

Hi guys, looks like quarkus 0.16.1 should have the fix for this issue but I'm still getting the exception:

Quarkus 0.16.1 started in 4.267s. Listening on: http://[::]:8080
Installed features: [cdi, myfaces, omnifaces]
Redirecting user back to /car-list.xhtml
class com.github.adminfaces.starter.bean.CarListMB: postConstruct
Error trying to load and send resource favicon/favicon-96x96.png with library null: Broken pipe
java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    org/apache/myfaces/cdi/JsfArtifactProducer_ProducerMethod_getFacesContext_6432ec49e096ea975e673cec96a0eaae1039fc21_ClientProxy.getNamingContainerSeparatorChar()C @7: areturn
  Reason:
    Type integer (current frame, stack[0]) is not assignable to reference type
  Current Frame:
    bci: @7
    flags: { }
    locals: { 'org/apache/myfaces/cdi/JsfArtifactProducer_ProducerMethod_getFacesContext_6432ec49e096ea975e673cec96a0eaae1039fc21_ClientProxy' }
    stack: { integer }
  Bytecode:
    0x0000000: 2ab6 000e b600 28b0                    

        at org.apache.myfaces.cdi.JsfArtifactProducer_ProducerMethod_getFacesContext_6432ec49e096ea975e673cec96a0eaae1039fc21_Bean$$function$$40.get(Unknown Source)
        at io.quarkus.arc.LazyValue.get(LazyValue.java:42)
        at org.apache.myfaces.cdi.JsfArtifactProducer_ProducerMethod_getFacesContext_6432ec49e096ea975e673cec96a0eaae1039fc21_Bean.get(Unknown Source)
        at org.apache.myfaces.cdi.JsfArtifactProducer_ProducerMethod_getFacesContext_6432ec49e096ea975e673cec96a0eaae1039fc21_Bean.get(Unknown Source)
        at io.quarkus.arc.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:324)
        at io.quarkus.arc.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:336)
        at io.quarkus.arc.BeanManagerImpl.getReference(BeanManagerImpl.java:74)
        at io.quarkus.myfaces.runtime.spi.QuarkusCdiELResolver.getValue(QuarkusCdiELResolver.java:88)
        at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:62)
        at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:94)
        at org.apache.el.parser.AstValue.getTarget(AstValue.java:70)
        at org.apache.el.parser.AstValue.getType(AstValue.java:58)
        at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:174)
        at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getType(ContextAwareTagValueExpression.java:76)
        at org.apache.myfaces.view.facelets.tag.jsf.core.SetPropertyActionListenerHandler$SetPropertyListener.processAction(SetPropertyActionListenerHandler.java:125)
        at javax.faces.event.ActionEvent.processListener(ActionEvent.java:58)
        at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:412)
        at javax.faces.component.UICommand.broadcast(UICommand.java:55)
        at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:1238)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:411)
        at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1722)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:918)
        at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:43)
        at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:164)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:207)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
        at com.github.adminfaces.template.session.AdminFilter.doFilter(AdminFilter.java:145)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
        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.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
        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:64)
        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.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:292)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
        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.UndertowDeploymentTemplate$7$1$1.call(UndertowDeploymentTemplate.java:469)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:364)
        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1538)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1429)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:32)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)
tandraschko commented 5 years ago

Seems the issue is not closed and not fixed therefor

rmpestano commented 5 years ago

You're right, I made confusion with the other issue (the web-fragment.xml one) in v0.16 where the application didn't start

rmpestano commented 5 years ago

Guys, I found a way to fix this issue on our side, we just need to return Character instead of char in FacesContext getNamingContainerSeparatorChar method.

I don't know the implications but clients of this API will not be affected because o Java unboxing.

Following patch shows the classes affected:

Index: api/src/main/java/javax/faces/context/FacesContextWrapper.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- api/src/main/java/javax/faces/context/FacesContextWrapper.java  (revision d7075284b37dc3c4884f6e76558825d359c7b72f)
+++ api/src/main/java/javax/faces/context/FacesContextWrapper.java  (date 1560604557000)
@@ -266,7 +266,7 @@
     }

     @Override
-    public char getNamingContainerSeparatorChar()
+    public Character getNamingContainerSeparatorChar()
     {
         return getWrapped().getNamingContainerSeparatorChar();
     }
Index: impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImplBase.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImplBase.java (revision d7075284b37dc3c4884f6e76558825d359c7b72f)
+++ impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImplBase.java (date 1560604676000)
@@ -366,7 +366,7 @@
     }

     @Override
-    public char getNamingContainerSeparatorChar()
+    public Character getNamingContainerSeparatorChar()
     {
         if (_separatorChar == null)
         {
Index: api/src/main/java/javax/faces/context/FacesContext.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- api/src/main/java/javax/faces/context/FacesContext.java (revision d7075284b37dc3c4884f6e76558825d359c7b72f)
+++ api/src/main/java/javax/faces/context/FacesContext.java (date 1560604466000)
@@ -463,7 +463,7 @@
      * @since 2.2
      * @return 
      */
-    public char getNamingContainerSeparatorChar()
+    public Character getNamingContainerSeparatorChar()
     {
         FacesContext ctx = firstInstance.get();

Index: test/src/main/java/org/apache/myfaces/test/mock/MockFacesContext.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/src/main/java/org/apache/myfaces/test/mock/MockFacesContext.java   (revision d7075284b37dc3c4884f6e76558825d359c7b72f)
+++ test/src/main/java/org/apache/myfaces/test/mock/MockFacesContext.java   (date 1560604616000)
@@ -95,7 +95,7 @@
     }

     @Override
-    public char getNamingContainerSeparatorChar()
+    public Character getNamingContainerSeparatorChar()
     {
         if (_separatorChar == null)
         {
tandraschko commented 5 years ago

-1, thats a public API and aligned with mojarra Quarkus should fix it

tandraschko commented 5 years ago

@rmpestano please see my comment in the quarkus issue