Mangosoft-team / Demo

0 stars 0 forks source link

UnsupportedOperationException #20

Closed sashkoif closed 5 years ago

sashkoif commented 5 years ago

When open http://localhost:10002 I get empty list of loan agreements on view element. In cosole I get

com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.UnsupportedOperationException) 
(through reference chain: java.util.ArrayList[0]-
>de.varengold.cdl.core.model.contract.loanAgreement.LoanAgreement["securityAgreements"]-
>java.util.ArrayList[0]->de.varengold.cdl.core.model.collateral.SecurityAgreement["collAgreements"]-
>java.util.ArrayList[0]->de.varengold.cdl.core.model.collateral.CollateralAgreement["collaterals"]-
>java.util.ArrayList[0]->de.varengold.cdl.core.model.collateral.Collateral["cashCollaterals"]-
>java.util.Collections$UnmodifiableRandomAccessList[0])
    at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
    at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
    at com.fasterxml.jackson.databind.deser.impl.SetterlessProperty.deserializeAndSet(SetterlessProperty.java:133)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
    at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:136)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
    at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:136)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:127)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3023)

I receive it when should be executed this loanAgreements = mapper.readValue(jsonResult, new TypeReference<List<LoanAgreement>>(){}); On previous vesions of core-model and server all was fine. Do you have any suggestions what could it be or how can it be solved?

sashkoif commented 5 years ago

This is full method

public static List<LoanAgreement> getLoanAgreements() {
        List<LoanAgreement> loanAgreements = new ArrayList<LoanAgreement>();

        String accessToken = TokenService.getAccessToken();
        String jsonResult = "";

        try {           
            jsonResult = ConnectorService.getGETResponse(accessToken, "loanagreements");
            JavaTimeModule module = new JavaTimeModule();
            module.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")));
            module.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")));
            ObjectMapper mapper = new ObjectMapper().registerModule(module);
                    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                    loanAgreements = mapper.readValue(jsonResult, new TypeReference<List<LoanAgreement>>(){});
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return loanAgreements;
}
sashkoif commented 5 years ago

I try to use edited JSON result. I removed all elements from cashCollaterals array. I know it's incorrect but it works.

CT-VG commented 5 years ago

Please try with the latest model version

sashkoif commented 5 years ago

it works!