Reputation: 438
I want to know that if Struts 2 core jar must be in sync with the Struts2-Json-Plugin jar. because when i am returning 'SUCCESS' from a method in Action class then exception is occurring . ihave declared result type as 'json' in my xml as
<result-type name="json" class="org.apache.struts2.json.JSONResult"/>
and the exception i am getting is
java.lang.NoSuchMethodError: com.opensymphony.xwork2.ActionContext.get(Ljava/lang/String;)Ljava/lang/Object;
at org.apache.struts2.json.JSONResult.execute(JSONResult.java:166)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
i am using struts2-core-2.0.11.jar and my struts.xml is
<action name="editEmployee" class="myaction.AddEmployeeAction" method="getValue">
<result name="success" type="json" />
</action>
and my action is
public class AddEmployeeAction extends ActionSupport implements ParameterAware {
/**
*
*/
private static final long serialVersionUID = 1L;
private EmployeeDaoImp empdao;
private Map parameters;
public EmployeeDaoImp getEmpdao() {
return empdao;
}
public void setEmpdao(EmployeeDaoImp empdao) {
this.empdao = empdao;
}
public String getValue() throws Exception
{
//JSONArray jsonArr = new JSONArray();
JSONObject jsonObject = new JSONObject();
String query = getParameterValue("selChar");
List<String> names = empdao.getData(query);
/*for (String name : names) {
jsonArr.add(name);
}*/
jsonObject.put("namesList", names);
return SUCCESS;
}
}
Upvotes: 1
Views: 3675
Reputation: 160321
S2 plugin versions must match the S2 version; plugins use mechanisms provided by struts2-core.
While a plugin may work with a different version of core, it will never be tested like that, so unless you provide your own test harness, there's no way to know what the behavior will be if you start mixing and matching at random. You should not mix and match.
Upvotes: 4