cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaybytez <jayby...@yahoo.com>
Subject Re: CXF/JAXB and Hibernate LazyInitializationException
Date Wed, 29 Aug 2012 16:13:03 GMT
I have read several articles and none seemed to work for my case, they all
still produced the LazyInitializationException (either with the Filter or
the Interceptor).

I have this configuration within the web.xml:


<web-app>
	<display-name>FooBusinessService Endpoint</display-name>

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/FooBusinessServiceWar-context.xml
			classpath*:FooBusinessServiceClientInt-context.xml
		</param-value>
	</context-param>
	<context-param>
        <param-name>contextClass</param-name>
       
<param-value>com.foo.turnoff.validation.ServiceXmlWebApplicationContext</param-value>
    </context-param>
	
    <filter>
        <filter-name>OpenEntityManagerInViewFilter</filter-name>
        <filter-class>
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
        <init-param>
            <param-name>entityManagerFactoryBeanName</param-name>
            <param-value>fsbEntityManagerFactory</param-value>
        </init-param>
        
    </filter>
    
    <filter-mapping>
        <filter-name>OpenEntityManagerInViewFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>

	<servlet>
		<servlet-name>CXFServlet</servlet-name>
		<servlet-class>
			org.apache.cxf.transport.servlet.CXFServlet
		</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>CXFServlet</servlet-name>
		<url-pattern>/*</url-pattern>
	</servlet-mapping>
</web-app>


I am not sure if the definition of the hibernate properties has anything to
do with it:

I flipped hibernate.current_session_context_class between thread and jta.

		<property name="jpaPropertyMap">
      		<map>
                      ......
                      <entry key="hibernate.current_session_context_class"
value="thread"/>
                      <entry key="hibernate.autocommit" value="false" /> 
	              ......
      		</map>
    	</property>


Not sure if the AOP Pointcut/Transasctions are the issue, most people's
examples are using the @Transactional.

The Filter is part of the stracktrace


org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter -
Initializing filter 'OpenEntityManagerInViewFilter'
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter - Filter
'OpenEntityManagerInViewFilter' configured successfully
org.springframework.beans.factory.support.DefaultListableBeanFactory -
Returning cached instance of singleton bean 'cxf'
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter - Using
EntityManagerFactory 'fsbEntityManagerFactory' for
OpenEntityManagerInViewFilter
org.springframework.beans.factory.support.DefaultListableBeanFactory -
Returning cached instance of singleton bean 'fsbEntityManagerFactory'
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter - Opening
JPA EntityManager in OpenEntityManagerInViewFilter
org.hibernate.impl.SessionImpl - opened session at timestamp: 13461104198
org.hibernate.ejb.AbstractEntityManagerImpl - Looking for a JTA transaction
to join
org.hibernate.ejb.AbstractEntityManagerImpl - No JTA transaction found
.......................................
org.springframework.transaction.jta.WebLogicJtaTransactionManager -
Initiating transaction rollback
org.apache.cxf.phase.PhaseInterceptorChain - Application
{http://foo.com}MemberSnapshotBusines
sServiceEndpointService#{http://foo.com}getBeneficiary has thrown exception,
unwinding now
org.apache.cxf.interceptor.Fault: failed to lazily initialize a collection
of role: com.foo.PersonUid.identifiers, no session or session was closed
        at
org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:155)
~[cxf-full.jar:2.4.5]
        at
org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:86)
~[cxf-full.jar:2.4.5]
        at
org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:121)
~[cxf-full.jar:2.4.5]
		........
        at
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
[spring-full.jar:3.0.5]
        at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
[spring-full.jar:3.0.5]
        at
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
[weblogic.jar:10.3.5.0]
........................................
com.foo.frmwk.exception.CustomSoapFaultOutInterceptor - SOAP Fault that was
thrown is org.hibernate.LazyInitializationException
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter - Closing
JPA EntityManager in OpenEntityManagerInViewFilter
org.springframework.orm.jpa.EntityManagerFactoryUtils - Closing JPA
EntityManager


I will try the custom interceptor approach with the Phase you
provided...thanks.



--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-JAXB-and-Hibernate-LazyInitializationException-tp5713130p5713327.html
Sent from the cxf-user mailing list archive at Nabble.com.

Mime
View raw message