If I uncomment the first line in a method, the code works. I found this simply by trial and error.Code:@Service @Transactional public class InitialIndexPerformer { @PersistenceContext transient EntityManager entityManager; @PostConstruct public void performInitialIndex() throws InterruptedException { // entityManager=entityManager.getEntityManagerFactory().createEntityManager(); Session session = (Session) entityManager.unwrap(Session.class); FullTextSession fullTextSession = Search.getFullTextSession(session); fullTextSession.createIndexer().startAndWait(); } }
In this version, it gives me a nasty
Exception.Code:java.lang.IllegalStateException: No transactional EntityManager available at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:223) at $Proxy40.unwrap(Unknown Source)
Can anybody explain why? I have @Transaction specified and all... I simply do not know what I am doing wrong and why the trick with
worked.Code:entityManager=entityManager.getEntityManagerFactory().createEntityManager();
Thank you


