Bug 50449

Summary: Methodexpression with arguments fails in JSF composite component
Product: Tomcat 7 Reporter: balusc <balusc>
Component: JasperAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED WORKSFORME    
Severity: normal CC: bernhard.keprt
Priority: P2    
Version: 7.0.5   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description balusc 2010-12-09 21:46:12 UTC
When a methodexpression with arguments is invoked in a JSF composite component, Tomcat 7.0.5 EL fails to locate the right method. This works fine in Glassfish 3.0.1, so it's likely not a JSF/Facelets issue.

Below testcase requires the Mojarra 2.0.3 API and Impl JAR's in /WEB-INF/lib.

test.xhtml
----------------------------------------
<!DOCTYPE html>
<html lang="en"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:cc="http://java.sun.com/jsf/composite/components">
    <h:head>
        <title>Test</title>
    </h:head>
    <h:body>
        <h1>Inline components</h1>
        <h:form>
            <h:commandButton value="submit without argument" 
                action="#{bean.submit}" />
            <h:commandButton value="submit with argument" 
                action="#{bean.submit('test')}" />
        </h:form>    
        <h1>Composite component</h1>
        <cc:test bean="#{bean}" />
    </h:body>  
</html>
----------------------------------------

resources/components/test.xhtml
----------------------------------------
<!DOCTYPE html>
<html lang="en"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:cc="http://java.sun.com/jsf/composite">
    <cc:interface>
        <cc:attribute name="bean" required="true" />
    </cc:interface>
    <cc:implementation>
        <h:form>
            <h:commandButton value="submit without argument" 
                action="#{cc.attrs.bean.submit}" />
            <h:commandButton value="submit with argument"
                action="#{cc.attrs.bean.submit('test')}" />
        </h:form>    
    </cc:implementation>
</html>
----------------------------------------

com.example.Bean
----------------------------------------
package com.example;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean
@RequestScoped
public class Bean {
    public void submit() { 
        System.out.println("submit");
    }
    
    public void submit(String string) {
        System.out.println("submit with string: " + string);
    }
}
----------------------------------------

When running on Tomcat 7.0.5, the submit with argument on a JSF composite component will submit to the method without argument. When the method without argument is outcommented in bean, a javax.el.MethodNotFoundException is been thrown. While not immediately visible in the stacktrace, under the covers Tomcat seems to be returning the wrong method for the method expression.
Comment 1 Mark Thomas 2010-12-12 16:21:35 UTC
The Mojarra download pages are currently empty so I tested 7.0.x (trunk) with MyFaces 2.0.2 and all works as expected.
Comment 2 Bernhard Keprt 2011-01-10 06:57:21 UTC
I also experience this problem.
I use Tomcat 7.0.5 BETA, JSF-SUN RI 2.0.2.

For me, its a message like this:
javax.el.MethodNotFoundException: /resources/components/sortableColumn.xhtml @22,74 action="#{cc.attrs.model.changeOrder('test', 'test')}": Method not found: at.compax.aax2sv.model.CollectionModel@4741e072.changeOrder()
Comment 3 Mark Thomas 2011-01-10 07:29:15 UTC
As I said, this works for me when tested with the provided test case.

If this doesn't work for you, you will need to provide the simplest a test case that demonstrates this.