For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 10 replies, 2 voices, and was last updated 11 years, 8 months ago by
support-pradeep.
-
AuthorPosts
-
atl_alaMemberI have tried to scaffolding a crud web project for rest/json support with the default derby database (choosed hibernate 4).
However, it kept producing duplicate output, i.e.,
http://localhost:8080/sp/Office/2
I got tons of same outputs (see attachment). Also the console is full of these kind of errors:
at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:268)
at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:160)
at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:131)
at org.codehaus.jackson.map.ser.ContainerSerializers$CollectionSerializer.serializeContents(ContainerSerializers.java:363)
at org.codehaus.jackson.map.ser.ContainerSerializers$CollectionSerializer.serializeContents(ContainerSerializers.java:314)I have searched around and people are talking about lazy loading problem for hibernate, ” your transaction will end, the Hibernate Session gets closed and when the mapper tries to access that collection”
I mean since it is a out of box function, do we have some kind of workaround to address the issue quickly?
Attachments:
You must be logged in to view attached files.December 24, 2013 at 6:13 am #345480
support-pradeepMemberatl_ala,
Sorry that you are seeing this issue.
> Can you please be more clear on the issue ? Can you please mention the exact steps in detail (right from creating a project), to help us replicate the issue at our end ?
> Please share your MyEclipse installation details from MyEclipse > Installation summary > Installation details ?
> Can you also check the .log file which is located at <workspace dir>/.metadata/.log for any errors of interest ? If yes then paste the errors here for us to investigate further.
December 24, 2013 at 1:44 pm #345489
atl_alaMember1. Followed this video:
Around 7:29, I have checked Web Service and Json option.
2. Version 10.6
Build id: 10.6-201207273. .log has nothing appended when this issue happened. Console is full of repeated message as following:
at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:268)
at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:160)
at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:131)
at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:268)
at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:160)
at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:131)
at org.codehaus.jackson.map.ser.ContainerSerializers$CollectionSerializer.serializeContents(ContainerSerializers.java:363)
at org.codehaus.jackson.map.ser.ContainerSerializers$CollectionSerializer.serializeContents(ContainerSerializers.java:314)December 26, 2013 at 4:18 am #345502
support-pradeepMemberatl_ala,
Thanks for the details provided.
We couldn’t replicate the issue at our end after following the video. It is not clear how you added Hibernate 4 support while Scaffolding the web project. Can you please explain how you have added Hibernate 4 support while scaffolding ?
Also, can you please clarify which version of Spring libraries did you select during scaffolding ? Is it Spring 2.5 / 3.0 / 3.1 ?
If possible, can you please attach the sample project which exhibits this issue to help us investigate further ?
January 9, 2014 at 3:13 pm #345884
atl_alaMemberI did some more testing and here is what I have found:
office and employee was linked with a officeCode foreign key. then REST try to display like
office (
….
employees (
….
office ()
))
Endless looping.
How can we fix it? I.e., control it to display only 1 level then stop? I guess the CRUD rest code should provide options for this.
Same thing for create a office with employee together. Due to the foreign key, how can you present with json to assign an employee belongs to which office even the office has not been created yet? The CRUD sample did not cover that too.
January 9, 2014 at 3:26 pm #345886January 10, 2014 at 6:07 am #345908
support-pradeepMemberatl_ala,
We couldn’t replicate the issue at our end after linking office and employee tables with a officeCode foreign key.
Can you please attach the sample project which exhibits this issue to help us investigate further ? Also, please paste the schema of the tables on which you are trying to scaffold ?
January 10, 2014 at 11:45 pm #345936January 13, 2014 at 5:48 am #345957
support-pradeepMemberatl_ala,
Thanks for the source code provided.
We could replicate the issue at our end with your source code. Inorder to fix the issue, you need to add @JsonIgnore annotation above getOffice method (in Employee.java file) and getEmployees method (in Office.java file).
Let us know how it works for you.
January 19, 2014 at 12:33 am #346186
atl_alaMembersorry it took long to response.
January 20, 2014 at 5:51 am #346217
support-pradeepMemberatl_ala,
Glad that the duplicate output issue is solved. The tutorials are just to help you get started. we can’t usually provide much assistance with that and you will usually need to post on more appropriate development forums (for example, http://www.stackoverflow.com ) for better support on this.
Do let us know if you see any issues in MyEclipse.
-
AuthorPosts