我有一个从 postgis 检索地理空间数据(线串)的服务,我想将此地理空间数据作为 JSON 数据发送到 RestEasy + Jackson 的 REST 服务之外。有人知道如何将这些空间数据转换为 JSON 吗?
我的实体:
public class Route {
...
private LineString caminho;
public Rota() {
}
public Rota(Integer id, Usuario usuario, String descricao, LineString lineString) {
this.id = id;
this.usuario = usuario;
this.descricao = descricao;
this.caminho = lineString;
}
// getters and setters
@Type(type = "org.hibernate.spatial.GeometryType")
public LineString getCaminho() {
return caminho;
}
public void setCaminho(LineString caminho) {
this.caminho = caminho;
}
// hashcode and equals method
}
我的 REST 服务:
@Inject
private RotaBC rotaBC;
@GET
@Path("/rotas/{idrota}")
@Produces("application/json")
public Route show(@PathParam("id") String id) {
return rotaBC.show(Integer.parseInt(id));
}
错误:
15:05:16,447 错误 [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/sharecar].[default]] (http--0.0.0.0-8080-1) Servlet.service() 默认抛出异常:java.lang.ClassNotFoundException: org.codehaus.jackson.map.JsonMappingException$Reference from [Module "org.codehaus.jackson.jackson-mapper-asl:main" from local module loader @1d332b(根:/opt/demoiselle/server/jboss-7.1/modules)]
...
在 org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
在 org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:166)
...
在 org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) 在 org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) 在 org.codehaus.jackson .map.ser.BeanSerializer.serialize(BeanSerializer.java:112)