title: Problem with entity manager in Spring Webflux
body: <p>In my web client, where I started using Spring WebFlux, I got following exception:</p>
  <pre><code>reactor.core.Exceptions$ErrorCallbackNotImplemented: javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call
  Caused by: javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call
  </code></pre>
  <p>Code:</p>
  <pre><code>@Service
  @Transactional
  @Slf4j
  public class PersonSyncServiceImpl
          extends HotelApiCommunicationService implements PersonSyncService {
  
      private static final String REST_ENDPOINT_PATH = &quot;/api/sync/person&quot;;
  
      @PersistenceContext
      private EntityManager em;
      @Autowired
      private SynchronizationService syncMgr;
  
  
      @Override
      public int initialSyncPersonData(ObiektDTO obiekt) {
  
          WebClient client = WebClient.create(&quot;http://&quot; + obiekt.getAdresIp());
          AtomicInteger count = new AtomicInteger(0);
  
          Flux&lt;Person&gt; personFlux = client.get()
                  .uri(REST_ENDPOINT_PATH)
                  .retrieve()
                  .bodyToFlux(Person.class);
  
          personFlux.subscribe(person -&gt; {
              CNPerson cnPerson = syncMgr.convertObject(person, CNPerson.class);
              cnPerson.setObiektLoid(obiekt.getLoid());
              em.persist(cnPerson);
              count.getAndIncrement();
          });
  
          return count.get();
      }
  }
  </code></pre>
  <p>I know that the problem is on this line, because reactor can't get entity manager.</p>
  <pre><code>em.persist(cnPerson);
  </code></pre>
  <p>Controller method on server:</p>
  <pre><code>    @GetMapping(value = &quot;/person&quot;, produces = MediaType.APPLICATION_STREAM_JSON_VALUE)
      public Flux&lt;Person&gt; getPersonList() {
  
          return Flux.fromStream(
                  personDao.findAll().stream());
      }
  </code></pre>
  <p>How to fix it? How to access transaction with reactor and using JPA save a record to database?</p>