views:

78

answers:

1

im getting this nasty exception, the problem is that i cannot control the get string since it's done by a 3rd party app. Apparently the number is too long to be parsed as int...

java.lang.NumberFormatException: For input string: "1286579871769"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    at java.lang.Integer.parseInt(Integer.java:461)
    at java.lang.Integer.valueOf(Integer.java:528)
    at ognl.OgnlParserTokenManager.makeInt(OgnlParserTokenManager.java:63)
    at ognl.OgnlParserTokenManager.TokenLexicalActions(OgnlParserTokenManager.java:1624)
    at ognl.OgnlParserTokenManager.getNextToken(OgnlParserTokenManager.java:1498)
    at ognl.OgnlParser.jj_ntk(OgnlParser.java:3099)
    at ognl.OgnlParser.unaryExpression(OgnlParser.java:1079)
    at ognl.OgnlParser.multiplicativeExpression(OgnlParser.java:971)
    at ognl.OgnlParser.additiveExpression(OgnlParser.java:894)
    at ognl.OgnlParser.shiftExpression(OgnlParser.java:750)
    at ognl.OgnlParser.relationalExpression(OgnlParser.java:508)
    at ognl.OgnlParser.equalityExpression(OgnlParser.java:405)
    at ognl.OgnlParser.andExpression(OgnlParser.java:352)
    at ognl.OgnlParser.exclusiveOrExpression(OgnlParser.java:299)
    at ognl.OgnlParser.inclusiveOrExpression(OgnlParser.java:246)
    at ognl.OgnlParser.logicalAndExpression(OgnlParser.java:193)

struts2 snippet:

<package name="ajax" namespace="/ajax" extends="default">

        <default-interceptor-ref name="ajaxStack"/>

        <action name="**">
            <result>/WEB-INF/ajax/{1}.jsp</result>
        </action>

    </package>

and the interceptor:

<interceptor-stack name="ajaxStack">                        
                <interceptor-ref name="checkSession" />
                <interceptor-ref name="checkAjax" />    
                <interceptor-ref name="defaultStack" />                                 
            </interceptor-stack>

checkAjax just makes sure the user is logged in and checkSession stores a session param in a threadlocal

A: 

The issue is not with OGNL parser, it's the Integer.parseInt() method. When we input a String to the Integer.parseInt method, it is not detected at compile time if the numeric value of the String is a number in range. The following code will show a compile time error:

Integer y = new Integer(3223232320); 

But the following will throw a runtime exception:

Integer y = new Integer("3223232320");
SidCool
understand, but the parseint shouldnt even be called by struts in this case to start w/. here's an explanation by one of the creators of struts, apparently ognl only understands ints? https://issues.apache.org/jira/browse/WW-386
Ricardo
So better convert it into String instead of Number (as in anything that is a java.lang.Number)
SidCool
i dont way to control the http get params, they're inserted by a 3rd party app
Ricardo