Module 4 Build Error

Getting the following error while i try to Test Build.
Can someone help?
ERROR com.crio.warmup.stock.log.UncaughtExceptionHandler - {“stacktrace”:[“org.springframework.http.converter.json.AbstractJacks
on2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:242)”,“org.springframework.http.converter.json.AbstractJackson2HttpMe
ssageConverter.read(AbstractJackson2HttpMessageConverter.java:227)”,“org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:104)”,“org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:744)”,“org.springframework.web.client.RestTemplate.execute(RestTemplate.java:677)”,“org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:318)”,“com.crio.warmup.stock.portfolio.PortfolioManagerImpl.getStockQuote(PortfolioManagerImpl.java:72)”,“com.crio.warmup.stock.portfolio.PortfolioManagerImpl.calculateAnnualizedReturn(PortfolioManagerImpl.java:115)”,“com.crio.warmup.stock.PortfolioManagerApplication.mainCalculateReturnsAfterRefactor(PortfolioManagerApplication.java:308)”,“com.crio.warmup.stock.PortfolioManagerApplication.main(PortfolioManagerApplication.java:320)”],“cause”:“org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class com.crio.warmup.stock.dto.Candle]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of com.crio.warmup.stock.dto.Candle (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information\n at [Source: (PushbackInputStream); line: 1, column: 2] (through reference chain: java.lang.Object[][0])”}
org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class com.crio.warmup.stock.dto.Candle]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of com.crio.warmup.stock.dto.Candle (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
at [Source: (PushbackInputStream); line: 1, column: 2] (through reference chain: java.lang.Object[][0])
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:242) ~[spring-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:227) ~[spring-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:104) ~[spring-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:744) ~[spring-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:677) ~[spring-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:318) ~[spring-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at com.crio.warmup.stock.portfolio.PortfolioManagerImpl.getStockQuote(PortfolioManagerImpl.java:72) ~[main/:?]
at com.crio.warmup.stock.portfolio.PortfolioManagerImpl.calculateAnnualizedReturn(PortfolioManagerImpl.java:115) ~[main/:?]
at com.crio.warmup.stock.PortfolioManagerApplication.mainCalculateReturnsAfterRefactor(PortfolioManagerApplication.java:308) ~[main/:?]
at com.crio.warmup.stock.PortfolioManagerApplication.main(PortfolioManagerApplication.java:320) ~[main/:?]
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of com.crio.warmup.stock.dto.Candle (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
at [Source: (PushbackInputStream); line: 1, column: 2] (through reference chain: java.lang.Object[][0])
at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67) ~[jackson-databind-2.10.1.jar:2.10.1]
at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1589) ~[jackson-databind-2.10.1.jar:2.10.1]
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1055) ~[jackson-databind-2.10.1.jar:2.10.1]
at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserialize(AbstractDeserializer.java:265) ~[jackson-databind-2.10.1.jar:2.10.1]
at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:195) ~[jackson-databind-2.10.1.jar:2.10.1]
at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:21) ~[jackson-databind-2.10.1.jar:2.10.1]
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4202) ~[jackson-databind-2.10.1.jar:2.10.1]
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3258) ~[jackson-databind-2.10.1.jar:2.10.1]
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:239) ~[spring-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
… 9 more

You are trying to create an object of an interface. We can only implement interfaces and create instances for classes

This is your stack trace when the error occured. Try to pinpoint the method which is causing the error to see the line at which the bug is present

Im so sorry! i just found the reason… I am soo soo sorry! i was using Candle[] class instead of TiingoCandle[]. And thank you soo very much for looking through my long error… Thanks a ton man!! :slight_smile:

No problem :slight_smile: Now, I know what to do when I get this error :sweat_smile:

1 Like