struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nabeel Saad <nabeeliph...@gmail.com>
Subject <select> field value causing NumberFormatException and breaking Action
Date Fri, 15 Oct 2010 15:24:47 GMT
Hello folks,

I'm working on a project to upgrade a JBoss Portal community platform to a
supported version of JBoss Enterprise Portal Platform.

During the process, I've gotten the platform building and functioning mostly
normally.  I have one issue that is completely blocking me for the moment.
 There is a portlet that pretty much searches for users that is currently
failing.  All you do is fill in a form (a dropdown [called searchType] with
the type of data your are providing - username, address, card number, etc...
- the value for that data and a post code) and it searches for the user and
returns the results of the search.

However, when I click on the search button, I get re-directed to the search
page and the attached "debug_stack_trace" is thrown in the JBoss console.
 What I've understood from the trace and from my research and testing, is
that the dropdown field searchType is returning data that is breaking its
conversion into a number, thus the NumberFormatException.

Method "setSearchType" failed for object
com.client.user.search.action.SearchCustomerAction@5524c895[java.lang.NoSuchMethodException:
setSearchType([Ljava.lang.String;)]

This error does make sense because it's trying to assign the value of
searchType to the field in the class; however, searchType is actually
expected to be an int, and somehow it's receiving a String or the fact that
it's failing to convert it to a Number, then it says I can't find a method
that takes String for setSearchType...

I ran through the code, and was able to find exactly where it broke.  In
OgnlTypeConverterWrapper.convertValue the method returns
"ognl.NoConversionPossible" which causes OgnlRuntime.getConvertedTypes to
return false.

Clearly xwork is not able to convert my property, the last two lines before
the NumberFormatException are:

[XWorkConverter] field-level type converter for property [searchType] = none
found
[XWorkConverter] global-level type converter for property [searchType] =
none found

However, what I don't get is that this is core Struts functionality,
correct?  And my project, using maven dependencies, depends on struts2-core
which in turn depends on xwork-2.1.1.  So, I don't get why this is now
breaking.

One of the things that I have noticed is the line saying:

[ParametersInterceptor] Setting params struts.portlet.mode => [ view ]
dynamicAttributes => [ {} ] struts.portlet.action => [ /view/view/search ]
templateDir => [ template ] theme => [ simple ] value => [
*testuser52testuser52,
testuser52* ] searchType => [ *11, 1* ] postcode => [ ,  ]

Note the text in *bold*.  These are the values that I have entered in the
form; however, it is duplicated in the debug output!!  The actual value that
I input was only testuser52 and 1.  But somehow, somewhere in the struts
mechanism (I think), these parameters were duplicated twice, once in the
value stored in the first index of the array and another as a second value
in the second index of the array.  When I ran the original platform, the
parameter look like this:

[ParametersInterceptor] Setting params struts.portlet.mode => [ view ]
dynamicAttributes => [ {} ] struts.portlet.action => [ /view/view/search ]
templateDir => [ template ] theme => [ simple ] value => [ *testuser52* ]
searchType => [ *1* ] postcode => [ ,  ]

I've ran the code through a debugger in Ecipse while running in JBoss to try
and see what was happening.. first of all, the duplication is happening at
the lowest level of reading that I can see...  whenever there is a
getParameters() type call anywhere (even in xwork.ActionContext), the
parameters are already duplicated.  So, I'm wondering if this duplication
isn't happening when the parameters are "written". I'm not even sure the
duplication would affect the final output of my portlet (although, I suspect
it would given that the "main" value is corrupted by being duplicated) but
I'm just trying to figure out the different possible reasons for this
portlet to break.

So in summary, I think the problems I have are:
1. Parameters duplicated in request parameters somehow
2. xwork converter fails to convert my searchType String of value { 11, 1}
(an array) to an int.

Any thoughts would be much appreciated as I've been stuck on this issue for
about a week now.

Cheers,
Nabeel

Mime
View raw message