Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [texo] conversion from json string to EDataType
[texo] conversion from json string to EDataType [message #898894] Sat, 28 July 2012 21:02 Go to next message
Erdal Karaca is currently offline Erdal Karaca
Messages: 750
Registered: July 2009
Senior Member
I have a request like this:

{"test": 1, "_eclass": "myPackage|Test"}

Test.test is of type EDouble, but it is provided an Integer which leads to a ClassCastException...

Should texo handle proper type conversions or do I have to provide the "right" string in the request, i.e. the following request works:

{"test": 1.0, "_eclass": "myPackage|Test"}
Re: [texo] conversion from json string to EDataType [message #898991 is a reply to message #898894] Mon, 30 July 2012 04:24 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5339
Registered: July 2009
Senior Member
He Erdal,
Seems to be a solvable bug, can you post the stacktrace?

gr. Martin

On 07/28/2012 11:02 PM, Erdal Karaca wrote:
> I have a request like this:
>
> {"test": 1, "_eclass": "myPackage|Test"}
>
> Test.test is of type EDouble, but it is provided an Integer which leads to a ClassCastException...
>
> Should texo handle proper type conversions or do I have to provide the "right" string in the request, i.e. the following
> request works:
>
> {"test": 1.0, "_eclass": "myPackage|Test"}
>


--

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] conversion from json string to EDataType [message #899427 is a reply to message #898991] Tue, 31 July 2012 18:56 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal Karaca
Messages: 750
Registered: July 2009
Senior Member
Here is the complete stack trace:

java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double
	at com.example.ExampleModelFactory$MyTypeModelObject.eSet(ExampleModelFactory.java:395)
	at org.eclipse.emf.texo.json.JSONModelConverter.eSet(JSONModelConverter.java:78)
	at org.eclipse.emf.texo.json.BaseJSONModelConverter.convertSingleEAttribute(BaseJSONModelConverter.java:402)
	at org.eclipse.emf.texo.json.BaseJSONModelConverter.convertContent(BaseJSONModelConverter.java:211)
	at org.eclipse.emf.texo.json.BaseJSONModelConverter.doConvert(BaseJSONModelConverter.java:108)
	at org.eclipse.emf.texo.json.BaseJSONModelConverter.convert(BaseJSONModelConverter.java:103)
	at org.eclipse.emf.texo.server.service.json.JSONServiceContext.getRequestData(JSONServiceContext.java:91)
	at org.eclipse.emf.texo.server.service.UpdateInsertModelOperation.internalExecute(UpdateInsertModelOperation.java:42)
	at org.eclipse.emf.texo.server.service.ModelOperation.execute(ModelOperation.java:48)
	at org.eclipse.emf.texo.server.web.WebServiceHandler.doPost(WebServiceHandler.java:107)
	at org.eclipse.emf.texo.server.web.WebServiceHandler.doPut(WebServiceHandler.java:121)
	at org.eclipse.emf.texo.server.web.WebServiceServlet.doPut(WebServiceServlet.java:73)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.eclipse.emf.texo.server.store.CurrentEntityManagerRequestFilter.doFilter(CurrentEntityManagerRequestFilter.java:65)
	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:240)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)


I did not have a look at the json implementation (json.org), but it should be the best to provide type information to the de-serialization of json strings.
Re: [texo] conversion from json string to EDataType [message #899439 is a reply to message #899427] Tue, 31 July 2012 19:53 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5339
Registered: July 2009
Senior Member
Hi Erdal,
I published a new build which should solve this. Can you try?

gr. Martin

On 07/31/2012 08:56 PM, Erdal Karaca wrote:
> Here is the complete stack trace:
>
>
> java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double
> at com.example.ExampleModelFactory$MyTypeModelObject.eSet(ExampleModelFactory.java:395)
> at org.eclipse.emf.texo.json.JSONModelConverter.eSet(JSONModelConverter.java:78)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.convertSingleEAttribute(BaseJSONModelConverter.java:402)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.convertContent(BaseJSONModelConverter.java:211)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.doConvert(BaseJSONModelConverter.java:108)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.convert(BaseJSONModelConverter.java:103)
> at org.eclipse.emf.texo.server.service.json.JSONServiceContext.getRequestData(JSONServiceContext.java:91)
> at org.eclipse.emf.texo.server.service.UpdateInsertModelOperation.internalExecute(UpdateInsertModelOperation.java:42)
> at org.eclipse.emf.texo.server.service.ModelOperation.execute(ModelOperation.java:48)
> at org.eclipse.emf.texo.server.web.WebServiceHandler.doPost(WebServiceHandler.java:107)
> at org.eclipse.emf.texo.server.web.WebServiceHandler.doPut(WebServiceHandler.java:121)
> at org.eclipse.emf.texo.server.web.WebServiceServlet.doPut(WebServiceServlet.java:73)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at
> org.eclipse.emf.texo.server.store.CurrentEntityManagerRequestFilter.doFilter(CurrentEntityManagerRequestFilter.java:65)
> 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:240)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
> at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
> at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
> at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
>
>
> I did not have a look at the json implementation (json.org), but it should be the best to provide type information to
> the de-serialization of json strings.
>


--

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] conversion from json string to EDataType [message #899654 is a reply to message #899439] Wed, 01 August 2012 17:01 Go to previous message
Erdal Karaca is currently offline Erdal Karaca
Messages: 750
Registered: July 2009
Senior Member
Git master works, thanks!
Previous Topic:[EEF] Changing Representation of attributes of an Eclass with multiple SuperTypes
Next Topic:EMFStore Default Host
Goto Forum:
  


Current Time: Fri Oct 31 19:29:58 GMT 2014

Powered by FUDForum. Page generated in 0.02524 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software