0

我在发送一组自定义对象时遇到以下错误。

2015 年 10 月 21 日晚上 7:28:38 com.amazonaws.services.dynamodbv2.datamodeling.marshallers.ObjectSetToStringSetMarshaller marshall 警告:将一组非字符串对象编组到 DynamoDB StringSet。除非您真的知道自己在做什么,否则您将无法从 DynamoDB 中读取这些对象:这可能是一个错误。如果您确实知道自己在做什么,请随意忽略此警告,但请考虑为此使用自定义封送处理程序。

com.amazonaws.AmazonServiceException:一个或多个参数值无效:com.amazonaws.http.AmazonHttpClient 上的字符串集可能不为空(服务:AmazonDynamoDBv2;状态代码:400;错误代码:ValidationException;请求 ID:S61P89234SI8PE61M8I9QTG8RNVV4KQNSO5AEMVJF66Q9ASUAAJG)。 com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:766) 的 handleErrorResponse(AmazonHttpClient.java:1181) com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:485) com.amazonaws.http.AmazonHttpClient .execute(AmazonHttpClient.java:306) 在 com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:1799) 在 com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.updateItem(AmazonDynamoDBClient.java:1614) 在 com。 amazonaws.services.dynamodbv2.datamodeling。DynamoDBMapper$SaveObjectHandler.doUpdateItem(DynamoDBMapper.java:1241) 在 com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper$2.executeLowLevelRequest(DynamoDBMapper.java:937) 在 com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper$SaveObjectHandler.execute (DynamoDBMapper.java:1120) 在 com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.save(DynamoDBMapper.java:966) 在 com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.save(DynamoDBMapper.java:758) 在.dao.impl.DeviceDaoImpl.addDevice(DeviceDaoImpl.java:57) 在 .admin.device.service.impl.DeviceServiceImpl.addDevice(DeviceServiceImpl.java:38)DynamoDBMapper$SaveObjectHandler.execute(DynamoDBMapper.java:1120) 在 com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.save(DynamoDBMapper.java:966) 在 com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.save(DynamoDBMapper.save) java:758) 在 .dao.impl.DeviceDaoImpl.addDevice(DeviceDaoImpl.java:57) 在 .admin.device.service.impl.DeviceServiceImpl.addDevice(DeviceServiceImpl.java:38)DynamoDBMapper$SaveObjectHandler.execute(DynamoDBMapper.java:1120) 在 com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.save(DynamoDBMapper.java:966) 在 com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.save(DynamoDBMapper.save) java:758) 在 .dao.impl.DeviceDaoImpl.addDevice(DeviceDaoImpl.java:57) 在 .admin.device.service.impl.DeviceServiceImpl.addDevice(DeviceServiceImpl.java:38)

这是发生这种情况的代码片段

    @DynamoDBTable(tableName="Device")
public class Device extends BaseEntity implements Serializable{
private Set<AsscoiatedReviewer> asscoiatedReviewers ;
// getters setter

    public Device addDevice(Device device) {
        device.setDeviceId(generateId());
        device.setCreatedTime(getCurrentTime());
        if (!StringUtils.isNullOrEmpty(device.getPincode())) {
            // get lat and long - do this for review team as well
            //TODO : move it to common place that can be accessed for review team too
            setLatLong(device);
            // calculate the distances between this organization and reviewers
            calculateAsscoiatedReviewersDistances(device);
        }
        mapper.save(device);
        Device device1 = mapper.load(Device.class, device.getDeviceId());


        return device1;
    }

    private void calculateAsscoiatedReviewersDistances(Device device)  {
        if(StringUtils.isNullOrEmpty(device.getPincode())) return;
        try {
            List<ReviewTeam> ReviewTeam = reviewTeamDao.getAllReviewTeams();
            Set<AsscoiatedReviewer> asscoiatedReviewers = new HashSet<AsscoiatedReviewer>();
            /*for (ReviewTeam reviewTeam2 : ReviewTeam) {
                if(StringUtils.isNullOrEmpty(reviewTeam2.getPincode())) continue;
                AsscoiatedReviewer asscoiatedReviewer = new AsscoiatedReviewer();
                asscoiatedReviewer.setReviewTeamId(reviewTeam2.getReviewTeamId());
                double distance = distance(new Double(device.getLat()), new Double(device.getLongt()),
                        new Double(reviewTeam2.getLat()), new Double(reviewTeam2.getLongt()));
                asscoiatedReviewer.setDistance(new Double(distance).toString());
                asscoiatedReviewers.add(asscoiatedReviewer);
            }*/
            device.setAsscoiatedReviewers(asscoiatedReviewers);

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
    public class AsscoiatedReviewer implements Serializable,Comparable {

    /**
     *
     */
    private static final long serialVersionUID = -1906388056843006046L;

    private String distance;
    private String reviewTeamId;
// getters setters 
}

似乎错误是从以下行发生的 device.setAsscoiatedReviewers(asscoiatedReviewers);

这应该被编组/解组并发送到亚马逊吗?任何帮助将不胜感激 。

更新:当在 asscoiatedReviewers 中填充数据时,我收到以下异常

警告:将一组非字符串对象编组到 DynamoDB 字符串集。除非您真的知道自己在做什么,否则您将无法从 DynamoDB 中读取这些对象:这可能是一个错误。如果您确实知道自己在做什么,请随意忽略此警告,但请考虑为此使用自定义封送处理程序。com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException:如果没有自定义编组器或 @DynamoDBDocument 注释,则无法解组以键入 in.forus.foruscare.entity.AsscoiatedReviewer 类。在 com.amazonaws.services.dynamodbv2.datamodeling.ConversionSchemas$StandardItemConverter.getObjectUnmarshaller(ConversionSchemas.java:590) 在 com.amazonaws.services.dynamodbv2.datamodeling.ConversionSchemas$StandardItemConverter.augment(ConversionSchemas.java:497) 在 com.amazonaws .services.dynamodbv2。

这是否意味着我需要编写自定义编组器或使用 DynamoDBDocument 注释进行注释。如果是,这是一组自定义对象,您能否将指向 marshaller 的简单示例的指针发送给我。我碰巧看了其他 marshllers,他们似乎没有解释我需要什么

4

0 回答 0