1 2 Previous Next 16 Replies Latest reply: Dec 2, 2010 1:59 PM by Marcin Kuthan RSS

[JBossAS6] Problem in EL. Method without Argument is fail.

n min Newbie

I using JBoss AS 6 M4, and JSF 2.0(Mojarra 2.0.2).

 

When the method without the argument in EL is used, the exception of EL is generated.

It succeeded when a similar thing was done with GlassFish 3.0 and JSF 2.0(Mojarra 2.0.2).

 

How should I correspond to this situation?
Please give advice.

 

-- Xhtml of Page --

<h:commandButton value="action1" action="#{testOfELManager.action1}"/>
<h:inputText value="#{testOfELManager.value1}"/>
<!-- Success -->
<h:outputText value="#{testOfELManager.methodWithParam('abc')}"/>
<!-- Error -->
<h:outputText value="#{testOfELManager.methodWithNonParam()}"/>

 

-- ManagedBean Class --

public class TestOfELManager implements Serializable {

 

    private String value1 = "v a l u e 1";

    public String getValue1() {
        return value1;
    }

    public void setValue1(String value1) {
        this.value1 = value1;
    }

 

 

    public String methodWithParam(String str) {
        return str + "["+ value1 +"]";
    }

 

    public String methodWithNonParam() {
        return value1;
    }

 

    public void action1() {
         System.out.println("action. value1=[" + value1 + "]");
     }

}

 

-- StackTrace of Error --

org.apache.el.parser.ParseException: Encountered " ")" ") "" at line 1, column 38.
Was expecting one of:
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <STRING_LITERAL> ...
    "true" ...
    "false" ...
    "null" ...
    "(" ...
    "!" ...
    "not" ...
    "empty" ...
    "-" ...
    <IDENTIFIER> ...
   
    at org.apache.el.parser.ELParser.generateParseException(ELParser.java:2195) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.jj_consume_token(ELParser.java:2077) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Unary(ELParser.java:951) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Multiplication(ELParser.java:711) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Math(ELParser.java:631) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Compare(ELParser.java:443) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Equality(ELParser.java:337) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.And(ELParser.java:281) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Or(ELParser.java:225) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Choice(ELParser.java:182) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Expression(ELParser.java:174) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Parameters(ELParser.java:1137) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.DotSuffix(ELParser.java:1060) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.ValueSuffix(ELParser.java:1032) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Value(ELParser.java:977) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Unary(ELParser.java:947) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Multiplication(ELParser.java:711) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Math(ELParser.java:631) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Compare(ELParser.java:443) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Equality(ELParser.java:337) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.And(ELParser.java:281) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Or(ELParser.java:225) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Choice(ELParser.java:182) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.Expression(ELParser.java:174) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.DeferredExpression(ELParser.java:112) [:6.0.0.20100721-M4]
    at org.apache.el.parser.ELParser.CompositeExpression(ELParser.java:40) [:6.0.0.20100721-M4]
    at org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:93) [:6.0.0.20100721-M4]
    at org.apache.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:150) [:6.0.0.20100721-M4]
    at org.apache.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:194) [:6.0.0.20100721-M4]
    at org.apache.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:68) [:6.0.0.20100721-M4]
    at com.sun.faces.facelets.tag.TagAttributeImpl.getValueExpression(TagAttributeImpl.java:378) [:2.0.2-FCS]
    at com.sun.faces.facelets.tag.TagAttributeImpl.getValueExpression(TagAttributeImpl.java:344) [:2.0.2-FCS]
    at com.sun.faces.facelets.tag.jsf.ValueHolderRule$DynamicValueExpressionMetadata.applyMetadata(ValueHolderRule.java:122) [:2.0.2-FCS]
    at com.sun.faces.facelets.tag.MetadataImpl.applyMetadata(MetadataImpl.java:74) [:2.0.2-FCS]
    at javax.faces.view.facelets.MetaTagHandler.setAttributes(MetaTagHandler.java:122) [:2.0.2-FCS]
    at javax.faces.view.facelets.DelegatingMetaTagHandler.setAttributes(DelegatingMetaTagHandler.java:96) [:2.0.2-FCS]
    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:153) [:2.0.2-FCS]
    at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114) [:2.0.2-FCS]
    at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91) [:2.0.2-FCS]
    at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120) [:2.0.2-FCS]
    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204) [:2.0.2-FCS]
    at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114) [:2.0.2-FCS]
    at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120) [:2.0.2-FCS]
    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204) [:2.0.2-FCS]
    at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114) [:2.0.2-FCS]
    at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91) [:2.0.2-FCS]
    at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:86) [:2.0.2-FCS]
    at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91) [:2.0.2-FCS]
    at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:75) [:2.0.2-FCS]
    at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:145) [:2.0.2-FCS]
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:716) [:2.0.2-FCS]
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106) [:2.0.2-FCS]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [:2.0.2-FCS]
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [:2.0.2-FCS]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313) [:2.0.2-FCS]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.0.0.20100721-M4]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.20100721-M4]
    at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:63) [:6.0.0.20100721-M4]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.20100721-M4]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.20100721-M4]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.0.0.20100721-M4]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:6.0.0.20100721-M4]
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0.20100721-M4]
    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.CR3]
    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.CR3]
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.20100721-M4]
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:93) [:6.0.0.20100721-M4]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.20100721-M4]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.20100721-M4]
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.20100721-M4]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.20100721-M4]
    at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.20100721-M4]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.20100721-M4]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.20100721-M4]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [:6.0.0.20100721-M4]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.20100721-M4]
    at java.lang.Thread.run(Thread.java:619) [:1.6.0_20]

  • 1. Re: [JBossAS6] Problem in EL. Method without Argument is fail.
    Stan Silvert Master

    Sorry I didn't notice this post sooner.  That looks like a bug in EL.  I'll look into it.

     

    Of course in the mean time, you can just say, #{testOfELManager.methodWithNonParam} instead of #{testOfELManager.methodWithNonParam()}

     

    Stan

  • 2. Re: [JBossAS6] Problem in EL. Method without Argument is fail.
    Stan Silvert Master

    I've filed a bug report on this.  Thanks for reporting it:

     

    https://jira.jboss.org/browse/JBAS-8374

     

    Stan

  • 3. Re: [JBossAS6] Problem in EL. Method without Argument is fail.
    Stan Silvert Master

    This should be fixed now.  The fix will be in the next AS6 release.

  • 4. Re: [JBossAS6] Problem in EL. Method without Argument is fail.
    Marcin Kuthan Newbie

    I'm still have a problem with method invocation from in EL:

    #{employeeViewController.toString()}

     

    toString() method is used to be sure that method exists, but I observed the same behaviour for business methods.

     

    The exception stack trace is different:

     

    javax.el.ELException: /employee/view.xhtml: The class 'package.EmployeeViewController' does not have the property 'toString'.
         at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:85)
         at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:78)
         at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:298)
         at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:101)
         at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
         at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643)
         at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
         at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
         at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:389)
         at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127)
         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117)
         at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)

     

    What is weird that EL (or Facelets) is looking for property not method. It looks that parentheses are ignored.

    My application is deployed on JBoss AS 6.0.0 CR1.

    Any help will be appreciated.

  • 5. Re: [JBossAS6] Problem in EL. Method without Argument is fail.
    Stan Silvert Master

    Hi Marcin,

     

    The only thing I can think of is that you might be using an old version of Facelets or EL?  Make sure Facelets is not bundled in your WAR.

     

    From the Mojarra 2.0.3 release notes:

     

    With JSF 2.0, there is now a set of rules that are followed to determine when the Facelets included with Mojarra 2.0.3  will be disabled.  See the following list:
     if /WEB-INF/faces-config.xml is versioned at 1.2 or older, JSF 2.0 Facelets will not be used.  Make sure the version and web-facesconfig.xml       schema reference are versioned at 2.0 
     If any of the faces-config.xml files reference the com.sun.facelets.FaceletViewHandler, JSF 2.0 Facelets will not be used.  This allows for easy migration compatibility for those applications that have direct dependencies on Facelet classes. 
    
    

     

    Regards,

     

    Stan

  • 6. Re: [JBossAS6] Problem in EL. Method without Argument is fail.
    Marcin Kuthan Newbie

    Hi Stan

     

    Thank you for the quick response.

     

    My application deployed on the Glassfish 3.0.1 (upgraded to Mojarra 2.0.3) doesn't throw an exception. The faces-config is defined within 2.0 namespace, and the only JSF related libarary in the WAR file is a primefaces.

    I will try to reproduce the issue with single-page example generated by Netbeans without any dependencies.

     

    The enclosed stack trace was copied from facelet page, in the app server log file I found that at the end of each line [:2.0.3-SNAPSHOT] suffix exists:

     

    at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:85) [:2.0.3-SNAPSHOT]

     

    It doesn't come from my artifacts. Maybe it helps you in some way.

     

    Thanks,

    Marcin

  • 7. Re: [JBossAS6] Problem in EL. Method without Argument is fail.
    Marcin Kuthan Newbie

    Easliy reproduced in helloworld like application:

     

    @ManagedBean(name = "elManagedBean")
    public class ElManagedBean {

     

        public String hello() {
        return "Hello";
        }
    }

     

    Facelet fragment:

     

    <ui:composition template="template.xhtml">
        <ui:define name="header">
            Add your header here or delete to use the default
        </ui:define>
        <ui:define name="content">
            Add your content here or delete to use the default
            #{elManagedBean.hello()}
        </ui:define>
        <ui:define name="footer">
            Add your footer here or delete to use the default
        </ui:define>
    </ui:composition>

     

    And stack trace:

     

    javax.el.ELException: /jsf.xhtml: The class 'test.ElManagedBean' does not have the property 'hello'.
         at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:85)
         at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:78)
         at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:179)
         at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
         at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:389)
         at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127)
         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117)
         at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181)
         at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285)
         at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261)
         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88)
         at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
         at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)
         at java.lang.Thread.run(Thread.java:619)
  • 8. Re: [JBossAS6] Problem in EL. Method without Argument is fail.
    Stan Silvert Master

    OK.  I'll take another look at this issue.

     

    Stan

  • 9. Re: [JBossAS6] Problem in EL. Method without Argument is fail.
    Stan Silvert Master

    I tried this with my app and it works just fine.  Can you attach a simple war that reproduces the problem?

     

    Stan

  • 10. Re: [JBossAS6] Problem in EL. Method without Argument is fail.
    Marcin Kuthan Newbie

    Hi Stan

     

    The sample WAR is enclosed. The test page is located under:

    http://localhost:8080/stack-test/jsf.xhtml

     

    To be sure, my environment:

    jboss-6.0.0.20101110-CR1

    default domain

    additional libs: mysql driver

    datasource configuration for mysql db

     

     

    Thanks,

    Marcin

  • 11. Re: [JBossAS6] Problem in EL. Method without Argument is fail.
    Stan Silvert Master

    Hi Marcin,

     

    It looks to me like this is working as expected.  This has nothing to do with a lack of arguments.

     

    Your expression, #{elManagedBean.hello()} is being treated as a ValueExpression.  If you changed your method to getHello() then it would work.

     

    The question is, should it be treated as a ValueExpression or a MethodExpression?  For instance, if you had the same expression in an action attribute it would be treated as a MethodExpression.

    <h:commandButton value="Hello" action="#{elManagedBean.hello()}" id="submit_button"/>
    

     

    You have put the expression in the middle of the Facelets page and not as the value of an attribute.  As far as I know, this will always be treated as a ValueExpression.  I don't see how this would work in Glassfish.  It's possible that there is some code that tries it out as a ValueExpression and then tries it as a MethodExpression if it fails.  However, I think that would go against the EL spec.  In other words, I'm surprised that this would work on Glassfish.

     

    Stan

  • 12. Re: [JBossAS6] Problem in EL. Method without Argument is fail.
    Marcin Kuthan Newbie

    Hi Stan

     

    I appreciate your explanation but I don't agree with you. If I want to access property I will use the following statement:

     

    elManagedBean.hello

    With brackets I expect method invocation instead of property access.

     

    I'm not an expert in programming language design but EL expression evaluation should be independent of place where the expression is used. Different interpretation in "action" attribute and in the middle of facelet is weird. The inline expression elManagedBean.hello() should be equivalent to the <h:outputText value="elManagedBean.hello()"/>. I suppose that <h:outputText .../> also throws an exception (I don't have JBoss runtime to check, now).

     

    If the EL is interpretted as you described it suks, IMHO. I'm wondering how it is defined in the spec, I will check :-)

     

    Many thanks,

    Marcin

  • 13. Re: [JBossAS6] Problem in EL. Method without Argument is fail.
    Marcin Kuthan Newbie

    Hi

     

    After quick look at specifications I must admit that EL method evaluation in JBoss AS is 100% fine :-(

     

    Even more, the () braces should not be allowed as a method expression (only for functions and operators precedence)! See chapter 1.2.1.2 in the EL specification.

    To pass method parameters use [] braces. See chapter 1.6 in EL specification.

     

    JSF spec in chapter 5.2 defines where the expression are evaluated as method (action, actionListener, validator).

     

    Weird, and not intuitive really ... . I have to read specification to understand "simple" language. Does anyone know how to integrate Freemarker into JSF ...?

     

    Marcin

  • 14. Re: [JBossAS6] Problem in EL. Method without Argument is fail.
    Stan Silvert Master

    I think you might be looking at EL 2.1 instead of EL 2.2.  Params are now allowed to designate arguments passed to methods.  In both specs, the use of [] braces is equivalent to using a dot '.'

     

    Yes, it's all very weird and confusing.  There are historical reasons why things are the way that are though.  The issue remains that EL doesn't actually define whether something is treated as a ValueExpression or a MethodExpression.  This decision is made by the technology that is using the EL: namely JSP, JSP taglibs in JSF 1.x, or Facelets in JSF 2.x.

     

    Stan

1 2 Previous Next