在对 Restful 服务器的 POST 请求中"Can not instantiate abstract type" JSON 错误



我正在尝试使用JSON格式(使用Chrome的附加组件Advanced Rest Api)在Restful服务器上执行POST请求。下面是 JSON 字符串:(带标题:接受:应用程序/json;授权:基本...

{
"datecreated": 1355237359326,
"datemodified": 1355237359326,
"entrylocation": "Düdingen",
"entrydate": 1347351720000,
"entryduration": 11900,
"comment": "Random text",
"publicvisible": 2,
-
"coursetype": "Running track (Outdoor)",
"courselength": 600,
"numberofrounds": 12,
"track": "Fast track"
}

我收到以下错误:

Can not instantiate abstract type [simple type, class ch.unifr.cybercoach.server.entities.jaxb.entries.Entry] (need to add/enable type         information?) 
at [Source: org.eclipse.jetty.server.HttpInput@65ab8182; line: 1, column: 2]

这很奇怪,因为相同的 POST 请求适用于 XML 格式:

 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <entryrunning>
 <comment>Random text</comment>
 <entrydate>2012-09-11T10:22:00+02:00</entrydate>
 <entryduration>11900</entryduration>
 <entrylocation>Düdingen</entrylocation>
 <publicvisible>2</publicvisible>
 <courselength>600</courselength>
 <coursetype>Running track (Outdoor)</coursetype>
 <numberofrounds>12</numberofrounds>
 <track>
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPGttbCB4bWxucz0iaHR0cDovL3d3dy5vcGVuZ2lzLm5ldC9rbWwvMi4yIj4KICA8RG9jdW1lbnQ+CiAgICAgICAgICA8L1BvbHlnb24+CiAgICAgICAgPC9QbGFjZW1hcms+CiAgICAgIDwvRm9sZGVyPgogICAgPC9Gb2xkZXI+CiAgPC9Eb2N1bWVudD4KPC9rbWw+Cg==</track>
 </entryrunning>

有人知道吗?

提前非常感谢!

sys.stderr 原来是对的 - 谢谢(请参阅我的问题帖子下面的评论)。服务器端的解组出现问题。现在这已修复,以下 json 字符串工作正常:

{"entryrunning" :{
"datecreated": 1355237359326,
"datemodified": 1355237359326,
"entrylocation": "Düdingen",
"entrydate": 1347351720000,
"entryduration": 11900,
"comment": "Random text",
"publicvisible": 2,
"coursetype": "Running track (Outdoor)",
"courselength": 600,
"numberofrounds": 12,
"track": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPGttbCB4bWxucz0iaHR0cDovL3d3dy5vcGVuZ2lzLm5ldC9rbWwvMi4yIj4KICA8RG9jdW1lbnQ+CiAgICAgICAgICA8L1BvbHlnb24+CiAgICAgICAgPC9QbGFjZW1hcms+CiAgICAgIDwvRm9sZGVyPgogICAgPC9Gb2xkZXI+CiAgPC9Eb2N1bWVudD4KPC9rbWw+Cg=="
}}

相关内容

最新更新