I'm trying to have an Ajax call in my Struts 2 project in Netbeans, and I'm having issues getting it to work that seem to have to do with libraries. First of all, the only combination I've found that works at all is to use the current (2.5.22) JSON plugin with the Struts 2.3 core libraries; if I use the "correct" 2.3 version of the plugin, or if I use the 2.5 Struts libraries all around, I don't get any error messages, but I don't get any data either: none of the fields of the action class get populated. However, I can't get the return data back; instead I get an HTML-formatted 500 message saying "java.lang.NoClassDefFoundError: Could not initialize class org.apache.struts2.json.JSONResult" plus a ton of traceback after that. I can see perfectly well that this class is there in the JSON plugin jar. So my library list at present looks like this: library list
My struts.xml entry for the action in question is
<action name="updateProductWorkforceAjax" class="prsm2.display.controller.SingleProductAjax"
method="updateProductWorkforceAjax">
<interceptor-ref name="json">
<param name="enableSMD">true</param>
</interceptor-ref>
<result type="json">
</result>
</action>
and I am extending the json-default package.
The Ajax call looks like this:
var arg = {dvList: dvlist,
prodId : prodId,
orgId : orgId,
programYear : programYear,
functionalArea : fa};
$.ajax({
data: arg,
type: 'POST',
dataType : 'json',
url: 'updateProductWorkforceAjax',
success: function(data) {
control.log(data);
},
error:function(result) {
var zz = result;
}
})
where all the variables folded into arg are strings. The action class has all the required getters and setters and appears to work fine-- after all if I use the inconsistent libraries, it gets data correctly.
I've tried using a complete set of libraries for one version, which will not run at all (the server won't even start).
If someone can tell me what libraries will work together for this, or what I'm doing wrong with the ones I have, I would appreciate it.