Error returned for interaction between Ajax framework and SSH

Source: Internet
Author: User

Error returned for interaction between Ajax framework and SSH


View abnormal display in Firefox

Class org. Apache. struts2.json. jsonwriter can not
Access a member of class
Org. Apache. commons. DBCP. poolingdatasource $ poolguardconnectionwrapper
Modifiers "public"


It is found that this problem occurs when the struts2 pojo action contains object attributes and is managed by hibernate. Hibernate adds the hibernatelazyinitializer attribute to each managed object, and Struts-jsonplugin or other jsonplugin converts pojo to JSON through the Java reflection mechanism, however, hibernatelazyinitializer cannot be obtained by reflection, so an exception is thrown.

 

This problem also occurs when spring MVC accesses SSH2 through Ajax.

 

Solution:

 

Method 1: remove the get method of hibernate Object Management in pojo action, and add <result type = "JSON"> </result> to <Param
Name = "excludeproperties">. * hibernatelazyinitializer </param>:

<Result type = "JSON">

<Param
Name = "excludeproperties">. * hibernatelazyinitializer </param>

</Result>

Used when Struts-jsonplugin is used.

 

Method 2: Add annotation to the pojo class to exclude the attribute hibernatelazyinitializer:

Annotation:

@ Jsonignoreproperties (value = {"hibernatelazyinitializer "})


Used to transfer JSON objects using Jackson.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.