I'm trying to make a method, which uses the Json data with jackson library to have a list of objects. If I run my code, I get the error:
java.lang.reflect.InaccessibleObjectException: Unable to make field private final int java.time.LocalDate.year accessible: module java.base does not "opens java.time" to unnamed module @5c90e579
Why is it giving me an error about LocalDate even though I have JodaModul in my Code?
public static List<Tweet> getTweetsFile() throws Exception{
ObjectMapper mapper = new ObjectMapper().
registerModule(new JodaModule()).
configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
File path = new File ("C:/Users/PC/eclipse-workspace/hw4/tw.json");
List<Tweet> myObjects3 = Arrays.asList(mapper.readValue(path, Tweet.class));
return myObjects3;
}
How it looks in my File:
[{"date":"2001-12-28","tweetNumber":1,"country":"England","comments":11,"message":"I like to watch anime and reading books","retweets":3,"username":"Isabelle","likes":55},{"date":"2003-05-11","tweetNumber":2,"country":"France","comments":25,"message":"I'm Viatnamese, but I live in France","retweets":30,"username":"Vin","likes":110}..
It's not in the right order like my Object has in their constructor, could that be the reaseon?
java.base
module and click Expose Package... button. Enter as Packagejava.time
, as Target moduleUNNAMED
and select opens. Does this fix your issue? But probably the root cause is that you use a too old library that was written for an older Java version. So first check, if your used libraries are up to date. – Dishtowel