Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [Texo] ClassCastException String cast to JSONObject
|
Re: [Texo] ClassCastException String cast to JSONObject [message #1065385 is a reply to message #1065375] |
Tue, 25 June 2013 14:03 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Bastian,
Can you check/debug the upstream/source of the json. Where is the json created? In a the jsonresource or the json
eobject store? How does it arrive on the server.
That would give more clues.
gr. Martin
On 06/25/2013 03:32 PM, Bastian Wagenfeld wrote:
> Hi Martin,
>
> I've got a ClassCastException which came from nowhere... I don't really understand why this happens, since I don't know
> what I changed compared to the last running version. I'm using the Texo version with qualifier 201304010838.
>
> So this is the stack trace:
> java.lang.ClassCastException: java.lang.String cannot be cast to org.json.JSONObject
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.convertSingleEReference(BaseJSONModelConverter.java:261)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.convertContent(BaseJSONModelConverter.java:228)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.doConvert(BaseJSONModelConverter.java:113)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.convertManyEReference(BaseJSONModelConverter.java:376)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.convertContent(BaseJSONModelConverter.java:220)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.doConvert(BaseJSONModelConverter.java:113)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.convert(BaseJSONModelConverter.java:105)
> at org.eclipse.emf.texo.server.service.json.JSONServiceContext.getRequestData(JSONServiceContext.java:94)
> at org.eclipse.emf.texo.server.service.UpdateInsertModelOperation.internalExecute(UpdateInsertModelOperation.java:45)
> at org.eclipse.emf.texo.server.service.ModelOperation.execute(ModelOperation.java:59)
> at org.eclipse.emf.texo.server.web.WebServiceHandler.doPost(WebServiceHandler.java:111)
> at org.eclipse.emf.texo.server.web.WebServiceServlet.doPost(WebServiceServlet.java:65)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at de.test.cmp.filter.DatabaseSwitchFilter.doFilter(DatabaseSwitchFilter.java:42)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
> at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
> at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
> at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
> at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
> at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> at java.lang.Thread.run(Thread.java:722)
> The interessting thing is that the String that is to be cast is "null". It isn't null, but it has the value "null". I
> would be glad, if you had a hint, how this could happen.
>
> Best regards
> Bastian
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
Re: [Texo] ClassCastException String cast to JSONObject [message #1065495 is a reply to message #1065385] |
Wed, 26 June 2013 07:09 |
Bastian Wagenfeld Messages: 183 Registered: January 2013 |
Senior Member |
|
|
Hi,
So I debugged a lot and I now know this situation happens, if there is a single reference from one object to another which should be set null.
As an example:
{"update":[{"id":"{SN must be set}","_eclass":"plane|Instance","db_version":1,"db_Id":1649,"_id":"1649","description":"Description","part":{"_eclass":"plane|Part","db_Id":26,"_id":"26","_proxy":true,"_uri":"http://localhost:8080/test2/jsonws/plane|Part/26#","_title":""},"manufacturer":{"_eclass":"plane|Customer","db_Id":217,"_id":"217","_proxy":true,"_uri":"http://localhost:8080/test2/jsonws/plane|Customer/217#","_title":"Custom"},"children":[],"_uri":"http://localhost:8080/test2/jsonws/plane|Instance/1649#","aVersion":"null","_title":"{SN must be set}"}],"_eclass":"request|ActionType","delete":[],"insert":[],"_title":"{SN must be set}"}
Where the reference aVersion is null. aVersion should be an EObject, but is treated as a String.
Just this moment I got a similar error. There seems to be a null value which is mapped as "null" (String) and therefore cannot be transformed.
java.lang.NumberFormatException: For input string: "null"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:441)
at java.lang.Long.valueOf(Long.java:540)
at org.eclipse.emf.ecore.impl.EcoreFactoryImpl.createELongObjectFromString(EcoreFactoryImpl.java:953)
at org.eclipse.emf.ecore.impl.EcoreFactoryImpl.createFromString(EcoreFactoryImpl.java:158)
at org.eclipse.emf.texo.provider.IdProvider.convertIdStringToId(IdProvider.java:150)
at org.eclipse.emf.texo.server.service.RetrieveModelOperation.internalExecute(RetrieveModelOperation.java:162)
at org.eclipse.emf.texo.server.service.ModelOperation.execute(ModelOperation.java:59)
at org.eclipse.emf.texo.server.web.WebServiceHandler.doGet(WebServiceHandler.java:89)
at org.eclipse.emf.texo.server.web.WebServiceServlet.doGet(WebServiceServlet.java:57)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at de.kisters.praesto.filter.DatabaseSwitchFilter.doFilter(DatabaseSwitchFilter.java:42)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
The json strings are created in the JSONEObjectStore. I'm pretty confused, because these errors came from nowhere...
I really hope to find the reason for that.
Best regards
Bastian
|
|
|
Re: [Texo] ClassCastException String cast to JSONObject [message #1065906 is a reply to message #1065495] |
Fri, 28 June 2013 08:31 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Bastian,
Sorry to ask, but can you debug the serialization code, to see why/where it happens?
The single ereferences are converted in the BaseModelJSONConverter.convertSingleEReference method. There is an if
statement to handle null:
final T value = (T) eGet(source, eReference);
if (value == null) {
target.put(jsonPropName, JSONObject.NULL);
....
gr. Martin
On 06/26/2013 09:09 AM, Bastian Wagenfeld wrote:
> Hi,
>
> So I debugged a lot and I now know this situation happens, if there is a single reference from one object to another
> which should be set null.
>
> As an example: {"update":[{"id":"{SN must be
> set}","_eclass":"plane|Instance","db_version":1,"db_Id":1649,"_id":"1649","description":"Description","part":{"_eclass":"plane|Part","db_Id":26,"_id":"26","_proxy":true,"_uri":"http://localhost:8080/test2/jsonws/plane|Part/26#","_title":""},"manufacturer":{"_eclass":"plane|Customer","db_Id":217,"_id":"217","_proxy":true,"_uri":"http://localhost:8080/test2/jsonws/plane|Customer/217#","_title":"Custom"},"children":[],"_uri":"http://localhost:8080/test2/jsonws/plane|Instance/1649#","aVersion":"null","_title":"{SN
> must be set}"}],"_eclass":"request|ActionType","delete":[],"insert":[],"_title":"{SN must be set}"}
>
> Where the reference aVersion is null. aVersion should be an EObject, but is treated as a String.
>
> Just this moment I got a similar error. There seems to be a null value which is mapped as "null" (String) and therefore
> cannot be transformed.
> java.lang.NumberFormatException: For input string: "null"
> at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
> at java.lang.Long.parseLong(Long.java:441)
> at java.lang.Long.valueOf(Long.java:540)
> at org.eclipse.emf.ecore.impl.EcoreFactoryImpl.createELongObjectFromString(EcoreFactoryImpl.java:953)
> at org.eclipse.emf.ecore.impl.EcoreFactoryImpl.createFromString(EcoreFactoryImpl.java:158)
> at org.eclipse.emf.texo.provider.IdProvider.convertIdStringToId(IdProvider.java:150)
> at org.eclipse.emf.texo.server.service.RetrieveModelOperation.internalExecute(RetrieveModelOperation.java:162)
> at org.eclipse.emf.texo.server.service.ModelOperation.execute(ModelOperation.java:59)
> at org.eclipse.emf.texo.server.web.WebServiceHandler.doGet(WebServiceHandler.java:89)
> at org.eclipse.emf.texo.server.web.WebServiceServlet.doGet(WebServiceServlet.java:57)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at de.kisters.praesto.filter.DatabaseSwitchFilter.doFilter(DatabaseSwitchFilter.java:42)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
> at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
> at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
> at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
> at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
> at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> at java.lang.Thread.run(Thread.java:722)
>
> The json strings are created in the JSONEObjectStore. I'm pretty confused, because these errors came from nowhere...
>
> I really hope to find the reason for that.
> Best regards
> Bastian
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
| |
Goto Forum:
Current Time: Tue Sep 24 17:56:10 GMT 2024
Powered by FUDForum. Page generated in 0.03908 seconds
|