2012-05-03 3 views
2

maven에서 두 개의 모듈 (하나는 지속성, 다른 하나는 webapp 자체 (gwt))으로 관리되는 앱이 있습니다.Guice-Persist : 닫힌 EntityManager에서 작업을 실행하려고 시도했습니다.

내 영속 모듈의 테스트는 매력처럼 작동하지만 webapp에서는 동일한 메소드를 여러 번 실행하면 java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManager.이 발생합니다.

저는 guice-persist를 사용하여 DAO에 엔티티 관리자를 삽입하고 모든 DAO 메소드에는 @Transactional 주석이 있습니다. 공용 클래스 ScuvServletModule 나는 PersistFilter을 제거하면 ServletModule {

@Override 
    protected void configureServlets() { 
     super.configureServlets(); 
     install(MyPersistenceAPI.getModule()); // return my module and install it 
     filter("/*").through(PersistFilter.class); 
     /// another bindings... 
    } 
} 

을 확장, 그것은 wotks하지만 무작위로 그런 거래 청산 예외 또는 뭔가를 던져 : 내 웹 애플리케이션에서

, 내가 넣어.

어떤 도움이 필요합니까?

답변

3

문제점을 발견했습니다. PersistFilter입니다. Aparently, 그것의 싱글 톤, 내 DAOs도 싱글 톤이지만 EntityManager isnt.

그래서 Provider<EntityManager> 대신 EntityManager을 삽입하고 매력처럼 작동합니다.

관련 문제