Announcement Announcement Module
Collapse
No announcement yet.
Change my webapp with OpenEntityManagerInViewFilter? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Change my webapp with OpenEntityManagerInViewFilter?

    Hi guys,

    I have a little already working JBoss webapp, and a Lazy initialisation problem.
    Therefore I was advised to investigate in Spring and use OpenEntityManagerInViewFilter.

    Nevertheless I still get the error, hope you could help me?

    I set it up like this:
    Code:
    	<filter>
    		<filter-name>
    			OpenEntityManagerInViewFilter
    		</filter-name>
    		<filter-class>
    			org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
    		</filter-class>
    		<init-param>
    			<param-name>singleSession</param-name>
    			<param-value>true</param-value>
    		</init-param>
    		<init-param>
    			<param-name>flushMode</param-name>
    			<param-value>AUTO</param-value>
    		</init-param>
    	</filter>
    	<!-- Include this if you are using Hibernate -->
    	<filter-mapping>
    		<filter-name>OpenEntityManagerInViewFilter</filter-name>
    		<url-pattern>/*</url-pattern>
    	</filter-mapping>
    	
    	<!-- Spring config -->
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    	<listener>
    		<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    	</listener>
    Now that my app runs fine again (so I assume spring was configured properly), I still have the Lazy problem:

    Code:
     [javax.enterprise.resource.webcontainer.jsf.context] (http--127.0.0.1-8080-1) org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: domain.personList, no session or session was closed

    What else do I have to change in my app to make use of the Spring OEM Filter?

    My setup is like this:

    @Entity Customer;
    @Stateless @TransactionAttribute(TransactionAttributeType.REQ UIRES_NEW) DaoService;
    @Named @RequestScoped CustomerFacade;
    +jsf stuff.

  • #2
    What you have explicitly configured are already the defaults so not sure why you added them.


    Please use [ code][/code ] tags when posting code also you are trying to use Spring Managed beans in a JSF environment that might be troublesome (I suggest a read of the reference guide especially the JSF section). Also make sure that you aren't opening sessions yourself and that spring is in control of the transactions (or at least knows about them).

    Comment

    Working...
    X