odrotbohm/sos

Cannot construct instance of OrderCompleted

mszarlinski opened this issue · 1 comments

After running mvc clean install I get the following error. The solution is simply to put @JsonCreator annotation.

-------------------------------------------------------------------------------
Test set: example.sos.modulith.orders.EmailNotificationTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 1, Errors: 1, Skipped: 0, Time elapsed: 1.026 s <<< FAILURE! - in example.sos.modulith.orders.EmailNotificationTest
completingAnOrderUpdatesInventory(example.sos.modulith.orders.EmailNotificationTest)  Time elapsed: 0.147 s  <<< ERROR!
java.lang.RuntimeException: 
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `example.sos.modulith.orders.Order$OrderCompleted` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: (String)"{"order":{"id":13,"lineItems":[{"id":null,"product":{"id":1,"name":"iPad Pro","price":799.99},"amount":5}],"status":"SUBMITTED"}}"; line: 1, column: 2]
	at example.sos.modulith.orders.EmailNotificationTest.lambda$completingAnOrderUpdatesInventory$0(EmailNotificationTest.java:58)
	at example.sos.modulith.orders.EmailNotificationTest.completingAnOrderUpdatesInventory(EmailNotificationTest.java:58)
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: 
Cannot construct instance of `example.sos.modulith.orders.Order$OrderCompleted` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: (String)"{"order":{"id":13,"lineItems":[{"id":null,"product":{"id":1,"name":"iPad Pro","price":799.99},"amount":5}],"status":"SUBMITTED"}}"; line: 1, column: 2]
	at example.sos.modulith.orders.EmailNotificationTest.lambda$completingAnOrderUpdatesInventory$0(EmailNotificationTest.java:58)
	at example.sos.modulith.orders.EmailNotificationTest.completingAnOrderUpdatesInventory(EmailNotificationTest.java:58)

Thats fundamentally caused by this ticket in Jackson in combination with Lombok 1.16.20 not adding @ConstructorProperties by default anymore. Fix coming in a second.