I ran into the same exact issue when doing the following
final Runnable callback = // Some method which provides a callback that sends a mail
final CompletableFuture<Void> notifyUsersFuture = CompletableFuture.runAsync(callback).exceptionally(throwable -> {
LOGGER.error(throwable.getMessage());
return null;
});
Issue occurs due to the way the thread is created.
The application context might not be loaded in the threads created by parallel stream.
In order for the application context to be loaded correctly, I used the spring @Async annotation instead to run the process asynchronously and the issue is resolved.
For your case you can simply do
reports.stream().forEach(it -> {
creationProcess.startCreationProcess(it);
})
@Async
void startCreationProcess(final Report report) {
// Your logic
}