failed to lazily initialize a collection …, could not initialize proxy - no Session

New Here ,
Dec 02, 2014 Dec 02, 2014

Copy link to clipboard


I have an application that i am extending to provide a REST API.  Everything works fine in the main site, but I am getting the following in the exception log when I try to hit the REST API:

    "Error","ajp-bio-8014-exec-3","12/02/14","12:54:06","table","failed to lazily initialize a collection of role: field, could not initialize proxy - no Session The specific sequence of files included or processed is: service.cfc'' "

    org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: field, could not initialize proxy - no Session

        at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(

        at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(

        at org.hibernate.collection.internal.AbstractPersistentCollection.readSize(

        at org.hibernate.collection.internal.PersistentBag.size(

        at coldfusion.runtime.xml.ListIndexAccessor.getSize(

        at coldfusion.runtime.xml.ArrayHandler.serialize(

        at coldfusion.runtime.xml.CFComponentHandler.serialize(

        at coldfusion.runtime.XMLizerUtils.serializeXML(


        at com.sun.jersey.spi.container.ContainerResponse.write(

        at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(

        at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(

        at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(

        at com.sun.jersey.spi.container.servlet.WebComponent.service(

        at com.sun.jersey.spi.container.servlet.ServletContainer.service(






        at coldfusion.filter.ExceptionFilter.invoke(

        at coldfusion.filter.ClientScopePersistenceFilter.invoke(

        at coldfusion.filter.GlobalsFilter.invoke(

        at coldfusion.filter.DatasourceFilter.invoke(



        at javax.servlet.http.HttpServlet.service(

        at coldfusion.bootstrap.BootstrapServlet.service(

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(

        at coldfusion.monitor.event.MonitoringServletFilter.doFilter(

        at coldfusion.bootstrap.BootstrapFilter.doFilter(

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(

        at org.apache.catalina.core.StandardWrapperValve.invoke(

        at org.apache.catalina.core.StandardContextValve.invoke(

        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(

        at org.apache.catalina.core.StandardHostValve.invoke(

        at org.apache.catalina.valves.ErrorReportValve.invoke(

        at org.apache.catalina.core.StandardEngineValve.invoke(

        at org.apache.catalina.connector.CoyoteAdapter.service(

        at org.apache.coyote.ajp.AjpProcessor.process(

        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(


        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

        at java.util.concurrent.ThreadPoolExecutor$ Source)

        at Source)

Disabling lazy loading will fix this, but results in unacceptable performance (load times go from 200ms to 22s).  I'm not sure how else to handle this.

I am new to REST in ColdFusion, and it seems to me that the CFC's are being handled in an unusual way.  They do not appear to be initialized (init method does not seem to run) and now it seems that ORM is not handled the same either.  Am I missing something?

Here is the excerpt of my code producing this error:

    component rest="true" restpath="item"


        import model.beans.*;


        remote item function getitem( numeric id restargsource="Path" ) restpath="{id}" httpmethod="GET"


            var item = entityLoad("item",{ id = id },true);


            return item;




And the bean:

    component persistent="true" table="item" output="false" extends="timestampedBean" batchsize="10" cacheuse="read-only"


        /* properties */


        property name="id" column="id" type="numeric" ormtype="int" fieldtype="id" generator="identity";

        property name="title" column="title" type="string" ormtype="string";

        property name="description" column="description" type="string" ormtype="string";

        property name="status" column="status" type="numeric" ormtype="byte" default="0" ;

        property name="user" fieldtype="many-to-one" cfc="user" fkcolumn="userid" inversejoincolum="userid" lazy="true" cacheuse="read-only";

        property name="field" type="array" fieldtype="many-to-many" cfc="field" fkcolumn="id" linktable="items_fields" inversejoincolumn="fieldid" lazy="extra" batchsize="10" cacheuse="read-only";


I also noticed in the stdout log that Hibernate is logging the query, but then it logs the "No session" error:



   as id0_0_,

            item0_.dtcreated as dtcreated0_0_,

            item0_.dtmodified as dtmodified0_0_,

            item0_.title as title0_0_,

            item0_.description as descript6_0_0_,

            item0_.status as status0_0_,

            item0_.userid as userid0_0_


            item item0_



    Dec 2, 2014 15:23:00 PM Error [ajp-bio-8014-exec-3] - failed to lazily initialize a collection of role: field, could not initialize proxy - no Session The specific sequence of files included or processed is: service.cfc''

I should probably also add that this "item" table is part of a many-to-many relationship, so "collection of role: field" is referencing the foreign table.







Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation