Skip to content

f:ajax component produces an IllegealArgumentException when providing a listener with the correct method signature #2010

@ren-zhijun-oracle

Description

@ren-zhijun-oracle

I have an f:ajax tag with a listener defined (in a composite component). <f:ajax listener="#

{cc.attrs.closeListener}

" render="#

{cc.attrs.onCloseUpdate}

"/>
The listener has the signature: public void actionListener(AjaxBehaviorEvent event). This method is provided as a composite component attribute.

The method AjaxBehaviorListenerImpl.processAjaxBehaviour tries to call the no-Arg version of the listener method. It then catches a MethodNotFoundException and then calls the correct method with the AjaxBehaviorEvent parameter.
The problem is that when calling my method without an argument the NativeMethodAccessorImpl throws a IllegealArgumentException and this Exception is nowhere converted to a MethodNotFoundException.

The interface of java.lang.reflect.Method.invoke allows the IllegealArgumentException to occur, but the javax.el.MethodExpression.invoke does not. I guess somewhere in the chain this should be converted (in el, weld or JSF)? Or the AjaxBehaviorListenerImpl.processAjaxBehavior needs to catch the IllegealArgumentException as well?

Stacktrace:

NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
AstValue.invoke(EvaluationContext, Class[], Object[]) line: 234
MethodExpressionImpl.invoke(ELContext, Object[]) line: 297
WeldMethodExpression(ForwardingMethodExpression).invoke(ELContext, Object[]) line: 43
WeldMethodExpression.invoke(ELContext, Object[]) line: 56
ContextualCompositeMethodExpression.invoke(ELContext, Object[]) line: 177
TagAttributeImpl$AttributeLookupMethodExpression.invoke(ELContext, Object[]) line: 450
AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxBehaviorEvent) line: 447
AjaxBehaviorEvent.processListener(FacesListener) line: 113
AjaxBehavior(BehaviorBase).broadcast(BehaviorEvent) line: 102
CloseWindowButton(UIComponentBase).broadcast(FacesEvent) line: 760
CloseWindowButton(UICommand).broadcast(FacesEvent) line: 300
UIViewRoot.broadcastEvents(FacesContext, PhaseId) line: 794
UIViewRoot.processApplication(FacesContext) line: 1259
InvokeApplicationPhase.execute(FacesContext) line: 81
...

Environment

Glassfish 3.1 Final with JSF 2.1 and Weld

Affected Versions

[2.1.0]

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions