Hi I am using
struts 2, spring 3.0.5 and hibernate 3.5.6
I tried using struts - json plug in to get json data from one of my action by extending json-default in my existing application as follows:
<package name="default" namespace="/" extends="json-default">
However, I do get error if I use any service class using Dependency Injection in my json action just before my return statement as follows:
************************** ERROR ***************************
[6/11/15 18:50:04:333 IST] 00000096 SystemOut O execute================================ends==
[6/11/15 18:50:04:620 IST] 00000096 SystemOut O ERROR ExceptionMappingInterceptor - org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException
org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException
PFA the complete error log.
**************************************************************
struts.xml
<package name="default" namespace="/" extends="json-default">
<interceptors>
<interceptor name="sessionInterceptor" class="com.city.watchlist.web.util.SessionInterceptor" />
<interceptor-stack name="appDefaultStack">
<interceptor-ref name="defaultStack">
<param name="exception.logEnabled">true</param>
<param name="exception.logLevel">ERROR</param>
</interceptor-ref>
<interceptor-ref name="sessionInterceptor"></interceptor-ref>
</interceptor-stack>
<interceptor-stack name="loginStack">
<interceptor-ref name="defaultStack">
<param name="exception.logEnabled">true</param>
<param name="exception.logLevel">ERROR</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>
<action name="*RuleSetSublist" class="RuleSetSublistAction" method="{1}">
<result name="success">/jsps/subListMaintenance.jsp</result>
<result name="successLoadAdd" >/jsps/addEditSubList.jsp</result>
<result name="successSaveAdd" type="redirectAction">/loadRuleSetSublist.action</result>
<result name="refreshRuleSet">/jsps/sublistRulesetSection.jsp</result>
<result name="input" >/jsps/addEditSubList.jsp</result>
</action>
<action name="ajaxAction" class="SublistAjaxJsonAction">
<result type="json">
<param name="excludeNullProperties">true</param>
<param name="noCache">true</param>
</result
</action>
*****************************************************
Basically in my addEditSubList.jsp page I will be calling $.getJSON for some front end requirement.
PFA my SublistAjaxJsonAction.java class file
***********************************
spring config file is :
<bean id="ruleSetSublistDAO" class="com.city.watchlist.ruleset.dao.RuleSetSublistDAO" parent="baseDAO"/>
<bean id="ruleSetSublistServ" class="com.city.watchlist.ruleset.service.RuleSetSublistService">
<property name="ruleSetSublistDAO" ref="ruleSetSublistDAO" />
</bean>
<bean id="RuleSetSublistAction" class="com.city.watchlist.ruleset.action.RuleSetSublistAction" scope="prototype">
<property name="ruleSetSublistServ" ref="ruleSetSublistServ" />
</bean>
<bean id="SublistAjaxJsonAction" class="com.city.watchlist.ruleset.action.SublistAjaxJsonAction" scope="prototype" >
<property name="ruleSetSublistServ" ref="ruleSetSublistServ" />
</bean>
************************************
It goes all fine just before my return statement but is giving error while returning to calling
jsp(addEditSubList.jsp).
if I just use some hardcoded value and not use Dependency injection and other stuffs it works fine.
PLEASe HELP|!!!