View Full Version : webflow-2.2.1 upgraded - java.lang.ArrayIndexOutOfBoundsException:
trieder
Dec 29th, 2010, 10:58 AM
I upgrade SWF to 2.2.1 (spring-integration-2.0.1, spring-framework-3.0.5)
Since then i get error on all my form:select fields.
I don't see where exaclty the the relation to swf is, but it just stopped working after the webflow upgrade (from 2.0.8)
<tr>
<td>Land*</td>
<td>
<form:select path="countryId">
<form:option value="1" label="India" />
</form:select>
</td>
<td>
</td>
</tr>
<view-state id="userdetails" view="/gameshop/user/orderuserdetails" model="order">
<binder>
<binding property="username" />
<binding property="customerName" />
<binding property="customerSurname" />
<binding property="customerAddressAddOn" />
<binding property="customerStreet" />
<binding property="customerZip" />
<binding property="customerCity" />
<binding property="countryId" />
<binding property="customerBirthDate"/>
<binding property="telNumber" />
<binding property="comment" />
</binder>
<on-render>
<evaluate expression="showContentController.getBasicModel(externalContex t)" result="viewScope.model"/>
<set name="flowScope.userId" value="userManager.getUserIdByEmail(currentUser?.name)"/>
<evaluate expression="shopManager.getCountryList()" result="viewScope.countryList"/>
<evaluate expression="checkoutActionController.initOrderUserDetails" />
</on-render>
<transition on="next" to="orderpaymentoptions">
<evaluate expression="checkoutActionController.updateUserDetails" />
</transition>
<transition on="back" to="orderdetails" bind="false"/>
<transition on="login" to="login" bind="false"/>
</view-state>
Is this my fault or is swf 2.2.1 brocken?
trieder
Dec 29th, 2010, 11:01 AM
2010-12-29 17:30:27,692 DEBUG [org.springframework.core.convert.support.GenericCo nversionService] - <Looking for Converter to convert from [TypeDescriptor java.lang.String] to [TypeDescriptor java.lang.String]>
2010-12-29 17:30:27,692 DEBUG [org.springframework.core.convert.support.GenericCo nversionService] - <Conditional converter lookup [MATCHED] org.springframework.core.convert.support.ObjectToS tringConverter@1dc2e34>
2010-12-29 17:30:27,693 ERROR [org.springframework.web.servlet.tags.form.SelectTa g] - <-1>
java.lang.ArrayIndexOutOfBoundsException: -1
at org.springframework.core.MethodParameter.getParame terAnnotations(MethodParameter.java:233)
at org.springframework.core.convert.support.PropertyT ypeDescriptor.getAnnotations(PropertyTypeDescripto r.java:111)
at org.springframework.core.convert.TypeDescriptor.to String(TypeDescriptor.java:447)
at java.lang.String.valueOf(String.java:2826)
2010-12-29 17:30:27,703 DEBUG [org.springframework.webflow.engine.impl.FlowExecut ionImpl] - <Attempting to handle [org.springframework.webflow.execution.FlowExecutio nException: Exception thrown in state 'userdetails' of flow 'checkout'] with root cause [java.lang.ArrayIndexOutOfBoundsException: -1]>
2010-12-29 17:30:27,703 DEBUG [org.springframework.webflow.engine.impl.FlowExecut ionImpl] - <Rethrowing unhandled flow execution exception>
2010-12-29 17:30:27,703 DEBUG [org.springframework.webflow.conversation.impl.Sess ionBindingConversationManager] - <Unlocking conversation 1>
2010-12-29 17:30:27,703 DEBUG [org.springframework.web.servlet.handler.SimpleMapp ingExceptionResolver] - <Resolving exception from handler [org.springframework.webflow.mvc.servlet.FlowContro ller@9213b1]: org.springframework.webflow.execution.FlowExecutio nException: Exception thrown in state 'userdetails' of flow 'checkout'>
2010-12-29 17:30:27,703 DEBUG [org.springframework.web.servlet.handler.SimpleMapp ingExceptionResolver] - <Resolving to view 'error' for exception of type [org.springframework.webflow.execution.FlowExecutio nException], based on exception mapping [java.lang.Exception]>
2010-12-29 17:30:27,703 DEBUG [org.springframework.web.servlet.handler.SimpleMapp ingExceptionResolver] - <Exposing Exception as model attribute 'showException'>
2010-12-29 17:30:27,703 DEBUG [org.springframework.web.servlet.DispatcherServlet] - <Handler execution resulted in exception - forwarding to resolved error view: ModelAndView: reference to view with name 'error'; model is {showException=org.springframework.webflow.executi on.FlowExecutionException: Exception thrown in state 'userdetails' of flow 'checkout'}>
org.springframework.webflow.execution.FlowExecutio nException: Exception thrown in state 'userdetails' of flow 'checkout'
at org.springframework.webflow.engine.impl.FlowExecut ionImpl.wrap(FlowExecutionImpl.java:569)
at org.springframework.webflow.engine.impl.FlowExecut ionImpl.resume(FlowExecutionImpl.java:263)
at org.springframework.webflow.executor.FlowExecutorI mpl.resumeExecution(FlowExecutorImpl.java:169)
at org.springframework.webflow.mvc.servlet.FlowHandle rAdapter.handle(FlowHandlerAdapter.java:183)
at org.springframework.webflow.mvc.servlet.FlowContro ller.handleRequest(FlowController.java:174)
Caused by: org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/checkout/include_orderuserdetails.jsp at line 82
79: <tr>
80: <td>Land*</td>
81: <td>
82: <form:select path="countryId">
83: <form:option value="1" label="India" />
84: </form:select>
85: </td>
Stacktrace:
at org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:510)
at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:419)
at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:260)
trieder
Dec 29th, 2010, 01:50 PM
I found a workaround. but still i think this is not the right behavior.
public class ApplicationConversionService extends DefaultConversionService {
@Override
protected void addDefaultConverters() {
super.addDefaultConverters();
super.addDefaultAliases();
// registers a custom converter reference-able by id and applied when requested
StringToDate myStringToDate = new StringToDate();
myStringToDate.setPattern("yyyy-MM-dd");
addConverter(myStringToDate);
addConverter(myStringToDate);
//addConverter(new StringToInteger());
addConverter("intConverter", new StringToInteger());
addConverter("boolConverter", new StringToBoolean());
addConverter("floatConverter", new StringToFloat());
addConverter("shortDate", new StringToDate());
}
}
<binder>
<binding property="username" />
<binding property="customerName" />
<binding property="customerSurname" />
<binding property="customerAddressAddOn" />
<binding property="customerStreet" />
<binding property="customerZip" />
<binding property="customerCity" />
<binding property="countryId" converter="intConverter"/>
<binding property="customerBirthDate" converter="shortDate"/>
<binding property="telNumber" />
<binding property="comment" />
</binder>
why must i convert simple types?
zenith.fox
Dec 29th, 2010, 02:29 PM
I don't think you need to convert integer.
If you added datatimeformat annotation and put jodatime in your class path, you don't need to convert date either.
The problem might be caused by other reasons.
The out of bound problem might be caused by the label "India". you can try to put both the value and the label of the form option "1".
zenith.fox
Dec 29th, 2010, 02:34 PM
By the way, it would be better if you define a enum for country names.
Then, you can put both the value and the label to country names. In this case, you do not need to remember the mapping between numbers and country names yourself.
Spring can correctly convert string to enum types.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.