Fórum
Unable To Deserialize Object
Unable To Deserialize Object
New Member Postagens: 14 Data de Entrada: 25/01/14 Postagens RecentesI am working on a small portlet that is using JSON to store data serialized. Locally on my own enviroment i've been able to serialize and deserialize data. To achieve this i used the JSONFactoryUtil.serialize & deserialize methods. However when i pushed the portlet to our servers i get a message indicating that JSONFactoryUtil.deserialize() was unable to deserialize the object.
Digging a little further i found that error is a class not found exception. Indicated in the stacktrace: Caused by: java.lang.ClassNotFoundException: com.liferay.portal.json.JSONArrayImpl. This has me a little puzzled as i would have believed this to be an out of the box class in Liferay.
I currently run liferay-portal-6.2-ee-sp11 locally and remotely 6.2.10-sp15 .
I'd appreciate any guidance on this issue,
Regards,
John
Anexos:
RE: Unable To Deserialize Object
Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens RecentesSeems like maybe the API has changed between those service packs? Couple of things I would try --
1. Sync your local
a. Make a copy of your development folder (clone)
b. Stop the current dev and start the clone
c. Update the clone to SP15 and try to reproduce
-- if you can reproduce with a 15 locally, then at least you know the root cause so you can fix locally and then you know it will work in prod (your environments should all be in synch for this very reason in fact)
2. Try using the looseDeserialize method instead. It probably won't produce exactly as you want though. I would expect on your local you would have your array but on the server you would end up with everything except the array (loose methods basically ignore the things it can't convert).
Let me know what the results are as I am curious to know how this plays out
RE: Unable To Deserialize Object
New Member Postagens: 14 Data de Entrada: 25/01/14 Postagens RecentesHi Andrew, my aplogies for not replying sooner, i did eventually end up using the GSON library to work with JSON. Thank you for your help in this one.
Regards,
John
RE: Unable To Deserialize Object
Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens RecentesNo worries, we all get caught up in our work. As a matter of interest, I normally use another JSON provider as well. In my case though what I have done though is I have taken the time to put together an API/Service module companion set with a default implementation that uses the JSON API that Liferay ships with. When I want to leverage a new implementation, I simply define a new service, giving it a higher ranking if I want it to be the default, or alternatively using a target filter when defining my @Reference to inject the service implementation I want to use in the Component. There are time when the Liferay JSON API is super convenient to leverage, but other times where the implementation (flex JSON I believe it is) provide a little more bloat that I want.
At any rate, glad to hear you got it working.