Re: [S2] ClassCastException on getParameters
Hi , Even i am also facing the same issue. If any body is having please share with us.. It is returning the String array[] . But how it will return string[] if we enter normal text also... Thanks Ravi On 8/2/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi all, I'm having big trouble while trying to acces to the parameters values. I'm simply trying to retrieve a parameter value from my interceptor class. The Action class that is intercepted implements the ParameterAware interface and has getter and setter method related to parameters attribute which is a Map. Here is the sample code. public String intercept(ActionInvocation invocation) throws Exception { ActionSupport action = (ActionSupport) invocation.getAction(); Map session = invocation.getInvocationContext().getSession(); Map parameters = invocation.getInvocationContext().getParameters(); String loginAttempt = (String)parameters.get(Constants.LOGIN_ATTEMPT_KEY); return invocation.invoke (); } When the line in bold is reached, I' getting a ClassCastException. Here is an extract of the stacktrace java.lang.ClassCastException: [Ljava.lang.String; at com.natixis.media.interceptors.AuthenticationInterceptor.intercept( AuthenticationInterceptor.java:42) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling( DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling( DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile( UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke( DefaultActionInvocation.java:221) at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept (DefaultWorkflowInterceptor.java:221) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept( MethodFilterInterceptor.java:86) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling( DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling( DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile( UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke( DefaultActionInvocation.java:221) at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept( ValidationInterceptor.java:150) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept (AnnotationValidationInterceptor.java:48) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept( MethodFilterInterceptor.java:86) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling( DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling Can someone tells me what I'm missing. Thank in advance. Meissa L'integrite de ce message n'etant pas assuree sur internet, Natixis ne peut etre tenu responsable de son contenu. Toute utilisation ou diffusion non autorisee est interdite. Si vous n'etes pas destinataire de ce message, merci de le detruire et d'avertir l'expediteur. Ensemble, faisons un geste pour l'environnement : n'imprimons nos mails que si necessaire The integrity of this message cannot be guaranteed on the Internet. Natixis can not therefore be considered responsible for the contents. Any unauthorized use or dissemination is prohibited. If you are not the intended recipient of this message, then please delete it and notify the sender. Let us mind the environment : let's print our mails only when necessary.
Re: [S2] ClassCastException on getParameters
Why can't you access the HttpServletRequest object using ServletActionContext.getRequest() and then just use the getParameter() method to get the request parameters? If you're getting a ClassCastException it's because you're casting something that isn't a String to a String. Find out what the type of that object is and go from there. It's simple debugging really. Zarar On 8/2/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi all, I'm having big trouble while trying to acces to the parameters values. I'm simply trying to retrieve a parameter value from my interceptor class. The Action class that is intercepted implements the ParameterAware interface and has getter and setter method related to parameters attribute which is a Map. Here is the sample code. public String intercept(ActionInvocation invocation) throws Exception { ActionSupport action = (ActionSupport) invocation.getAction(); Map session = invocation.getInvocationContext().getSession(); Map parameters = invocation.getInvocationContext().getParameters(); String loginAttempt = (String)parameters.get(Constants.LOGIN_ATTEMPT_KEY); return invocation.invoke (); } When the line in bold is reached, I' getting a ClassCastException. Here is an extract of the stacktrace java.lang.ClassCastException: [Ljava.lang.String; at com.natixis.media.interceptors.AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:42) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling Can someone tells me what I'm missing. Thank in advance. Meissa L'integrite de ce message n'etant pas assuree sur internet, Natixis ne peut etre tenu responsable de son contenu. Toute utilisation ou diffusion non autorisee est interdite. Si vous n'etes pas destinataire de ce message, merci de le detruire et d'avertir l'expediteur. Ensemble, faisons un geste pour l'environnement : n'imprimons nos mails que si necessaire The integrity of this message cannot be guaranteed on the Internet. Natixis can not therefore be considered responsible for the contents. Any unauthorized use or dissemination is prohibited. If you are not the intended recipient of this message, then please delete it and notify the sender. Let us mind the environment : let's print our mails only when necessary. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[S2] ClassCastException on getParameters
Hi all, I'm having big trouble while trying to acces to the parameters values. I'm simply trying to retrieve a parameter value from my interceptor class. The Action class that is intercepted implements the ParameterAware interface and has getter and setter method related to parameters attribute which is a Map. Here is the sample code. public String intercept(ActionInvocation invocation) throws Exception { ActionSupport action = (ActionSupport) invocation.getAction(); Map session = invocation.getInvocationContext().getSession(); Map parameters = invocation.getInvocationContext().getParameters(); String loginAttempt = (String)parameters.get(Constants.LOGIN_ATTEMPT_KEY); return invocation.invoke (); } When the line in bold is reached, I' getting a ClassCastException. Here is an extract of the stacktrace java.lang.ClassCastException: [Ljava.lang.String; at com.natixis.media.interceptors.AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:42) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling Can someone tells me what I'm missing. Thank in advance. Meissa L'integrite de ce message n'etant pas assuree sur internet, Natixis ne peut etre tenu responsable de son contenu. Toute utilisation ou diffusion non autorisee est interdite. Si vous n'etes pas destinataire de ce message, merci de le detruire et d'avertir l'expediteur. Ensemble, faisons un geste pour l'environnement : n'imprimons nos mails que si necessaire The integrity of this message cannot be guaranteed on the Internet. Natixis can not therefore be considered responsible for the contents. Any unauthorized use or dissemination is prohibited. If you are not the intended recipient of this message, then please delete it and notify the sender. Let us mind the environment : let's print our mails only when necessary.