Unexpected error during response processing Can not deserialize instance of java.lang.String out of

异常信息如下:



十二月 18, 2012 6:41:18 下午 org.glassfish.jersey.filter.LoggingFilter log
INFO: 8 * LoggingFilter - Response received on thread main
8 < 200
8 < Date: Tue, 18 Dec 2012 10:41:18 GMT
8 < Content-Length: 564
8 < Connection: keep-alive
8 < Content-Type: application/json
8 < X-Compute-Request-Id: req-d2df79ae-532d-493c-8801-dbc698ed8c8a
{"images": [{"id": "267e2d08-da40-4ddc-9321-76a437d962d3", "links": [{"href": "http://192.168.120.228:8774/v2/71ee1f0d07e04776827d78c21b3d3974/images/267e2d08-da40-4ddc-9321-76a437d962d3", "rel": "self"}, {"href": "http://192.168.120.228:8774/71ee1f0d07e04776827d78c21b3d3974/images/267e2d08-da40-4ddc-9321-76a437d962d3", "rel": "bookmark"}, {"href": "http://192.168.120.228:9292/71ee1f0d07e04776827d78c21b3d3974/images/267e2d08-da40-4ddc-9321-76a437d962d3", "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "Ubuntu 12.04 cloudimg amd64"}]}

Exception in thread "main" javax.ws.rs.client.ClientException: Unexpected error during response processing.
    at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:725)
    at org.glassfish.jersey.client.JerseyInvocation.access$500(JerseyInvocation.java:86)
    at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:629)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:420)
    at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:625)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:360)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:260)
    at edu.hnu.lost.openstack.glance.test.MyGlanceUtils$ListMyGlance.execute(MyGlanceUtils.java:29)
    at edu.hnu.lost.openstack.glance.test.MyGlanceUtils$ListMyGlance.execute(MyGlanceUtils.java:1)
    at org.openstack.glance.GlanceClient.execute(GlanceClient.java:19)
    at edu.hnu.lost.openstack.glance.test.TestOpenstackGlance01.ListGlanceimage(TestOpenstackGlance01.java:86)
    at edu.hnu.lost.openstack.glance.test.TestOpenstackGlance01.main(TestOpenstackGlance01.java:38)
Caused by: javax.ws.rs.MessageProcessingException: Error reading entity from input stream.
    at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:826)
    at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:749)
    at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:94)
    at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:719)
    ... 11 more
Caused by: org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "links" (Class edu.hnu.lost.openstack.glance.test.Image), not marked as ignorable
 at [Source: org.glassfish.jersey.message.internal.EntityInputStream@7d6a05fd; line: 1, column: 70] (through reference chain: edu.hnu.lost.openstack.glance.test.Images["images"]->edu.hnu.lost.openstack.glance.test.Image["links"])
    at org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:53)
    at org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldException(StdDeserializationContext.java:267)
    at org.codehaus.jackson.map.deser.std.StdDeserializer.reportUnknownProperty(StdDeserializer.java:673)
    at org.codehaus.jackson.map.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:659)
    at org.codehaus.jackson.map.deser.BeanDeserializer.handleUnknownProperty(BeanDeserializer.java:1365)
    at org.codehaus.jackson.map.deser.BeanDeserializer._handleUnknown(BeanDeserializer.java:725)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:703)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
    at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:217)
    at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:194)
    at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:30)
    at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
    at org.codehaus.jackson.map.deser.SettableBeanProperty$FieldProperty.deserializeAndSet(SettableBeanProperty.java:579)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
    at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2704)
    at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1315)
    at org.codehaus.jackson.jaxrs.JacksonJsonProvider.readFrom(JacksonJsonProvider.java:419)
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:208)
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:158)
    at org.glassfish.jersey.message.internal.ExceptionWrapperInterceptor.aroundReadFrom(ExceptionWrapperInterceptor.java:70)
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:158)
    at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:852)
    at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:811)
    ... 14 more




在网上搜索 

有个美女的帖子 http://blog.csdn.net/lifeifei2010/article/details/8216586


她碰到的问题:


  1. Exception in thread "main" javax.ws.rs.client.ClientException: Unexpected error during response processing.  
  2.     at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:725)  
  3.     at org.glassfish.jersey.client.JerseyInvocation.access$500(JerseyInvocation.java:86) 

  1. Caused by: org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "issued_at" (Class org.openstack.keystone.model.Access$Token), not marked as ignorable  
  2.  at [Source: org.glassfish.jersey.message.internal.EntityInputStream@145f939; line: 1, column: 37] (through reference chain: org.openstack.keystone.model.Access["token"]->org.openstack.keystone.model.Token["issued_at"]) 

处理结果是在org.openstack.keystone.model.Access类中添加


  1. private String issued_at;  
  2.         public String getIssued_at() {  
  3.             return issued_at;  
  4.         }  
  5.   
  6.         public void setIssued_at(String issuedAt) {  
  7.             issued_at = issuedAt;  
  8.         } 


我试着在 image中添加了相应的 get 和set 方法


然后出现如下诡异的错误:   Can not deserialize instance of java.lang.String out of START_ARRAY token


Exception in thread "main" javax.ws.rs.client.ClientException: Unexpected error during response processing.
    at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:725)
    at org.glassfish.jersey.client.JerseyInvocation.access$500(JerseyInvocation.java:86)
    at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:629)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:420)
    at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:625)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:360)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:260)
    at edu.hnu.lost.openstack.glance.test.MyGlanceUtils$ListMyGlance.execute(MyGlanceUtils.java:29)
    at edu.hnu.lost.openstack.glance.test.MyGlanceUtils$ListMyGlance.execute(MyGlanceUtils.java:1)
    at org.openstack.glance.GlanceClient.execute(GlanceClient.java:19)
    at edu.hnu.lost.openstack.glance.test.TestOpenstackGlance01.ListGlanceimage(TestOpenstackGlance01.java:86)
    at edu.hnu.lost.openstack.glance.test.TestOpenstackGlance01.main(TestOpenstackGlance01.java:38)
Caused by: javax.ws.rs.MessageProcessingException: Error reading entity from input stream.
    at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:826)
    at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:749)
    at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:94)
    at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:719)
    ... 11 more
Caused by: org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.String out of START_ARRAY token
 at [Source: org.glassfish.jersey.message.internal.EntityInputStream@7d6a05fd; line: 1, column: 58] (through reference chain: edu.hnu.lost.openstack.glance.test.Images["images"]->edu.hnu.lost.openstack.glance.test.Image["links"])

    at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163)
    at org.codehaus.jackson.map.deser.StdDeserializationContext.mappingException(StdDeserializationContext.java:219)
    at org.codehaus.jackson.map.deser.std.StringDeserializer.deserialize(StringDeserializer.java:44)
    at org.codehaus.jackson.map.deser.std.StringDeserializer.deserialize(StringDeserializer.java:13)
    at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
    at org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
    at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:217)
    at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:194)
    at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:30)
    at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
    at org.codehaus.jackson.map.deser.SettableBeanProperty$FieldProperty.deserializeAndSet(SettableBeanProperty.java:579)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
    at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2704)
    at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1315)
    at org.codehaus.jackson.jaxrs.JacksonJsonProvider.readFrom(JacksonJsonProvider.java:419)
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:208)
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:158)
    at org.glassfish.jersey.message.internal.ExceptionWrapperInterceptor.aroundReadFrom(ExceptionWrapperInterceptor.java:70)
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:158)
    at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:852)
    at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:811)
    ... 14 more


目前正在 寻找原因 ???
对JSON 不是很熟悉 ,初看起来好像 是json在转换的时候 format 出错  无法反序列化??

你可能感兴趣的:(Unexpected error during response processing Can not deserialize instance of java.lang.String out of)