Array Index out of bound Error

My Line 117 (in main class) :
PortfolioTrade[] obj = mapper.readValue(resolveFileFromResources(args[0]), PortfolioTrade[].class);

[main] ERROR com.crio.warmup.stock.log.UncaughtExceptionHandler - {“stacktrace”:[“com.crio.warmup.stock.PortfolioManagerApplication.main(PortfolioManagerApplication.java:117)”],“cause”:“java.lang.ArrayIndexOutOfBoundsException: 0”}
java.lang.ArrayIndexOutOfBoundsException: 0
at com.crio.warmup.stock.PortfolioManagerApplication.main(PortfolioManagerApplication.java:117) ~[main/:?]

I dont know if its the error, but try this:

Try using file class and then use its instance in readValue rather than taking it directly.

Hey @vipulkrishna have you tried to print your obj or have you tried to iterate over this that it is able to read that value or not and also ArrayIndexOutOfBoundsException is repetitive error which you will get so instead of expecting direct solution debugging will be more helpful for you in future practices and tasks. :v: :+1:

Stucked on same error from two days. Can anyone help me?

15:25:55.553 [main] ERROR com.crio.warmup.stock.log.UncaughtExceptionHandler - {“stacktrace”:[“com.crio.warmup.stock.PortfolioManagerApplication.mainReadQuotes(PortfolioManagerApplication.java:90)”,“com.crio.warmup.stock.PortfolioManagerApplication.main(PortfolioManagerApplication.java:125)”],“cause”:“java.lang.ArrayIndexOutOfBoundsException: 0”}
java.lang.ArrayIndexOutOfBoundsException: 0
at com.crio.warmup.stock.PortfolioManagerApplication.mainReadQuotes(PortfolioManagerApplication.java:90) ~[main/:?]
at com.crio.warmup.stock.PortfolioManagerApplication.main(PortfolioManagerApplication.java:125) ~[main/:?]

I am writing this line in mainReadQuote()…Is it wrong ?
PortfolioTrade[] obj = mapper.readValue(resolveFileFromResources(args[0]), PortfolioTrade[].class);

yes it is wrong line by passing args[0] into the function resolveFileFromResources you have not got data you just have got file path so you have to apply one more function between this to read file content as string.