net.sf.json.JSONException: java.lang.reflect.InvocationTarge
发布时间:2020-12-16 19:15:22 所属栏目:百科 来源:网络整理
导读:严重: Servlet.service() for servlet [centralServlet] in context with path [/UserTest] threw exception [Request processing failed; nested exception is net.sf.json.JSONException: java.lang.reflect.InvocationTargetException] with root causeja
严重: Servlet.service() for servlet [centralServlet] in context with path [/UserTest] threw exception [Request processing failed; nested exception is net.sf.json.JSONException: java.lang.reflect.InvocationTargetException] with root cause java.lang.NullPointerException at org.hibernate.tuple.entity.EntityMetamodel.isNaturalIdentifierInsertGenerated(EntityMetamodel.java:1127) 上面的异常是在执行下面的语句出现的:
出现这bug JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
jsonConfig.registerJsonBeanProcessor(java.sql.Date.class,new JsDateJsonBeanProcessor());
或者 private java.util.Date createTime;
解决:hibernate延时加载设置 JsonConfig cfg = new JsonConfig(); cfg.setExcludes(new String[]{"handler","hibernateLazyInitializer"});还有一个办法就是建一个 model 类,将需要的数据取出来放到 model 对象中,然后把 model 对象转换成 json 对象 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |