paulcwarren/spring-content

Spring-Content-JPA 2.9.0 nullpointer exception trying to setContent

tom-vandepoele-1 opened this issue · 3 comments

Describe the bug
java.lang.NullPointerException: Cannot invoke "java.sql.ResultSet.close()" because "this.rs" is null

when trying to follow along the reference documentation for Spring Content JPA (trying to store any file in the H2 database)

To Reproduce
Steps to reproduce the behavior:

  1. clone from https://github.com/tom-vandepoele-1/Spring-Content-JPA-demo
  2. run DemoApplication class

Caused by: java.lang.NullPointerException: Cannot invoke "java.sql.ResultSet.close()" because "this.rs" is null
at internal.org.springframework.content.jpa.io.BlobResourceOutputStream.close(BlobResourceOutputStream.java:104) ~[spring-content-jpa-2.8.0.jar:na]
at java.base/java.io.FilterOutputStream.close(FilterOutputStream.java:188) ~[na:na]
at org.apache.commons.io.IOUtils.closeQuietly(IOUtils.java:534) ~[commons-io-2.11.0.jar:2.11.0]
at org.apache.commons.io.IOUtils.closeQuietly(IOUtils.java:466) ~[commons-io-2.11.0.jar:2.11.0]
at org.apache.commons.io.IOUtils.closeQuietly(IOUtils.java:603) ~[commons-io-2.11.0.jar:2.11.0]
at internal.org.springframework.content.jpa.repository.DefaultJpaStoreImpl.setContent(DefaultJpaStoreImpl.java:265) ~[spring-content-jpa-2.8.0.jar:na]

Expected behavior
File is stored in the H2 database without errors.

Additional context
Spring Content JPA 2.9.0
Spring Boot 2.7.11

Thanks for the sample @tom-vandepoele-1 . will look into this soonest.

When using spring-content-jpa directly (and not the spring boot starter) you need to initialize the datasource as per git@github.com:paulcwarren/Spring-Content-JPA-demo.git.

I am updating the spring content jpa docs to clarify.

Docs updated here