[3.7.0 Railo] org.hibernate.LazyInitializationException

Hi guys, yesterday had this error in my home page of a site, using “fwreinit” it go away… but today the same error within an “admin section using solitary module” appear again,
I use fwreinit but the error did not go away… maybe because of solitary?

Any way, does any one have come across this type of error on Railo?

Thanks!

Railo 4.1.2.004 Error (org.hibernate.LazyInitializationException)
Message failed to lazily initialize a collection of role: User.roles, no session or session was closed
Cause org.hibernate.LazyInitializationException
Stacktrace The Error Occurred in
/opt/railo/lib/railo-server/context/library/tag/Dump.cfc: line 94

92: }
93: catch(e) {
94: var meta = dumpStruct(structKeyExists(attrib,‘var’) ? attrib.var : nullValue(), attrib.top, attrib.show, attrib.hide, attrib.keys, attrib.metaInfo, attrib.showUDFs);
95: }
96:

called from /home/rebate/public_html/coldbox/system/includes/BugReport.cfm: line 223

221:
222: #key#:
223: <cfif isSimpleValue( sessioncbstorage[ key ] )>#htmlEditFormat( sessioncbstorage[ key ] )##key#
224:
225:

called from /home/rebate/public_html/coldbox/system/web/services/ExceptionService.cfc: line 114

112:
113: <!— Save the Bug Report —>
114:
115:
116:

called from /home/rebate/public_html/coldbox/system/Coldbox.cfc: line 353

351:
352: <!— Render The Exception —>
353: #exceptionService.renderBugReport(ExceptionBean)#
354:
355:

called from /home/rebate/public_html/Application.cfc: line 121

119: <cfif findNoCase(‘index.cfm’, listLast(arguments.targetPage, ‘/’))>
120: <!— Reload Checks —>
121: <cfset application.cbBootStrap.processColdBoxRequest()>
122:
123:

Java Stacktrace failed to lazily initialize a collection of role: User.roles, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:383):383
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:375):375
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:368):368
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:111):111
at org.hibernate.collection.PersistentBag.listIterator(PersistentBag.java:469):469
at railo.runtime.dump.DumpUtil.toDumpData(DumpUtil.java:244):244
at railo.runtime.type.util.StructUtil.toDumpTable(StructUtil.java:124):124
at railo.runtime.type.util.StructSupport.toDumpData(StructSupport.java:131):131
at railo.runtime.dump.DumpUtil.toDumpData(DumpUtil.java:224):224
at railo.runtime.functions.other.DumpStruct.call(DumpStruct.java:65):65
at railo.runtime.functions.other.DumpStruct.call(DumpStruct.java:54):54
at dump_cfc$cf.udfCall1(/opt/railo/lib/railo-server/context/library/tag/Dump.cfc:94):94
at dump_cfc$cf.udfCall(/opt/railo/lib/railo-server/context/library/tag/Dump.cfc):-1
at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:95):95
at railo.runtime.type.UDFImpl._call(UDFImpl.java:308):308
at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:199):199
at railo.runtime.ComponentImpl._call(ComponentImpl.java:624):624
at railo.runtime.ComponentImpl._call(ComponentImpl.java:506):506
at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1749):1749
at railo.runtime.tag.CFTag.cfcStartTag(CFTag.java:371):371
at railo.runtime.tag.CFTag.doStartTag(CFTag.java:158):158
at system.includes.bugreport_cfm$cf.call(/home/rebate/public_html/coldbox/system/includes/BugReport.cfm:223):223
at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:837):837
at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:784):784
at system.web.services.exceptionservice_cfc$cf.udfCall(/home/rebate/public_html/coldbox/system/web/services/ExceptionService.cfc:114):114
at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:95):95
at railo.runtime.type.UDFImpl._call(UDFImpl.java:308):308
at railo.runtime.type.UDFImpl.call(UDFImpl.java:212):212
at railo.runtime.ComponentImpl._call(ComponentImpl.java:623):623
at railo.runtime.ComponentImpl._call(ComponentImpl.java:506):506
at railo.runtime.ComponentImpl.call(ComponentImpl.java:1732):1732
at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:713):713
at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1506):1506
at coldbox.system.coldbox_cfc$cf.udfCall1(/home/rebate/public_html/coldbox/system/Coldbox.cfc:353):353
at coldbox.system.coldbox_cfc$cf.udfCall(/home/rebate/public_html/coldbox/system/Coldbox.cfc):-1
at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:95):95
at railo.runtime.type.UDFImpl._call(UDFImpl.java:308):308
at railo.runtime.type.UDFImpl.call(UDFImpl.java:212):212
at railo.runtime.ComponentImpl._call(ComponentImpl.java:623):623
at railo.runtime.ComponentImpl._call(ComponentImpl.java:506):506
at railo.runtime.ComponentImpl.call(ComponentImpl.java:1732):1732
at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:713):713
at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1506):1506
at application_cfc$cf.udfCall(/home/rebate/public_html/Application.cfc:121):121
at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:95):95
at railo.runtime.type.UDFImpl._call(UDFImpl.java:308):308
at railo.runtime.type.UDFImpl.call(UDFImpl.java:212):212
at railo.runtime.ComponentImpl._call(ComponentImpl.java:623):623
at railo.runtime.ComponentImpl._call(ComponentImpl.java:506):506
at railo.runtime.ComponentImpl.call(ComponentImpl.java:1732):1732
at railo.runtime.listener.ModernAppListener.call(ModernAppListener.java:387):387
at railo.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:113):113
at railo.runtime.listener.ModernAppListener.onRequest(ModernAppListener.java:83):83
at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2170):2170
at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2137):2137
at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:332):332
at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:29):29
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722):722
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304):304
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224):224
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169):169
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472):472
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168):168
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100):100
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118):118
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405):405
at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200):200
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515):515
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302):302
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source):-1
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source):-1
at java.lang.Thread.run(Unknown Source):-1

Timestamp 12/6/13 10:25:53 AM CST

Are you storing the object in session or some volatile scope?

Hi Luis,

The Admin credentials are being stored in “session” that is correct. This error is practically new to me, I did a Railo upgrade to 4.1.2.004, but I did that about a week ago, could this be related?

Thanks

You can’t store ORM objects in session, they will become “detached”. Just store the ID and get the object on the request.

Curt

Like Curt said. When you store an ORM object in a volatile scope, you can, but there are intricacies.

One, if you have lazy or proxied relationships, they must all be loaded in order to work correctly.
Two, you can re-attach the object back into the session using entity merge or the merge() method in the orm services
Three, you can store simple id’s in the volatile scopes and then just request the object from ORM on a per request basis (I would combine that with ORM secondary cache)

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Ok, in that case I got that wrong… Im not storing ORM Objects into nothing, what I’m storing in session as you mention are the “Admin Credentials: id,roles,etc” but the ORM object I left them alone.

All the securty ORM objects are handle by solitary itself…

Thanks

Digging to find why I was getting this strange (for me) error:

Error (org.hibernate.LazyInitializationException)
Message failed to lazily initialize a collection of role: User.roles, no session or session was closed
Cause org.hibernate.LazyInitializationException

When all was working “fine” and then that start to showing up.
I finally found my bug, but that brought to me another question, why a Hibernate error when by mistake I use this:

<cfset var plugininstance = getPlugin(plugin=“myplugin”,customPlugin=false) />

Instead of this:

<cfset var plugininstance = getPlugin(plugin=“myplugin”,customPlugin=true) />

By calling a custom plugin and using customPlugin as false, that was mi issue, I don’t find a relation since I do not use Hibernate in my own handlers.

Thanks

I can’t imagine how getting the wrong version of a plugin would have caused the error you were receiving. Are you saying you don’t use ORM at all? What was the plugin in question?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Hi Brad, a simple CFC with no database functions, but this CFC is inside a protected session using solitary module which as you might know it is ORM driven. I do not know using customPlugin as false when it should be true could trigger inside this “protected” session.

Thanks

You must have two plugins with the same name-- one in the coldbox.system.plugins folder, and one in your custom plugin location. When customPlugin is false, it will use the default system one. When customPlugin is true, it will use your custom one instead.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Thank you guys :slight_smile: for your time and support!