我遇到了许多例外情况,我发现这些例外对我的问题没有帮助,
这里是他们
Class org.apache.struts2.json.JSONWriter can not access a member of class org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl$EntityInstrumentationMetadataImpl with modifiers "public"
java.lang.IllegalAccessException: Class org.apache.struts2.json.JSONWriter can not access a member of class org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl$EntityInstrumentationMetadataImpl with modifiers "public"
org.apache.struts2.json.JSONException: java.lang.IllegalAccessException: Class org.apache.struts2.json.JSONWriter can not access a member of class org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl$EntityInstrumentationMetadataImpl with modifiers "public"
org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.IllegalAccessException: Class org.apache.struts2.json.JSONWriter can not access a member of class org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl$EntityInstrumentationMetadataImpl with modifiers "public"
org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.IllegalAccessException: Class org.apache.struts2.json.JSONWriter can not access a member of class org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl$EntityInstrumentationMetadataImpl with modifiers "public"
org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.IllegalAccessException: Class org.apache.struts2.json.JSONWriter can not access a member of class org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl$EntityInstrumentationMetadataImpl with modifiers "public"
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.IllegalAccessException: Class org.apache.struts2.json.JSONWriter can not access a member of class org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl$EntityInstrumentationMetadataImpl with modifiers "public"
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.IllegalAccessException: Class org.apache.struts2.json.JSONWriter can not access a member of class org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl$EntityInstrumentationMetadataImpl with modifiers "public"
这是我的动作类,它返回JSON
public class GetTagsAction extends ActionSupport{
public String execute(){
Gson gson = new Gson();
String tags = gson.toJson(audioTaggingService.findTagsByName(q));
System.out.println(tags);
return Action.SUCCESS;
}
public String getQ() {
return q;
}
public void setQ(String q) {
this.q = q;
}
public AudioTaggingService getAudioTaggingService() {
return audioTaggingService;
}
public void setAudioTaggingService(AudioTaggingService audioTaggingService) {
this.audioTaggingService = audioTaggingService;
}
public String getTags() {
return tags;
}
public void setTags(String tags) {
this.tags = tags;
}
private String q;
private AudioTaggingService audioTaggingService;
private String tags;
}
这是包
<package name="default" namespace="/" extends="json-default">
<!-- Get AJAX Related Actions -->
<action name="tags" class="tags">
<result type="json" />
</action>
</package>
我正在使用Struts2-JSON-plugin
答案 0 :(得分:3)
错误是因为插件试图转换整个对象图,看起来插件试图通过audioTaggingService转换数据库层。您需要在struts XML中指定“root”参数
<action name="tags" class="tags">
<result type="json">
<param name="root">tags</param>
</result>
</action>
并在您的操作中提供getTags()方法。
但是,我不确定这会有所帮助。我不确定当你尝试JSON-ify已经包含JSON数据的String时会发生什么。
答案 1 :(得分:2)
答案 2 :(得分:0)
如果其中一个JSON数据为空,有时会出现此错误,它在转换时不会出错,但在处理数据时会出错。