Re: Serializing a non-EO in JSON
Re: Serializing a non-EO in JSON
- Subject: Re: Serializing a non-EO in JSON
- From: Mike Schrag <email@hidden>
- Date: Thu, 05 May 2011 10:16:45 -0400
actually .. yeah … your version might be slightly more tedious to use … maybe new impl coming.
ms
On May 5, 2011, at 10:10 AM, Pascal Robert wrote:
> I looked at it, and it looked easier to use JSONSerializer in a context where I'm not sending the JSON as part of a REST request (I want to save it to a database). BTW, that's org.jabsorb.JSONSerializer (the one in the Ajax framework).
>
>> any reason you're using JSONSerializer rather than using ERRest json serialization?
>>
>> ms
>>
>> On May 5, 2011, at 9:56 AM, Pascal Robert wrote:
>>
>>> I'm a bit lost here. I'm trying to encode a ERCalendar object in JSON, and I'm getting problems. That object (coming from ERCalendar2) also have a array that contains EREvent objects.
>>>
>>> So I did that:
>>>
>>> JSONSerializer serializer = new JSONSerializer();
>>> serializer.registerDefaultSerializers();
>>> serializer.registerSerializer(new ERXBeanSerializer(EREvent.class));
>>> serializer.registerSerializer(new ERXBeanSerializer(ERCalendar.class));
>>> serializer.registerSerializer(new NSArraySerializer());
>>>
>>> But I'm getting Java heap space errors (see full stack below).
>>>
>>> If I don't serialize EREvent, no errors, but the EREvent objects are not serialized. So I guess something make the serializer to go an infinite loop in EREvent, but I don't know what.
>>>
>>> Any suggestions?
>>>
>>> Stacktrace:
>>>
>>> INFO [er.ajax.json.serializer.ERXBeanSerializer] analyzing er.calendar2.ERCalendar
>>> INFO [org.jabsorb.serializer.impl.BeanSerializer] analyzing net.fortuna.ical4j.model.Calendar
>>> ...
>>> INFO [org.jabsorb.serializer.impl.BeanSerializer] analyzing java.net.Proxy$Type
>>> INFO [org.jabsorb.serializer.impl.BeanSerializer] analyzing java.util.concurrent.TimeUnit$1
>>> INFO [org.jabsorb.serializer.impl.BeanSerializer] analyzing java.util.concurrent.TimeUnit$2
>>> INFO [org.jabsorb.serializer.impl.BeanSerializer] analyzing java.util.concurrent.TimeUnit$3
>>> INFO [org.jabsorb.serializer.impl.BeanSerializer] analyzing java.util.concurrent.TimeUnit$4
>>> INFO [org.jabsorb.serializer.impl.BeanSerializer] analyzing java.util.concurrent.TimeUnit$5
>>> INFO [org.jabsorb.serializer.impl.BeanSerializer] analyzing java.util.concurrent.TimeUnit$6
>>> INFO [org.jabsorb.serializer.impl.BeanSerializer] analyzing java.util.concurrent.TimeUnit$7
>>> WARN [NSLog] <com.webobjects.appserver._private.WOComponentRequestHandler>: Exception occurred while handling request:
>>> com.webobjects.foundation.NSForwardException [java.lang.reflect.InvocationTargetException] null:java.lang.reflect.InvocationTargetException
>>> [2011-5-5 9:1:43 EDT] <WorkerThread0> com.webobjects.foundation.NSForwardException [java.lang.reflect.InvocationTargetException] null:java.lang.reflect.InvocationTargetException
>>> at com.webobjects.foundation._NSUtilities._explainInstantiationException(_NSUtilities.java:626)
>>> at com.webobjects.foundation._NSUtilities.instantiateObject(_NSUtilities.java:646)
>>> at com.webobjects.appserver._private.WOComponentDefinition._componentInstanceInContext(WOComponentDefinition.java:544)
>>> at com.webobjects.appserver._private.WOComponentDefinition.componentInstanceInContext(WOComponentDefinition.java:642)
>>> at com.webobjects.appserver.WOApplication.pageWithName(WOApplication.java:2332)
>>> at com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedSession(WOComponentRequestHandler.java:284)
>>> at com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedApplication(WOComponentRequestHandler.java:332)
>>> at com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(WOComponentRequestHandler.java:369)
>>> at com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WOComponentRequestHandler.java:442)
>>> at com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:1687)
>>> at er.extensions.appserver.ERXApplication.dispatchRequestImmediately(ERXApplication.java:1984)
>>> at er.extensions.appserver.ERXApplication.dispatchRequest(ERXApplication.java:1949)
>>> at com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:144)
>>> at com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:226)
>>> at java.lang.Thread.run(Thread.java:680)
>>> Caused by: java.lang.reflect.InvocationTargetException
>>> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>>> at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>>> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>>> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>>> at com.webobjects.foundation._NSUtilities.instantiateObject(_NSUtilities.java:640)
>>> ... 13 more
>>> Caused by: java.lang.OutOfMemoryError: Java heap space
>>> at java.util.LinkedList.toArray(LinkedList.java:863)
>>> at java.util.ArrayList.<init>(ArrayList.java:131)
>>> at org.jabsorb.serializer.FixUp.<init>(FixUp.java:57)
>>> at org.jabsorb.serializer.SerializerState.addFixUp(SerializerState.java:74)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:371)
>>> at org.jabsorb.serializer.impl.ArraySerializer.marshall(ArraySerializer.java:298)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.ArraySerializer.marshall(ArraySerializer.java:298)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.ArraySerializer.marshall(ArraySerializer.java:298)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.ArraySerializer.marshall(ArraySerializer.java:298)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.ArraySerializer.marshall(ArraySerializer.java:298)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.ArraySerializer.marshall(ArraySerializer.java:298)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235)
>>>
>>> WARN [NSLog] Ran out of memory, killing this instance
>>> FATAL [er.extensions.appserver.ERXApplication] Ran out of memory, killing this instance
>>> FATAL [er.extensions.appserver.ERXApplication] Ran out of memory, killing this instance
>>> java.lang.OutOfMemoryError: Java heap space
>>> at java.util.LinkedList.toArray(LinkedList.java:863)
>>> at java.util.ArrayList.<init>(ArrayList.java:131)
>>> at org.jabsorb.serializer.FixUp.<init>(FixUp.java:57)
>>> at org.jabsorb.serializer.SerializerState.addFixUp(SerializerState.java:74)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:371)
>>> at org.jabsorb.serializer.impl.ArraySerializer.marshall(ArraySerializer.java:298)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.ArraySerializer.marshall(ArraySerializer.java:298)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.ArraySerializer.marshall(ArraySerializer.java:298)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.ArraySerializer.marshall(ArraySerializer.java:298)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.ArraySerializer.marshall(ArraySerializer.java:298)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.ArraySerializer.marshall(ArraySerializer.java:298)
>>> at org.jabsorb.JSONSerializer.marshall(JSONSerializer.java:385)
>>> at org.jabsorb.serializer.impl.BeanSerializer.marshall(BeanSerializer.java:235) _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden