You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Movie movie = new Movie();
movie.setName("The Godfather");
movie.setGross(BigDecimal.valueOf(246120974));
movie.setGenre("Drama");
OsonFactory factory = new OsonFactory();
ObjectMapper mapper = new ObjectMapper(factory);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
mapper.writeValue(baos, movie);
baos.close();
// The Movie represented as OSON binary JSON
byte[] oson = baos.toByteArray();
Movie movie2 = mapper.readValue(oson, Movie.class);
System.out.println("Title: " + movie2.getName());
System.out.println("Genre: " + movie2.getGenre());
Since the images field of movie is null, it causes this exception:
Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: error: expecting end array (through reference chain: movie.model.Movie["images"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:402)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:361)
at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:323)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:778)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:184)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:502)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:341)
at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4811)
at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:4011)
at movie.JacksonDataBindMapper.main(JacksonDataBindMapper.java:39)
Suppressed: oracle.sql.json.OracleJsonGenerationException: ORA-26311: Generator closed before before end.
https://docs.oracle.com/error-help/db/ora-26311/
at oracle.jdbc.driver.json.OracleJsonExceptions$OracleExceptionFactory.createGenerationException(OracleJsonExceptions.java:153)
at oracle.jdbc.driver.json.OracleJsonExceptions$3.create(OracleJsonExceptions.java:225)
at oracle.jdbc.driver.json.binary.StreamContext.close(StreamContext.java:124)
at oracle.jdbc.driver.json.binary.OsonGeneratorImpl$OsonGeneratorState.close(OsonGeneratorImpl.java:1477)
at oracle.jdbc.driver.json.binary.OsonGeneratorImpl.close(OsonGeneratorImpl.java:2007)
at oracle.jdbc.provider.oson.OsonGenerator.close(OsonGenerator.java:551)
at com.fasterxml.jackson.databind.util.ClassUtil.closeOnFailAndThrowAsIOE(ClassUtil.java:495)
at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4813)
... 2 more
Caused by: com.fasterxml.jackson.core.JsonGenerationException: error: expecting end array
at com.fasterxml.jackson.core.JsonGenerator._constructWriteException(JsonGenerator.java:2901)
at com.fasterxml.jackson.core.JsonGenerator._reportError(JsonGenerator.java:2885)
at oracle.jdbc.provider.oson.OsonGenerator.writeEndArray(OsonGenerator.java:179)
at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:80)
at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:732)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
... 6 more
The text was updated successfully, but these errors were encountered:
Here is the reproducer:
The Movie class can be found here:
https://github.com/oracle/json-in-db/blob/master/JdbcExamples/src/main/java/movie/model/Movie.java
Since the images field of movie is null, it causes this exception:
The text was updated successfully, but these errors were encountered: