Greetings, I've been experimenting with creating a transactional web service using CXF, Spring and JPA/Hibernate. The basic examples I've seen of such services look like this: @Transactional @WebService(...) public class MyService implements MyServiceInterface { @PersistenceContext private EntityManager em; public void myOperation() throws DataAccessException { ... // use injected entity manager em.find(...) ... } } and the Spring config has this: <tx:annotation-driven transaction-manager="transactionManager" /> ... <jaxws:server id="myService" serviceClass="MyServiceInterface" address="/Service"> <jaxws:serviceBean> <bean id="myServiceBean" class="MyService" autowire="autodetect" /> </jaxws:serviceBean> </jaxws:server> Here's what I would expect to happen with a transactional web service based on JPA: - Request begins - System begins new unit of database work by creating a new EntityManager - All database interactions in the request use the same EntityManager - Request finishes processing - Transaction commits or rolls back (if an error occurred) - Response sent As far as I can tell, Spring is only creating one instance of my service bean, and injecting a single EntityManager into it when it does so. This clearly won't work when handling multiple concurrent requests, since EntityManager is not thread-safe and a new one needs to be instantiated for each unit of work. Is the above setup actually right? Can anyone point me to an example of how to wire this all together correctly? I'm about to give up on using Spring transactional support and go back to just implementing my own simple transactional wrapper and making the EntityManager available to DAOs through a ThreadLocal. Thanks, Karl
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com