Skip to content

Restlet.handle method occurs NullPointerException #1214

Open
@varlinor

Description

@varlinor

When I use restlet to request RESTFUL URL, it does not work! I tried messes of solutions ,but they don't work. but when I change another restful url, restlet framework works rightly!
I just want to know, what kind of case will cause this error. below is the error info:

[2016-05-31 15:24:47] [WARNING] [System.out] [java.lang.NullPointerException]
[2016-05-31 15:24:47] [WARNING] [System.out] [ at org.restlet.Restlet.handle(Restlet.java:230)]
[2016-05-31 15:24:47] [WARNING] [System.out] [ at org.restlet.Client.handle(Client.java:174)]
[2016-05-31 15:24:47] [WARNING] [System.out] [ at org.restlet.Client.handle(Client.java:168)]

My test code is like this:

Client client=new Client(Arrays.asList(new Protocol[] { Protocol.HTTP,Protocol.HTTPS })));
String mapsUri = "http://localhost:8090/iserver/services/map-china400/rest/maps/China/queryResults.rjson?returnContent=true";
Request request=new Request(Method.POST, mapsUri);
com.supermap.services.components.commontypes.QueryParameterSet queryParams = new com.supermap.services.components.commontypes.QueryParameterSet();// 查询参数
com.supermap.services.components.commontypes.QueryParameter param = new com.supermap.services.components.commontypes.QueryParameter();
param.name = "GangAo_ln@China400";
queryParams.queryParams = new com.supermap.services.components.commontypes.QueryParameter[] { param };
queryParams.expectCount = 20;
queryParams.startRecord = 0;
JSONObject queryEntity = new JSONObject();
JsonEncoder encoder = new JsonEncoder();
String queryParamsText = encoder.toRepresentation(MediaType.APPLICATION_JSON, queryParams).getText();
// put some parameters into object
queryEntity.put("queryMode", "SqlQuery");
queryEntity.put("queryParameters", new JSONObject(queryParamsText));
queryEntity.put("spatialQueryMode", "INTERSECT");
queryEntity.put("distance", 1);
JsonRepresentation requestEntity = new JsonRepresentation(queryEntity);
request.setEntity(requestEntity);
Response response = client.handle(request);
String text = response.getEntityAsText();
System.out.println("output:"+text);

the version of restlet in my project is 2.0.11

expect your support

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions