-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: org.hibernate.LazyInitializationException with h3b4
PostPosted: Mon Feb 14, 2005 2:40 pm 
Beginner
Beginner

Joined: Thu Jan 27, 2005 6:31 pm
Posts: 21
Location: This Life - Planet Earth
All;

The error is the "org.hibernate.LazyInitializationException " exception that we encounter, inspite of setting the "bankActlEstStatTypeCde" to "lazy=false". This application has been migrated from hibernate2 to 3.
I tried various combination but still the same error.
Please help. thank you in advance.
-Jenn
Package names have been changed to protet the innocent.

Hibernate version: h3b4

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="acmeinc.estimate">
<class name="BankActlEstStatHist" table="TBANK_ACTL_EST_STAT_HIST" >
<id
column="BANK_ACTL_EST_STAT_HIST_ID"
name="id"
type="integer"
>
<generator class="sequence">
<param name="sequence">
SEQ_BANK_ACTL_EST_STAT_HIST_ID
</param>
</generator>
</id>
<property
column="FISCAL_YR"
length="4"
name="fiscalYr"
not-null="true"
type="integer"
/>
<property
column="BANK_ACTL_EST_STAT_ADD_DT"
length="7"
name="bankActlEstStatAddDt"
not-null="false"
type="timestamp"
/>
<property
column="BANK_ACTL_EST_STAT_CMNT"
length="300"
name="bankActlEstStatCmnt"
not-null="false"
type="string"
/>
<property
column="BANK_ACTL_EST_STAT_ADD_ID"
length="20"
name="bankActlEstStatAddId"
not-null="false"
type="string"
/>

<many-to-one
class="Quarter"
name="qtrNbr"
not-null="true"
lazy="false"
>
<column name="QTR_NBR" />
</many-to-one>
<many-to-one
class="acmeinc.estimate.BankActlEstStatType"
name="bankActlEstStatTypeCde"
not-null="true"
lazy="false"
>
<column name="BANK_ACTL_EST_STAT_TYPE_CDE" />
</many-to-one>
<many-to-one
class="acmeinc.bank.Bank"
name="bank"
not-null="true"
lazy="false"
>
<column name="BANK_ID" />
</many-to-one>
<set
inverse="true"
lazy="true"
name="tbankActlEstSet"
>
<key column="BANK_ACTL_EST_STAT_HIST_ID" />
<one-to-many class="BankActlEst" />
</set>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
The class is accessed through struts and struts calls the properties directly.
Full stack trace of any exception that occurs:
2005-02-14 12:46:39,406 [Servlet.Engine.Transports : 1] ERROR org.hibernate.LazyInitializationException - could not initialize proxy - the owning Session was closed
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:53)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:133)
at acmeinc.estimate.BankActlEstStatType$$EnhancerByCGLIB$$aa8325ea.getBankActlEstStatTypeDesc(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(PropertyUtils.java:1185)
at org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.java:772)
at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:801)
at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:1008)
at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:227)
at org.apache.jsp._pgBankView._jspService(_pgBankView.java:2380)
at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:344)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:683)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:781)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:1014)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:592)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:204)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.ServicingServletState.service(StrictLifecycleServlet.java:333)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:1014)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:592)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:204)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:76)
at kpmg.taxshared.beans.navigation.SessionFilter.doFilter(SessionFilter.java:124)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:132)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:71)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:1010)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:592)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:204)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:125)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:286)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:615)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:449)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:912)
Name and version of the database you are using:
oracle9i
The generated SQL (show_sql=true):
select bankactles0_.BANK_ACTL_EST_STAT_HIST_ID as BANK1_, bankactles0_.FISCAL_YR as FISCAL2_13_, bankactles0_.BANK_ACTL_EST_STAT_ADD_DT as BANK3_13_, bankactles0_.BANK_ACTL_EST_STAT_CMNT as BANK4_13_, bankactles0_.BANK_ACTL_EST_STAT_ADD_ID as BANK5_13_, bankactles0_.QTR_NBR as QTR6_13_, bankactles0_.BANK_ACTL_EST_STAT_TYPE_CDE as BANK7_13_, bankactles0_.BANK_ID as BANK8_13_ from TBANK_ACTL_EST_STAT_HIST bankactles0_ where (bankactles0_.BANK_ID=? ) order by bankactles0_.BANK_ACTL_EST_STAT_ADD_DT
Debug level Hibernate log excerpt:
dont have this.


Top
 Profile  
 
 Post subject: continue error
PostPosted: Mon Feb 14, 2005 2:45 pm 
Beginner
Beginner

Joined: Thu Jan 27, 2005 6:31 pm
Posts: 21
Location: This Life - Planet Earth
Code between session create and close.
I forgot to post this ....


Session sess = createSession();
estHist =(ArrayList) sess.createQuery(
"FROM BankActlEstStatHist as bankActlEstStatHist WHERE bankActlEstStatHist.bank.id = ? order by bankActlEstStatHist.bankActlEstStatAddDt")
.setParameter(0, bankId, Hibernate.INTEGER).list();
sess.close();


-Jenn


Top
 Profile  
 
 Post subject: hmm ok i am really confused now..
PostPosted: Mon Feb 14, 2005 4:44 pm 
Beginner
Beginner

Joined: Thu Jan 27, 2005 6:31 pm
Posts: 21
Location: This Life - Planet Earth
sorry for the cross post... but I think I need to open a new topic t discuss what I am confusion about ....

I was able to fix a smiliar problem in another relation within my project (a more trivial code) by actually settign the class atribute
"lazy=false" .

ie setting the "acmeinc.estimate.BankActlEstStatType" mapping with lazy=false.

now this fixes the problem but raises a new one. why do i have to decalre theis class as lazy="false" and shy it declaring its reference in the above mapping as "lazy=false" fix this.

Why do we have the lazy attibute in 2 places..

also read my other post with the same issue...
http://forum.hibernate.org/viewtopic.php?t=938806

-Jennifer


Top
 Profile  
 
 Post subject: Have simillar problem:org.hibernate.LazyInitializationExcept
PostPosted: Wed Aug 17, 2005 10:19 am 
Newbie

Joined: Wed Aug 17, 2005 9:59 am
Posts: 1
getting the following exception:
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
i have a many-to-many mapping table
have tried out lazy="false" which gives this exception.
lazy="true" also doesnt works

m working on hibernate3..plz help

HSQL is
[junit] Hibernate: select loan0_.LOAN_ID as LOAN1_, loan0_.PROD_LINE_CD as PROD2_0_, loan0_.LOAN_NUM as LOAN3_0_, loan0_.PYMT_FRQNCY_TYP_CD as PYMT4_0_, loan0_.INTRST_CALC_MTHD_TYP_CD as INTRST5_0_, loan0_.LOAN_PRPS_CD as LOAN6_0_, loan0_.ACQSTN_TYP_CD as ACQSTN7_0_, loan0_.LOAN_TYP_CD as LOAN8_0_, loan0_.LOAN_STAT_CD as LOAN9_0_, loan0_.LOAN_ACQSTN_DT as LOAN10_0_, loan0_.ORIG_LOAN_BAL_AMT as ORIG11_0_, loan0_.ORIG_INTRST_RT_PCT as ORIG12_0_, loan0_.LOAN_TERM_NUM as LOAN13_0_, loan0_.AMORTZTN_SCHED_NUM as AMORTZTN14_0_, loan0_.SCHED_FRST_PYMT_DT as SCHED15_0_, loan0_.MATRTY_DT as MATRTY16_0_, loan0_.STAT_DT as STAT17_0_, loan0_.BYDWN_ORGNL_BAL_AMT as BYDWN18_0_, loan0_.ASSUM_IND as ASSUM19_0_, loan0_.ASSMPTN_DT as ASSMPTN20_0_, loan0_.MI_IND as MI21_0_, loan0_.BALLN_IND as BALLN22_0_, loan0_.BYDWN_IND as BYDWN23_0_, loan0_.CNCRRNT_LOAN_IND as CNCRRNT24_0_, loan0_.LOAN_FOCLSRE_IND as LOAN25_0_, loan0_.CONVRSN_IND as CONVRSN26_0_, loan0_.FHLMC_IND as FHLMC27_0_, loan0_.LATE_CHRG_IND
as LATE28_0_, loan0_.PREPMT_PNLTY_IND as PREPMT29_0_, loan0_.BRNCH_OFFC_ID as BRNCH30_0_, loan0_.PYMT_IN_FULL_DT as PYMT31_0_, loan0_.ORGNL_PI_AMT as ORGNL32_0_, loan0_.VERSION as VERSION0_, loan0_.CREATE_DT as CREATE34_0_, loan0_.CREATE_USER_ID as CREATE35_0_, loan0_.LAST_UPDATE_DT as LAST36_0_, loan0_.LAST_UPDATE_USER_ID as LAST37_0_ from LOAN loan0_ where (loan0_.LOAN_ID=? )
[junit] Hibernate: select loancustom0_.LOAN_ID as LOAN1_0_, loancustom0_.FOCLSRE_STOP_CD as FOCLSRE2_3_0_, loancustom0_.BNKRUPCY_CD as BNKRUPCY3_3_0_, loancustom0_.CSHIER_STOP_CD as CSHIER4_3_0_, loancustom0_.PROCSS_STOP_CD as PROCSS5_3_0_, loancustom0_.BAD_CHCK_STOP_IND as BAD6_3_0_, loancustom0_.BNKRUPCY_CHPTR_TYP_CD as BNKRUPCY7_3_0_, loancustom0_.PYMT_IN_FULL_STOP_CD as PYMT8_3_0_ from LOAN_CUSTOMER_CARE loancustom0_ where loancustom0_.LOAN_ID=?
[junit] Hibernate: select currentloa0_.LOAN_ID as LOAN1_0_, currentloa0_.NXT_PYMT_DUE_DT as NXT2_31_0_, currentloa0_.CRNT_PRCPL_BAL_AMT as CRNT3_31_0_ from CURRENT_LOAN_PAYMENT currentloa0_ where currentloa0_.LOAN_ID=?
[junit] Hibernate: select loanglb0_.LOAN_ID as LOAN1_0_, loanglb0_.GLB_NUM as GLB2_29_0_ from LOAN_GLB loanglb0_ where loanglb0_.LOAN_ID=?
[junit] Hibernate: select addresses0_.LOAN_ID as LOAN1_1_, addresses0_.PRPTY_ADDR_ID as PRPTY2_1_, address1_.ADDR_ID as ADDR1_0_, address1_.ADDR_LINE_1_TXT as ADDR2_4_0_, address1_.ADDR_LINE_2_TXT as ADDR3_4_0_, address1_.ADDR_LINE_3_TXT as ADDR4_4_0_, address1_.ADDR_CARR_RTE_CD as ADDR5_4_0_, address1_.POSTL_EXTNSN_CD as POSTL6_4_0_, address1_.POSTL_CD as POSTL7_4_0_, address1_.TRRTRY_CD as TRRTRY8_4_0_, address1_.CTY_CD as CTY9_4_0_, address1_.CITY_NAME as CITY10_4_0_, address1_.CNTY_CD as CNTY11_4_0_, address1_.ADDR_TYP_CD as ADDR12_4_0_, address1_.CNSUS_TRCT_ID as CNSUS13_4_0_, address1_.TX_JRSDCTN_ID as TX14_4_0_, address1_.FRGN_ADDR_IND as FRGN15_4_0_, address1_.VERSION as VERSION4_0_, address1_.CREATE_DT as CREATE17_4_0_, address1_.CREATE_USER_ID as CREATE18_4_0_, address1_.LAST_UPDATE_DT as LAST19_4_0_, address1_.LAST_UPDATE_USER_ID as LAST20_4_0_ from LOAN_PROPERTY addresses0_, ADDRESS address1_ where addresses0_.PRPTY_ADDR_ID=address1_.ADDR_ID and addresses0_.LOAN_ID=?
exception stacktrace
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:53)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:84)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
at com.amc.msr.tp3Engine.model.Territory$$EnhancerByCGLIB$$dc217e59.toString(<generated>)
at java.lang.String.valueOf(String.java:2177)
at java.lang.StringBuffer.append(StringBuffer.java:371)
at com.amc.msr.tp3Engine.dao.LoanDAOTestCase.testGetLoan(LoanDAOTestCase.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:325)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:536)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.