1 Reply Latest reply on Nov 2, 2018 2:10 PM by Rich DiCroce

    Java 8 default method throws EL PropertyNotFoundException (Wildfly 14, Java EE 8, JSF 2.3)

    Karsten Wutzke Expert

      I have a Java 8 interface for managing instances read from the DB, e.g. in a JSF datatable.

       

          public interface Manager<T> extends Serializable
          {
              public List<T> getEntities();
              public void setEntities( List<T> entities );
          
              // another default method
              default public void clearEntities()
              {
                  this.setEntities( null );
              }
          
              ...
              
              // this is what it is all about
              default public boolean isReadOnly()
              {
                  // user can generally create new entities...
                  return false;
              }
          }

       

      Base class is:

       

          public abstract class BaseManager<T> implements Manager<T>
          {
              private static final long serialVersionUID = 1L;
          
              protected List<T> entities;
              
              @Override
              public List<T> getEntities()
              {            
                  return this.entities;
              }
              
              @Override
              public void setEntities( List<T> entities )
              {
                  this.entities = entities;
              }
      
              ...
          }

       

      Implementing class:

       

          @Named
          @ViewScoped
          public class UserManager extends BaseManager<User>
          {
              private static final long serialVersionUID = 1L;
              
              // assume working CDI EJB
              @Inject
              private UserService userService;
              
              @PostConstruct
              @Override
              public void init()
              {
                  // load on init
                  try
                  {
                      this.setEntities( this.userService.findAll() );
                  }
                  catch ( RetrieveException e )
                  {
                      e.printStackTrace();
                  }
              }
              
              ...
          }

       

      The page with the datatable looks like this:

       

      <p:dataTable id="data"

                   widgetVar="userDataTable"

                   value="#{userManager.entities}"

                   var="usr"

                   rowKey="#{usr.id}"

                   selection="#{userManager.selectedEntity}"

                   selectionMode="single"

                   emptyMessage="No users found.">

       

          <f:facet name="header">

              <h:panelGroup id="header"

                            layout="block">

                  <p:commandButton id="add-user-button"

                                   icon="ui-icon ui-icon-document"

                                   value="Add user"

                                   action="#{userManager.add()}"

                                   process="@this"

                                   update=":content-form"

                                   disabled="#{userManager.readOnly}">

                  </p:commandButton>

              </h:panelGroup>

          </f:facet>

      </p:dataTable>

       

       

      When rendering this, I get a PropertyNotFoundException on the call to the Java 8 default method `isReadOnly()` (disabled attribute):

       

          01:13:53,315 FATAL [javax.enterprise.resource.webcontainer.jsf.context] (default task-1) JSF1073: javax.el.PropertyNotFoundException caught during processing of RENDER_RESPONSE 6 : UIComponent-ClientId=, Message=/home.xhtml @94,72 disabled="#{userManager.readOnly}": The class 'org.project.myone.view.UserManager' does not have the property 'readOnly'.
          01:13:53,316 FATAL [javax.enterprise.resource.webcontainer.jsf.context] (default task-1) /home.xhtml @94,72 disabled="#{userManager.readOnly}": The class 'org.project.myone.view.UserManager' does not have the property 'readOnly'.: javax.el.PropertyNotFoundException: /home.xhtml @94,72 disabled="#{userManager.readOnly}": The class 'org.project.myone.view.UserManager' does not have the property 'readOnly'.
              at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:117)
              at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:200)
              at javax.faces.component.html.HtmlCommandButton.isDisabled(HtmlCommandButton.java:197)
              at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeMarkup(CommandButtonRenderer.java:68)
              at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeEnd(CommandButtonRenderer.java:54)
              at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:949)
              at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:317)
              at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:114)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:918)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1905)
              at org.primefaces.component.datatable.DataTableRenderer.encodeFacet(DataTableRenderer.java:1467)
              at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:351)
              at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:94)
              at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:949)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1912)
              at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:918)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1905)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1908)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1908)
              at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:491)
              at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:194)
              at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:151)
              at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:151)
              at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:126)
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:223)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:671)
              at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
              at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
              at io.opentracing.contrib.jaxrs2.server.SpanFinishingFilter.doFilter(SpanFinishingFilter.java:55)
              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 org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
              at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
              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.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 org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
              at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
              at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
              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 org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
              at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
              at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
              at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
              at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
              at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
              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:360)
              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:1985)
              at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
              at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
              at java.lang.Thread.run(Thread.java:748)
          Caused by: javax.el.PropertyNotFoundException: The class 'org.project.myone.view.UserManager' does not have the property 'readOnly'.
              at javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:568)
              at javax.el.BeanELResolver.getValue(BeanELResolver.java:229)
              at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:180)
              at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:208)
              at com.sun.el.parser.AstValue.getValue(AstValue.java:139)
              at com.sun.el.parser.AstValue.getValue(AstValue.java:203)
              at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
              at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
              at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
              at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:115)
              ... 74 more

       

      I checked the JSF version via:

       

          JSF Version = #{facesContext.class.package.implementationTitle} #{facesContext.class.package.implementationVersion}

       

      Output is:

       

      `JSF Version = Mojarra 2.3.5.SP2`

       

      It all happens on Wildfly 14, faces-config version is 2.3.

       

      QUESTION:

       

      What's wrong? Why is JSF 2.3 complaining about a Java 8 default method here? I thought JSF 2.3 is Java-8-ready...

       

      Note:

      From the stacktrace it appears to be an EL problem. But why is Wildfly 14 EL complaining? I assume it has the latest EL.

       

      My web.xml has the following content:

       

      <?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_SKIP_COMMENTS</param-name>

              <param-value>true</param-value>

          </context-param>

         

          <context-param>

              <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>

              <param-value>true</param-value>

          </context-param>

         

          <context-param>

              <param-name>javax.faces.PROJECT_STAGE</param-name>

              <param-value>Development</param-value>

          </context-param>

         

          <context-param>

              <param-name>primefaces.THEME</param-name>

              <param-value>avalon-#{uiHelper.themeColor}</param-value>

          </context-param>

         

          <context-param>

              <param-name>primefaces.FONT_AWESOME</param-name>

              <param-value>true</param-value>

          </context-param>

             

      </web-app>

       

      Can anybody help please?

       

      Thanks

      Karsten

       

      PS: The JS text tool here to write postings, especially the language formatting, is really bad. It swallows code and formatting doesn't work 100%.