我是关于在 stackoverflow 上发布答案的新手。我希望你能帮助我。
我正在使用谷歌地图开发一个安卓应用程序。它通过 HTTP REST 调用 JBOSS 7 服务器,该服务器通过 HTTP REST 调用另一个服务器以从一些开放数据中获取一些点。然后,当第一个服务器收到响应时,它必须为智能手机客户端准备数据。因此,它使用 GeoPoint 准备了一个 OverlayItem 的数组列表。但是在创建 GeoPoint 的时候有一个例外。
我已将 maps.jar 和 gson-2.2.2.jar 放在 /WebContent/WEB-INF/lib/ 中,它似乎可以工作,但我对 Java 和 JBoss 不是那么专家,不知道它是否正确。
这是 JBoss 控制台中的异常:
11:36:23,287 错误 [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Prototipo_server_2].[it.unifi.sistemiTelematici.BikeServer.Rest.BikeServerREST]] (http --0.0.0.0-8080-1) Servlet it.unifi.sistemiTelematici.BikeServer.Rest.BikeServerREST 的 Servlet.service() 抛出异常:org.jboss.resteasy.spi.UnhandledException: java.lang.RuntimeException: stub at org .jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:340) [resteasy-jaxrs-2.3.2.Final.jar:] at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:214) [resteasy-jaxrs-2.3.2.Final.jar:] at org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:190) [resteasy-jaxrs-2.3.2.Final.jar:] at org. jboss.resteasy.core。SynchronousDispatcher.getResponse(SynchronousDispatcher.java:540) [resteasy-jaxrs-2.3.2.Final.jar:] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:502) [resteasy-jaxrs-2.3。 2.Final.jar:] 在 org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [resteasy-jaxrs-2.3.2.Final.jar:] 在 org.jboss.resteasy.plugins.server .servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.2.Final.jar:] at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.2.Final.jar:] 在 org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.2.Final.jar: ] 在 javax.servlet.http.HttpServlet。服务(HttpServlet.java:847)[jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:] at org.apache.catalina。 core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13. Final.jar:] 在 org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final] 在 org. apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:] 在 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:] 在 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve .java:109) [jbossweb-7.0.13.Final.jar:] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:] at org .apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:] at java。 lang.Thread.run(未知来源)[rt.jar:1.7.0_09] 原因:java.lang.RuntimeException:com.google.android.maps 的存根。GeoPoint.(Unknown Source) [maps.jar:] at it.unifi.sistemiTelematici.BikeServer.Rest.ServiziRastrelliere.getRastrelliereList(ServiziRastrelliere.java:100) [classes:] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ rt.jar:1.7.0_09] 在 sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_09] 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_09]在 java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_09] 在 org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:155) [resteasy-jaxrs-2.3.2 .Final.jar:] 在 org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257) [resteasy-jaxrs-2.3.2.Final.jar:] 在 org.jboss.resteasy.core.ResourceMethod。调用(资源方法.java:222) [resteasy-jaxrs-2.3.2.Final.jar:] 在 org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211) [resteasy-jaxrs-2.3.2.Final.jar:] 在org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:525) [resteasy-jaxrs-2.3.2.Final.jar:] ... 还有 19 个
这是给出异常的类的代码:
package it.unifi.sistemiTelematici.BikeServer.Rest;
import it.unifi.sistemiTelematici.BikeServer.JSON.JSONArray;
import it.unifi.sistemiTelematici.BikeServer.JSON.JSONException;
import it.unifi.sistemiTelematici.BikeServer.JSON.JSONObject;
import it.unifi.sistemiTelematici.BikeServer.Utils.CoordinatesUtilities;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.OverlayItem;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
@Path("/ServiziRastrelliere")
public class ServiziRastrelliere {
private RestComuneFirenze restComune;
private CoordinatesUtilities CoordinatesUtilities;
public ServiziRastrelliere() {
restComune = new RestComuneFirenze();
CoordinatesUtilities = new CoordinatesUtilities();
}
JSONArray rastrelliereFeatures = null;
@GET
@Produces("application/json")
@Path("/RastrelliereList/{latitudine}/{longitudine}")
public String getRastrelliereList(@PathParam("latitudine") String latitudine, @PathParam("longitudine") String longitudine){
String rastrelliereListJSON = null;
JSONObject rastrellieraObj, rastrellieraGeometryObj, rastrellieraPropertiesObj;
JSONArray rastrellieraCoordinates;
double rastrellieraCoordX, rastrellieraCoordY;
int rastrellieraCoordXint, rastrellieraCoordYint;
String rastrellieraPostiString, rastrellieraLocalizzazione, rastrellieraModello;
List<OverlayItem> myOverlayItemList = new ArrayList<OverlayItem>();
Type listOfMyOverlayItemType = new TypeToken<List<OverlayItem>>(){}.getType();
rastrelliereFeatures = restComune.getRastrelliereList(latitudine, longitudine);
if (rastrelliereFeatures != null) {
try {
for (int i = 0; i < rastrelliereFeatures.length(); i ++) {
rastrellieraObj = rastrelliereFeatures.getJSONObject(i);
rastrellieraGeometryObj = rastrellieraObj.getJSONObject("geometry");
rastrellieraCoordinates = rastrellieraGeometryObj.getJSONArray("coordinates");
rastrellieraCoordX = rastrellieraCoordinates.getDouble(0);
rastrellieraCoordY = rastrellieraCoordinates.getDouble(1);
rastrellieraCoordXint = CoordinatesUtilities.fromJSONtoItemCoord(rastrellieraCoordX);
rastrellieraCoordYint = CoordinatesUtilities.fromJSONtoItemCoord(rastrellieraCoordY);
rastrellieraPropertiesObj = rastrellieraObj.getJSONObject("properties");
rastrellieraPostiString = rastrellieraPropertiesObj.get("NUMPOSTI").toString();
rastrellieraLocalizzazione = rastrellieraPropertiesObj.getString("LOCALIZZAZIONE");
rastrellieraModello = rastrellieraPropertiesObj.getString("MODELLO");
//myOverlayItemList.add(new OverlayItem(new GeoPoint(rastrellieraCoordYint, rastrellieraCoordXint), rastrellieraLocalizzazione, "Modello = " + rastrellieraModello + "Posti: " + rastrellieraPostiString));
System.out.println("rastrellieraCoordYint = " + rastrellieraCoordYint + " rastrellieraCoordXint = " + rastrellieraCoordXint);
//myOverlayItemList.add(new OverlayItem(new GeoPoint(rastrellieraCoordYint, rastrellieraCoordXint), "a", "b"));
GeoPoint geopoint = new GeoPoint(43770262, 11252829);
//myOverlayItemList.add(new OverlayItem( new GeoPoint(43770262, 11252829), "Access Title 1", "Access snippet 1"));
}
} catch (JSONException ex) {
ex.printStackTrace();
}
Gson gson = new Gson();
rastrelliereListJSON = gson.toJson(myOverlayItemList, listOfMyOverlayItemType);
} else {
rastrelliereListJSON = "error";
}
return rastrelliereListJSON;
}
}