Results 1 to 2 of 2

Thread: Change my webapp with OpenEntityManagerInViewFilter?

  1. #1
    Join Date
    Nov 2011
    Posts
    2

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    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).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •