views:

260

answers:

1

Hi,

I am new to struts2, prior to this I have been using struts1.2, Spring and Hibernate combination. I have just started using Struts2,Spring and Hibernate application, but I seem to be plagued with interceptor exceptions,

There are two error which keep happening, all in different scenarios

1) 2010-07-26 19:50:58,031 ERROR org.apache.struts2.dispatcher.Dispatcher.error:27 - Could not find action or result No result defined for action com.inrev.bm.action.IRCampaignMgmtAction and result input at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:364) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266) at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)

2) 2010-07-26 22:09:22,779 DEBUG com.opensymphony.xwork2.interceptor.ParametersInterceptor.debug:57 - Setting params session => [ {"session_key":"djshjhdfkjhdjhuhhhgfhg-1133902930","uid":1133902930,"expires":0,"secret":"fjhfhlkasjdhfkdsjfhjhyhfhdjhfjkdh","sig":"hfjdfhljksdfhjkasdhfjhdfjhakfjnmx,nvds"} ] 2010-07-26 22:09:22,780 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Property: session 2010-07-26 22:09:22,781 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Class: com.inrev.bm.action.IRFacebookAction 2010-07-26 22:09:22,797 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - converter is null for property session. Mapping size: 0 2010-07-26 22:09:22,797 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - field-level type converter for property [session] = none found 2010-07-26 22:09:22,798 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - global-level type converter for property [session] = none found 2010-07-26 22:09:22,799 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@18a62f6] 2010-07-26 22:09:22,804 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:61 - unable to convert value using type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter] Cannot create type interface java.util.Map from value {"session_key":"6e2ecfba81fc0e9b889a80021133902930","uid":1133902930,"expires":0,"secret":" fjhfhlkasjdhfkdsjfhjhyhfhdjhfjkd","sig":"fe455338f9d869e589939d9c8dcdccb7"} - [unknown location] at com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.convertValue(XWorkBasicConverter.java:141) at com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.convertValue(XWorkBasicConverter.java:135) at com.opensymphony.xwork2.conversion.impl.XWorkConverter.convertValue(XWorkConverter.java:323) at com.opensymphony.xwork2.ognl.OgnlTypeConverterWrapper.convertValue(OgnlTypeConverterWrapper.java:28) at ognl.OgnlRuntime.getConvertedType(OgnlRuntime.java:1040) at ognl.OgnlRuntime.getConvertedTypes(OgnlRuntime.java:1057) at ognl.OgnlRuntime.getConvertedMethodAndArgs(OgnlRuntime.java:1083)

I can make out that the first error is related to Validator interceptor and the second one is related to Parameter convertor, but I cannot seem to figure out how I can fix them. In the second exception all the parameter values are being sent from facebook. Help would be highly appreciated.

Regards, Rohit

A: 

I can help you with the first exception. You need to make sure your action mapping for com.inrev.bm.action.IRCampaignMgmtAction has an input result:

 <action name="your-action-name" class="com.inrev.bm.action.IRCampaignMgmtAction">
   <result name="input">/WEB-INF/pat/to/input.jsp</result>
   <result name="success">/WEB-INF/pat/to/success.jsp</result>
 </action> 

Update

For your second error, you can see the code that's resulting in the message in the XWorkConverter.getConverter() method (starts at line 366). What Java type is your session property in your com.inrev.bm.action.IRFacebookAction class?

You may have to define a custom type converter to handle this case if it's not something XWork is able to handle by default.

Pat
Hey Pat,Thanks for the suggestion, adding the action mapping result does stop the exception, but then why does it go into the validation page when I don't want any validation. Secondly since the validation keeps failing it keeps going to the input mapping. Also this doesn't seem to be happening with all my other classes.How can I avoid any convertor from being applied. I want to retrieve my parameter objects from the request object myself.
rohitgu
Struts2 determines when to run validation based on the `validation` and `workflow` interceptors. In your struts.xml if you don't explicitly set an interceptor stack, the `defaultStack` is applied (which includes both of these interceptors). For both problems, you could create a custom stack that doesn't include either validation interceptor or the `params` interceptor. Then you'd be free to extract the objects yourself. The following explains interceptors and how to define custom stacks for specific actions: http://struts.apache.org/2.x/docs/interceptors.html
Pat
Hey Pat, Thanks for the reply, I removed the Validator interceptor, the second error was happening because Facebook sends a variable called "session" during authorization and which the Convertor interceptor was trying to convert to the session map.Had to remove the session aware interface for that action class, didn't want to add one more parameter for the exception.
rohitgu
Appreciate you letting me know what was happening in case I'm ever doing the same type of thing.
Pat