-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Illegal reflective access by com.fasterxml.jackson.databind.util.ClassUtil to field java.time.format.DateTimeFormatter.locale #2626
Comments
Thanks! This is sort of useful -- it already made sense that the warning comes from introspection, trying to access something that Java 9+ module system would block. Question of what to do with |
Hello, The similar one happened to Here are clauses. @Test
public void exceptionExpectJSR310DateTypes() {
var mapper = new ObjectMapper();
// given
VarietyDateType dateType = VarietyDateType.builder()
.localDateTime(LocalDateTime.now())
.localDate(LocalDate.now())
.localTime(LocalTime.now())
.zonedDateTime(ZonedDateTime.now(ZoneId.of("UTC")))
.duration(Duration.ofDays(1))
.instant(Instant.now())
.build();
// when
Assertions.assertThatThrownBy(() -> {
// ser
String serialized = mapper.writeValueAsString(dateType);
// des - exception
mapper.readValue(serialized, VarietyDateType.class);
}).isInstanceOf(InvalidDefinitionException.class)
// then
.hasMessageContaining("no Creators, like default construct, exist");
}
@Value
@Builder
static class VarietyDateType {
private LocalDateTime localDateTime;
private LocalDate localDate;
private LocalTime localTime;
private ZonedDateTime zonedDateTime;
private Instant instant;
private Duration duration;
} and the warning comes to console.
|
@agongi Right, since you did not register Java 8 date time module, and as such all types from within are handled as Beans. I think I will actually file a separate issue for trying to see if I could improve exception message for such cases (essentially looking at ser/deser of types |
I am getting this message when I am serializing/dserializing a LocalDate object, using a set of custom serializer and deserializer classes. But, interesting enough, when I added "@JsonIgnore" to three setter methods, that happen to use a different DateTimeFormatter instance, the error messages went away.
|
@arick I suspect that registering (de)serializer(s) using module (like |
Not sure what could be done here: Jackson 2.12 at least checks for missing module (see #2683 ). |
I could provoke this error by trying to serialize an ISO compliant Datetime String into a Java object of type DateTimeFormatter. I promise I won't do it again, but maybe you're still interested in both the full error message and how I got it to pop up.
error message:
How I got there:
First, I've set up a REST Controller using Spring Boot v2.1.6.RELEASE like this:
Up above, DateTime is a custom data class for holding a single DateTimeFormatter like so:
Now I just have to send a POST request to the /receiveDateTime mapping as I did with those two lines of Python code:
The response is a 400 error code by the way, looking like that:
The text was updated successfully, but these errors were encountered: