Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

IllegalArgumentException: argument type mismatch from InputTextTag

843842Jul 30 2004 — edited Jul 30 2004
I've attempted to put together a very simple JSF app to try to get a better understanding of how managed backing beans are treated by the framework. My first jsp page blows up on the doStartTag of the first inputText tag on the page. Here's the exception thrown by the tag:
javax.faces.el.EvaluationException: java.lang.IllegalArgumentException: argument type mismatch
	com.sun.faces.el.ValueBindingImpl.setValue(ValueBindingImpl.java:266)
	com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:396)
	javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1018)
	javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1045)
	javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:742)
	javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:423)
	com.sun.faces.taglib.html_basic.InputTextTag.doStartTag(InputTextTag.java:506)
	org.apache.jsp.start_jsp._jspx_meth_h_inputText_0(start_jsp.java:176)
This is caused by this exception, which shows up in tomcat logs:
Caused by: java.lang.IllegalArgumentException: argument type mismatch
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at com.sun.faces.el.PropertyResolverImpl.setValue(PropertyResolverImpl.java:178)
	at com.sun.faces.el.impl.ArraySuffix.setValue(ArraySuffix.java:192)
	at com.sun.faces.el.impl.ComplexValue.setValue(ComplexValue.java:171)
	at com.sun.faces.el.ValueBindingImpl.setValue(ValueBindingImpl.java:234)
This app is really simple, and I've gone back and forth between my code and the JSF samples, which all work fine, and don't see what they're doing that I'm not. This is on Tomcat 5.0.16 with JSF 1.1. Here is my code:

start.jsp:
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>start.jsp</title>
  </head>
  <body>
    <f:view>
      <h:form>
      	<div>
	      	<label for="unitsInput">Units:</label>
	      	<h:inputText id="unitsInput" binding="#{wizard.units}" required="true">
	      		<%-- f:validateLongRange minimum="1" maximum="100"/ --%>
	      	</h:inputText>
	      	<h:message for="unitsInput"/>
      	</div>
      	<div>
      		<label for="blahBlah">Note:</label>
      		<h:inputTextarea id="blahBlah" binding="#{wizard.note}"/>
      	</div>
      	<h:commandButton action="#{wizard.submitFirst}"/>
      </h:form>
      <%@include file="wizardOutput.jspf" %>
    </f:view>
    <jsp:include page="request_info.jsp"/>
  </body>
</html>
As you can see, I've commented out the LongRangeValidator so that the units field is being treated like a String. In the below file, I started with units as an Integer, but then changed to String thinking that might have been the cause of the error. No joy though.

Wizard.java:
package jsfapp;

public class Wizard {
    private String units;
    private String productId;
    private String note;
    private String note2;
    
    public String getNote() {
        return this.note;
    }
    public void setNote(String note) {
        this.note = note;
    }
    public String getProductId() {
        return this.productId;
    }
    public void setProductId(String productId) {
        this.productId = productId;
    }
    public String getUnits() {
        return this.units;
    }
    public void setUnits(String units) {
        this.units = units;
    }
    public String getNote2() {
        return this.note2;
    }
    public void setNote2(String note2) {
        this.note2 = note2;
    }
    
    public String submitFirst() {
        System.out.println("submitFirst called!  units="+units+" productId="+productId+" note="+note+" note2="+note2);
        return "success";
    }
    
    public String submitSecond() {
        System.out.println("submitSecond called!  units="+units+" productId="+productId+" note="+note+" note2="+note2);
        return "success";
    }
}
faces-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
	<managed-bean>
		<managed-bean-name>wizard</managed-bean-name>
		<managed-bean-class>jsfapp.Wizard</managed-bean-class>
		<managed-bean-scope>session</managed-bean-scope>
		<managed-property>
			<property-name>note2</property-name>
			<value>This is note2 from faces-config.xml!</value>
		</managed-property>
	</managed-bean>
	<navigation-rule>
		<from-view-id>/start.jsp</from-view-id>
		<navigation-case>
			<from-outcome>success</from-outcome>
			<to-view-id>/second.jsp</to-view-id>
		</navigation-case>
	</navigation-rule>
	<navigation-rule>
		<from-view-id>/second.jsp</from-view-id>
		<navigation-case>
			<from-outcome>success</from-outcome>
			<to-view-id>/thanks.jsp</to-view-id>
		</navigation-case>
	</navigation-rule>
	<navigation-rule>
		<from-view-id>/thanks.jsp</from-view-id>
		<navigation-case>
			<from-outcome>start</from-outcome>
			<to-view-id>/start.jsp</to-view-id>
		</navigation-case>
	</navigation-rule>
</faces-config>
Any help to see what I'm missing would be greatly appreciated.
-john.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 27 2004
Added on Jul 30 2004
2 comments
371 views