Page 2 of 2 FirstFirst 12
Results 11 to 11 of 11

Thread: LazyInitializationException with OpenEntityManagerInViewFilter

  1. #11

    Default

    Resolved !


    Migrated to the WebLogic 11, and changed the EclipseLink persistence provider to prove that support for 2.1 Lazy and transactions outside the EJB container.
    Minimum configuration, good.
    following configuration:

    web.xml
    Code:
    <filter>
    		<filter-name>openEntityManagerInViewFilter</filter-name>
    		<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
    	</filter>
    	<filter-mapping>
    		<filter-name>openEntityManagerInViewFilter</filter-name>
    		<url-pattern>*.do</url-pattern>
    	</filter-mapping>
    	
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>classpath:org/springmvc/resources/spring-context.xml</param-value>
    	</context-param>
    
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    
    	<servlet>
    		<servlet-name>springmvcdispatcherservlet</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<init-param>
    			<param-name>contextConfigLocation</param-name>
    			<param-value>classpath:org/springmvc/resources/spring-mvc.xml</param-value>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	
    	<servlet-mapping>
    		<servlet-name>springmvcdispatcherservlet</servlet-name>
    		<url-pattern>*.do</url-pattern>
    	</servlet-mapping>
    persistence.xml
    Code:
    <persistence-unit name="EJBPROJECT">
    		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    		<jta-data-source>jdbc/mySQL</jta-data-source>
    		<class>org.ejbproject.entitys.Entidade</class>
    		<class>org.ejbproject.entitys.Estado</class>
    		<class>org.ejbproject.entitys.Cidade</class>
    		<exclude-unlisted-classes>true</exclude-unlisted-classes>
    		<properties>			
    			<property name="show_sql" value="true" />
    		</properties>
    	</persistence-unit>
    spring-context.xml
    Code:
    <context:load-time-weaver
    		weaver-class="org.springframework.instrument.classloading.weblogic.WebLogicLoadTimeWeaver" />
    
    	<bean id="transactionManager"
    		class="org.springframework.transaction.jta.JtaTransactionManager" />
    
    	<bean id="entityManagerFactory"
    		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    		<property name="persistenceUnitName" value="EJBPROJECT" />
    		<property name="jpaVendorAdapter">
    			<bean id="jpaAdapter"
    				class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
    				<property name="databasePlatform"
    					value="org.eclipse.persistence.platform.database.MySQLPlatform" />
    				<property name="showSql" value="true" />
    			</bean>
    		</property>
    	</bean>
    spring-mvc.xml
    Code:
     <tx:annotation-driven />
    
    	<tx:jta-transaction-manager />
    
    	<context:component-scan base-package="org.springmvc.spring" />
    
    	<context:annotation-config />
    
    	<mvc:annotation-driven />
    
    	<mvc:default-servlet-handler />
    The Lazy collections open in view, and any change in the Spring @Service layer bean annotated with @Transaction instantly reflected in the database.

    The web module there is nothing persistence, everything is in EJB.

    JBoss 5 or 6 is J2SE server, not a JEE server.

    Tanks.
    Last edited by danielfarkas; Feb 15th, 2011 at 02:22 AM.

Posting Permissions

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