You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "shenjc (Created) (JIRA)" <ji...@apache.org> on 2011/10/28 04:05:37 UTC

[jira] [Created] (WW-3695) XWorkConverter catch XWorkException so that the client application can't get the detail original error message

XWorkConverter catch XWorkException so that the client application can't get the detail original error message
--------------------------------------------------------------------------------------------------------------

                 Key: WW-3695
                 URL: https://issues.apache.org/jira/browse/WW-3695
             Project: Struts 2
          Issue Type: Improvement
          Components: Other
    Affects Versions: 2.2.1.1
            Reporter: shenjc


in com.opensymphony.xwork2.conversion.impl.XWorkConverter line 331 to 341
            try {
                if (LOG.isDebugEnabled())
                    LOG.debug("falling back to default type converter [" + defaultTypeConverter + "]");
                return defaultTypeConverter.convertValue(context, target, member, property, value, toClass);
            } catch (Exception e) {
                if (LOG.isDebugEnabled())
                    LOG.debug("unable to convert value using type converter [#0]", e, defaultTypeConverter.getClass().getName());
                handleConversionException(context, property, value, target);

                return TypeConverter.NO_CONVERSION_POSSIBLE;
            }
here try catch code "defaultTypeConverter.convertValue" so that it can not throw exception to outside.
in some case,for example:
when I transmit a param a bigInteger to Integer in a action.
the program will run pass and ignore this exception,the outside program can't catch it ,so that can't find what cause the error.
and it only print in log file:
com.opensymphony.xwork2.util.logging.commons.CommonsLogger.debug(72) | unable to convert value using type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter]
Overflow or underflow casting: "3322333330" into class java.lang.Long - [unknown location]

and we need to find this  error message in large debug log message;
 
I think, throw this exception and not catch it here,and change log level from debug to error when print this message will better,isn't it ?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (WW-3695) XWorkConverter catch XWorkException so that the client application can't get the detail original error message

Posted by "Maurizio Cucchiara (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3695?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Maurizio Cucchiara closed WW-3695.
----------------------------------

    Resolution: Not A Problem
      Assignee: Maurizio Cucchiara

First add the input result to your action configuration:
{code}
@Result(name = "input", location = "/WEB-INF/pages/test/test_input.ftl", type = "freemarker")
{code}
Then print your field errors with the specific xml tag:
{code}
<@s.fielderror/>
{code}

Please, next time ask this kind of question to the [user ML|http://struts.apache.org/mail.html].
                
> XWorkConverter catch XWorkException so that the client application can't get the detail original error message
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-3695
>                 URL: https://issues.apache.org/jira/browse/WW-3695
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Other
>    Affects Versions: 2.2.1.1
>            Reporter: shenjc
>            Assignee: Maurizio Cucchiara
>
> in com.opensymphony.xwork2.conversion.impl.XWorkConverter line 331 to 341
> {code}
> try {
>     if (LOG.isDebugEnabled())
>         LOG.debug("falling back to default type converter [" + defaultTypeConverter + "]");
>     return defaultTypeConverter.convertValue(context, target, member, property, value, toClass);
> } catch (Exception e) {
>     if (LOG.isDebugEnabled())
>         LOG.debug("unable to convert value using type converter [#0]", e, defaultTypeConverter.getClass().getName());
>     handleConversionException(context, property, value, target);
>     return TypeConverter.NO_CONVERSION_POSSIBLE;
> }
> {code}
> here try catch code "defaultTypeConverter.convertValue" so that it can not throw exception to outside.
> in some case,for example:
> when I transmit a param a bigInteger to Integer in a action.
> the program will run pass and ignore this exception,the outside program can't catch it ,so that can't find what cause the error.
> and it only print in log file:
> {noformat}
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger.debug(72) | unable to convert value using type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter]
> Overflow or underflow casting: "3322333330" into class java.lang.Long - [unknown location]
> {noformat}
> and we need to find this  error message in large debug log message;
>  
> I think, throw this exception and not catch it here,and change log level from debug to error when print this message will better,isn't it ?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WW-3695) XWorkConverter catch XWorkException so that the client application can't get the detail original error message

Posted by "shenjc (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3695?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13140006#comment-13140006 ] 

shenjc commented on WW-3695:
----------------------------

thanks for replying, here provide a simple test case bellow:

@Namespace("/test")
public class TestSimpleAction extends ActionSupport {
	
	private static final long serialVersionUID = 1957094271415003053L;
	
	protected transient Logger logger = LoggerFactory.getLogger(getClass());
	
	private Integer param1;	

	public Integer getParam1() {
		return param1;
	}

	public void setParam1(Integer param1) {
		this.param1 = param1;
	}
	

	@Action(value="test1", 
		    results={@Result(name="success", location="/WEB-INF/pages/test/testSimple.ftl", type="freemarker"),
			@Result(name="error",location="/WEB-INF/pages/test/test_error.ftl", type="freemarker" )}
		  )
	public String test1() {
		return SUCCESS;
	}
	
}


when param1=1234567890
http://localhost/test/test1.do?param1=1234567890 execute correct;
but when when param1=2234567890
http://localhost/test/test1.do?param1=2234567890 there are some error:

 DEBUG ny.xwork2.conversion.impl.XWorkConverter(72) -unable to convert value using type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter]
Overflow or underflow casting: "2634567890" into class java.lang.Long - [unknown location]
	at com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.doConvertToNumber(XWorkBasicConverter.java:431)
	at com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.doConvertToNumber(XWorkBasicConverter.java:440)
	at com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.convertValue(XWorkBasicConverter.java:130)
	at com.opensymphony.xwork2.conversion.impl.XWorkConverter.convertValue(XWorkConverter.java:334)
	at com.opensymphony.xwork2.ognl.OgnlTypeConverterWrapper.convertValue(OgnlTypeConverterWrapper.java:39)
	at ognl.OgnlRuntime.getConvertedType(OgnlRuntime.java:1060)
...
...
WARN  .opensymphony.xwork2.ognl.OgnlValueStack(60) -Error setting expression 'param1' with value '[Ljava.lang.String;@1d1a35e'
ognl.MethodFailedException: Method "setParam1" failed for object cn.test.web.TestSimpleAction@150dcd3 [java.lang.NoSuchMethodException: cn.test.web.TestSimpleAction.setParam1([Ljava.lang.String;)]
	at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1285)
	at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1474)
...
...
ERROR org.apache.struts2.dispatcher.Dispatcher(38) -Could not find action or result
/test/test1.do?param1=2634567890
No result defined for action cn.test.web.TestSimpleAction and result input
	at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:375)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
...
...

The exception are catched in XWorkConverter,  so that I only can get the error:"No result defined for action cn.test.web.TestSimpleAction and result input" ,but can't get original reason:the number is too large;
additional,log "Overflow or underflow casting: "2634567890" into class java.lang.Long " is printed with DEBUG level ,not WARN or ERROR?
                
> XWorkConverter catch XWorkException so that the client application can't get the detail original error message
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-3695
>                 URL: https://issues.apache.org/jira/browse/WW-3695
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Other
>    Affects Versions: 2.2.1.1
>            Reporter: shenjc
>
> in com.opensymphony.xwork2.conversion.impl.XWorkConverter line 331 to 341
> {code}
> try {
>     if (LOG.isDebugEnabled())
>         LOG.debug("falling back to default type converter [" + defaultTypeConverter + "]");
>     return defaultTypeConverter.convertValue(context, target, member, property, value, toClass);
> } catch (Exception e) {
>     if (LOG.isDebugEnabled())
>         LOG.debug("unable to convert value using type converter [#0]", e, defaultTypeConverter.getClass().getName());
>     handleConversionException(context, property, value, target);
>     return TypeConverter.NO_CONVERSION_POSSIBLE;
> }
> {code}
> here try catch code "defaultTypeConverter.convertValue" so that it can not throw exception to outside.
> in some case,for example:
> when I transmit a param a bigInteger to Integer in a action.
> the program will run pass and ignore this exception,the outside program can't catch it ,so that can't find what cause the error.
> and it only print in log file:
> {noformat}
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger.debug(72) | unable to convert value using type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter]
> Overflow or underflow casting: "3322333330" into class java.lang.Long - [unknown location]
> {noformat}
> and we need to find this  error message in large debug log message;
>  
> I think, throw this exception and not catch it here,and change log level from debug to error when print this message will better,isn't it ?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (WW-3695) XWorkConverter catch XWorkException so that the client application can't get the detail original error message

Posted by "Maurizio Cucchiara (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3695?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Maurizio Cucchiara updated WW-3695:
-----------------------------------

    Description: 
in com.opensymphony.xwork2.conversion.impl.XWorkConverter line 331 to 341
{code}
try {
    if (LOG.isDebugEnabled())
        LOG.debug("falling back to default type converter [" + defaultTypeConverter + "]");
    return defaultTypeConverter.convertValue(context, target, member, property, value, toClass);
} catch (Exception e) {
    if (LOG.isDebugEnabled())
        LOG.debug("unable to convert value using type converter [#0]", e, defaultTypeConverter.getClass().getName());
    handleConversionException(context, property, value, target);

    return TypeConverter.NO_CONVERSION_POSSIBLE;
}
{code}
here try catch code "defaultTypeConverter.convertValue" so that it can not throw exception to outside.
in some case,for example:
when I transmit a param a bigInteger to Integer in a action.
the program will run pass and ignore this exception,the outside program can't catch it ,so that can't find what cause the error.
and it only print in log file:
{noformat}
com.opensymphony.xwork2.util.logging.commons.CommonsLogger.debug(72) | unable to convert value using type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter]
Overflow or underflow casting: "3322333330" into class java.lang.Long - [unknown location]
{noformat}
and we need to find this  error message in large debug log message;
 
I think, throw this exception and not catch it here,and change log level from debug to error when print this message will better,isn't it ?

  was:
in com.opensymphony.xwork2.conversion.impl.XWorkConverter line 331 to 341
            try {
                if (LOG.isDebugEnabled())
                    LOG.debug("falling back to default type converter [" + defaultTypeConverter + "]");
                return defaultTypeConverter.convertValue(context, target, member, property, value, toClass);
            } catch (Exception e) {
                if (LOG.isDebugEnabled())
                    LOG.debug("unable to convert value using type converter [#0]", e, defaultTypeConverter.getClass().getName());
                handleConversionException(context, property, value, target);

                return TypeConverter.NO_CONVERSION_POSSIBLE;
            }
here try catch code "defaultTypeConverter.convertValue" so that it can not throw exception to outside.
in some case,for example:
when I transmit a param a bigInteger to Integer in a action.
the program will run pass and ignore this exception,the outside program can't catch it ,so that can't find what cause the error.
and it only print in log file:
com.opensymphony.xwork2.util.logging.commons.CommonsLogger.debug(72) | unable to convert value using type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter]
Overflow or underflow casting: "3322333330" into class java.lang.Long - [unknown location]

and we need to find this  error message in large debug log message;
 
I think, throw this exception and not catch it here,and change log level from debug to error when print this message will better,isn't it ?

    
> XWorkConverter catch XWorkException so that the client application can't get the detail original error message
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-3695
>                 URL: https://issues.apache.org/jira/browse/WW-3695
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Other
>    Affects Versions: 2.2.1.1
>            Reporter: shenjc
>
> in com.opensymphony.xwork2.conversion.impl.XWorkConverter line 331 to 341
> {code}
> try {
>     if (LOG.isDebugEnabled())
>         LOG.debug("falling back to default type converter [" + defaultTypeConverter + "]");
>     return defaultTypeConverter.convertValue(context, target, member, property, value, toClass);
> } catch (Exception e) {
>     if (LOG.isDebugEnabled())
>         LOG.debug("unable to convert value using type converter [#0]", e, defaultTypeConverter.getClass().getName());
>     handleConversionException(context, property, value, target);
>     return TypeConverter.NO_CONVERSION_POSSIBLE;
> }
> {code}
> here try catch code "defaultTypeConverter.convertValue" so that it can not throw exception to outside.
> in some case,for example:
> when I transmit a param a bigInteger to Integer in a action.
> the program will run pass and ignore this exception,the outside program can't catch it ,so that can't find what cause the error.
> and it only print in log file:
> {noformat}
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger.debug(72) | unable to convert value using type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter]
> Overflow or underflow casting: "3322333330" into class java.lang.Long - [unknown location]
> {noformat}
> and we need to find this  error message in large debug log message;
>  
> I think, throw this exception and not catch it here,and change log level from debug to error when print this message will better,isn't it ?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WW-3695) XWorkConverter catch XWorkException so that the client application can't get the detail original error message

Posted by "Maurizio Cucchiara (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3695?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13138205#comment-13138205 ] 

Maurizio Cucchiara commented on WW-3695:
----------------------------------------

As you can see there is an {{handleConversionException}} which is delegated to manage this kind of condition (it adds conversion errors to the action context).
So, whenever an user add a value which causes a conversion error, if I understand correctly should add a conversion error, which triggers the input result.
I could be wrong, I probably didn't get you, could you provide a test case or a more detailed example?
                
> XWorkConverter catch XWorkException so that the client application can't get the detail original error message
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-3695
>                 URL: https://issues.apache.org/jira/browse/WW-3695
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Other
>    Affects Versions: 2.2.1.1
>            Reporter: shenjc
>
> in com.opensymphony.xwork2.conversion.impl.XWorkConverter line 331 to 341
> {code}
> try {
>     if (LOG.isDebugEnabled())
>         LOG.debug("falling back to default type converter [" + defaultTypeConverter + "]");
>     return defaultTypeConverter.convertValue(context, target, member, property, value, toClass);
> } catch (Exception e) {
>     if (LOG.isDebugEnabled())
>         LOG.debug("unable to convert value using type converter [#0]", e, defaultTypeConverter.getClass().getName());
>     handleConversionException(context, property, value, target);
>     return TypeConverter.NO_CONVERSION_POSSIBLE;
> }
> {code}
> here try catch code "defaultTypeConverter.convertValue" so that it can not throw exception to outside.
> in some case,for example:
> when I transmit a param a bigInteger to Integer in a action.
> the program will run pass and ignore this exception,the outside program can't catch it ,so that can't find what cause the error.
> and it only print in log file:
> {noformat}
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger.debug(72) | unable to convert value using type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter]
> Overflow or underflow casting: "3322333330" into class java.lang.Long - [unknown location]
> {noformat}
> and we need to find this  error message in large debug log message;
>  
> I think, throw this exception and not catch it here,and change log level from debug to error when print this message will better,isn't it ?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira