Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    JPADataSource and ManyToMany relationship

    Does JPADataSource support ManyToMany relationship? I could find examples with OneToMany and ManyToOne, but couldn't find example using ManyToMany. Is it supported or I should use SQL DataSource?

    #2
    OK, it seems that it is possible to use it in similar way like OneToMany.

    However, I couldn't make it load lazy collection. That is, until I made my ManyToMany collection as FetchType.EAGER I had LazyInitializationException when fetching data source. Am I doing something wrong or it is expected behavior?

    Comment


      #3
      Hi,

      Can you provide with minimal test case?

      Regards,
      Alius

      Comment


        #4
        Hm, I can post my code (at least parts that I think they are important):

        Role.java
        Code:
        @Entity
        @Table(name="es_role")
        
        public class Role implements Serializable {
           	@Id
            @GeneratedValue(strategy = GenerationType.AUTO)
            @Column(name="id")
            private Long id;
        
            @Column(name="name", unique=true)
            private String name;
            
            @Column(name="description")
            private String description;
            
            @Column(name="status_id")
            private Integer statusId;
            
            @ManyToMany
            @JoinTable(name="es_role_permission",
                   joinColumns=@JoinColumn(name="role_id"),
                    inverseJoinColumns=@JoinColumn(name="permission_id"))
            private Set<Permission> permissions;
           
           
           //getters and setters
           ...
        }
        Permission.java
        Code:
        @Entity
        @Table(name="es_permission")
        
        public class Permission implements Serializable {
         	@Id
            @GeneratedValue(strategy = GenerationType.AUTO)
            @Column(name="id")
            private Long id;
        
            @Column(name="name", unique=true)
            private String name;
            
            @Column(name="description")
            private String description;
            
            @Column(name="status_id")
            private Integer statusId;
            
            //getters and setters
            ...
        }
        permission.ds.xml

        Code:
        <DataSource  
            ID="permission"  
            serverConstructor="com.isomorphic.jpa.JPA2DataSource"  
            autoDeriveSchema="false"  
            schemaBean="net.esteh.esdoc.domain.Permission">
            
            
            <fields>
                <field name="id"  title="ID"   type="sequence" required="true" primaryKey="true" />        
                <field name="name" title="Name" type="string" required="false" />
                <field name="description" title="Description" type="string" required="false" />
                <field name="statusId" title="Status">
                    <valueMap> 
                        <value ID="1">Active</value> 
                        <value ID="2">Inactive</value>
                    </valueMap>
                </field>
            </fields>
            
        </DataSource>
        role.ds.xml
        Code:
        <!-- <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -->
          
        <DataSource xmlns:fmt="urn:jsptld:http://java.sun.com/jsp/jstl/fmt"  
            ID="role"  
            serverConstructor="com.isomorphic.jpa.JPA2DataSource"  
            autoDeriveSchema="false"  
            schemaBean="net.esteh.esdoc.domain.Role"
            dropExtraFields="true">
            
            
            <fields>
                <field name="id"  title="ID"   type="sequence" required="true" primaryKey="true" />        
                <field name="name" title="Name" type="string" required="false" />
                <field name="description" title="Description" type="string" required="false" />
                <field name="statusId" title="Status">
                    <valueMap> 
                        <value ID="1">Active</value> 
                        <value ID="2">Inactive</value>
                    </valueMap>
                </field>
                
                <field name="permissions" 
                       title="Permissions"
                       canSave="true"   
                       type="permission"
                       javaCollectionClass="net.esteh.esdoc.domain.Permission"
                       multiple="true"
                       foreignKey="permission.id"/>
                      
        	</fields>
           
            
        </DataSource>
        RoleListGrid.java
        Code:
        package net.esteh.esdoc.client.panel.admin.role;
        
        import com.smartgwt.client.data.DataSource;
        import com.smartgwt.client.widgets.grid.ListGridField;
        
        import net.esteh.esdoc.client.EstehListGrid;
        
        public class RoleListGrid extends EstehListGrid {
        	
        	public ListGridField nameField = new ListGridField("name");
        	public ListGridField descriptionField = new ListGridField("description");
        	
        	public RoleListGrid() {
        		setFields(nameField, descriptionField);
        		setDataSource(DataSource.get("role"));
        		setAutoFetchData(true);
        	}
        }

        When data is fetched, list gets data but permissions are not populated (I need that for second list grid). Here is log:
        Code:
        INFO: === 2012-02-07 11:19:19,662 [0(4)] INFO  RequestContext - URL: '/esdoc-web/esdoc/sc/IDACall', User-Agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7': Safari with Accept-Encoding header
        
        INFO: === 2012-02-07 11:19:19,664 [0(4)] DEBUG DataSource - In DS.forName() for 'transaction' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,664 [0(4)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,664 [0(4)] DEBUG DataSource - Creating instance of DataSource 'Object'
        
        INFO: === 2012-02-07 11:19:19,664 [0(4)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,664 [0(4)] DEBUG DataSource - Creating instance of DataSource 'Object'
        
        INFO: === 2012-02-07 11:19:19,665 [0(4)] DEBUG DataSource - In DS.forName() for 'List' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,665 [0(4)] DEBUG DataSource - Creating instance of DataSource 'List'
        
        INFO: === 2012-02-07 11:19:19,665 [0(4)] DEBUG DataSource - In DS.forName() for 'elem' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,666 [0(4)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,666 [0(4)] DEBUG DataSource - Creating instance of DataSource 'Object'
        
        INFO: === 2012-02-07 11:19:19,666 [0(4)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,666 [0(4)] DEBUG DataSource - Creating instance of DataSource 'Object'
        
        INFO: === 2012-02-07 11:19:19,667 [0(4)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,667 [0(4)] DEBUG DataSource - Creating instance of DataSource 'Object'
        
        INFO: === 2012-02-07 11:19:19,667 [0(4)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,667 [0(4)] DEBUG DataSource - Creating instance of DataSource 'Object'
        
        INFO: === 2012-02-07 11:19:19,667 [0(4)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,667 [0(4)] DEBUG DataSource - Creating instance of DataSource 'Object'
        
        INFO: === 2012-02-07 11:19:19,668 [0(4)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,668 [0(4)] DEBUG DataSource - Creating instance of DataSource 'Object'
        
        INFO: === 2012-02-07 11:19:19,668 [0(4)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,668 [0(4)] DEBUG DataSource - Creating instance of DataSource 'Object'
        
        INFO: === 2012-02-07 11:19:19,668 [0(4)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,669 [0(4)] DEBUG DataSource - Creating instance of DataSource 'Object'
        
        INFO: === 2012-02-07 11:19:19,669 [0(4)] DEBUG DataSource - In DS.forName() for 'role' with DSRequest: com.isomorphic.datasource.DSRequest@128bc73
        
        INFO: === 2012-02-07 11:19:19,669 [0(4)] DEBUG DataSource - Creating instance of DataSource 'role'
        
        INFO: === 2012-02-07 11:19:19,669 [0(4)] DEBUG DataSource - In DS.forName() for 'permission' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,670 [0(4)] DEBUG DataSource - Creating instance of DataSource 'permission'
        
        INFO: Hibernate: select top 2 count(role0_.id) as col_0_0_ from es_role role0_
        INFO: Hibernate: select top 75 role0_.id as id79_, role0_.description as descript2_79_, role0_.name as name79_, role0_.status_id as status4_79_ from es_role role0_
        INFO: === 2012-02-07 11:19:19,684 [0(4)] INFO  DSResponse - [builtinApplication.role_fetch] DSResponse: List with 3 items
        
        INFO: === 2012-02-07 11:19:19,688 [0(4)] WARN  DSResponse - Attempted to call getRecord() on a DSResponse with null DataSource
        
        INFO: === 2012-02-07 11:19:19,688 [0(4)] DEBUG DataSource - In DS.forName() for 'role' with DSRequest: com.isomorphic.datasource.DSRequest@128bc73
        
        INFO: === 2012-02-07 11:19:19,689 [0(4)] DEBUG DataSource - Creating instance of DataSource 'role'
        
        INFO: === 2012-02-07 11:19:19,689 [0(4)] DEBUG DataSource - In DS.forName() for 'permission' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,689 [0(4)] DEBUG DataSource - Creating instance of DataSource 'permission'
        
        INFO: === 2012-02-07 11:19:19,690 [0(4)] DEBUG DataSource - In DS.forName() for 'permission' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,690 [0(4)] DEBUG DataSource - Creating instance of DataSource 'permission'
        
        SEVERE: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
        org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
        	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
        	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
        	at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
        	at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
        	at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:186)
        	at com.isomorphic.jpa.JPADataSource.getRelationFieldValue(JPADataSource.java:3313)
        	at com.isomorphic.datasource.DataSource.getProperties(DataSource.java:1729)
        	at com.isomorphic.datasource.DataSourceBeanFilter.filter(DataSourceBeanFilter.java:200)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:659)
        	at com.isomorphic.js.JSTranslater.convertIterator(JSTranslater.java:1163)
        	at com.isomorphic.js.JSTranslater.convertCollection(JSTranslater.java:1114)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:621)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:557)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:548)
        	at com.isomorphic.js.JSTranslater.convertMap(JSTranslater.java:1001)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:619)
        	at com.isomorphic.js.JSTranslater.convertIterator(JSTranslater.java:1163)
        	at com.isomorphic.js.JSTranslater.convertCollection(JSTranslater.java:1114)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:621)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:557)
        	at com.isomorphic.js.JSTranslater.toJS(JSTranslater.java:519)
        	at com.isomorphic.rpc.RPCManager.completeResponse(RPCManager.java:1267)
        	at com.isomorphic.rpc.RPCManager.send(RPCManager.java:582)
        	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156)
        	at net.esteh.esdoc.server.web.servlet.EstehIDACallServlet.processRPCTransaction(EstehIDACallServlet.java:34)
        	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
        	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
        	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
        	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
        	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
        	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
        	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
        	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
        	at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
        	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
        	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
        	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
        	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
        	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
        	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
        	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
        	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
        	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        	at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        	at java.lang.Thread.run(Thread.java:680)
        
        INFO: === 2012-02-07 11:19:19,691 [0(4)] WARN  DataSource - Couldn't get value for property 'permissions' for datasource 'role' - ignoring. Actual error: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
        
        INFO: === 2012-02-07 11:19:19,693 [0(4)] DEBUG DataSource - In DS.forName() for 'string' with DSRequest: com.isomorphic.datasource.DSRequest@128bc73
        
        INFO: === 2012-02-07 11:19:19,693 [0(4)] DEBUG DataSource - In DS.forName() for 'sequence' with DSRequest: com.isomorphic.datasource.DSRequest@128bc73
        
        INFO: === 2012-02-07 11:19:19,694 [0(4)] DEBUG DataSource - In DS.forName() for 'integer' with DSRequest: com.isomorphic.datasource.DSRequest@128bc73
        
        INFO: === 2012-02-07 11:19:19,694 [0(4)] DEBUG DataSource - In DS.forName() for 'permission' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,694 [0(4)] DEBUG DataSource - Creating instance of DataSource 'permission'
        
        SEVERE: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
        org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
        	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
        	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
        	at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
        	at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
        	at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:186)
        	at com.isomorphic.jpa.JPADataSource.getRelationFieldValue(JPADataSource.java:3313)
        	at com.isomorphic.datasource.DataSource.getProperties(DataSource.java:1729)
        	at com.isomorphic.datasource.DataSourceBeanFilter.filter(DataSourceBeanFilter.java:200)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:659)
        	at com.isomorphic.js.JSTranslater.convertIterator(JSTranslater.java:1163)
        	at com.isomorphic.js.JSTranslater.convertCollection(JSTranslater.java:1114)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:621)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:557)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:548)
        	at com.isomorphic.js.JSTranslater.convertMap(JSTranslater.java:1001)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:619)
        	at com.isomorphic.js.JSTranslater.convertIterator(JSTranslater.java:1163)
        	at com.isomorphic.js.JSTranslater.convertCollection(JSTranslater.java:1114)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:621)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:557)
        	at com.isomorphic.js.JSTranslater.toJS(JSTranslater.java:519)
        	at com.isomorphic.rpc.RPCManager.completeResponse(RPCManager.java:1267)
        	at com.isomorphic.rpc.RPCManager.send(RPCManager.java:582)
        	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156)
        	at net.esteh.esdoc.server.web.servlet.EstehIDACallServlet.processRPCTransaction(EstehIDACallServlet.java:34)
        	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
        	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
        	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
        	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
        	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
        	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
        	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
        	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
        	at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
        	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
        	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
        	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
        	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
        	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
        	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
        	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
        	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
        	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        	at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        	at java.lang.Thread.run(Thread.java:680)
        
        INFO: === 2012-02-07 11:19:19,695 [0(4)] WARN  DataSource - Couldn't get value for property 'permissions' for datasource 'role' - ignoring. Actual error: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
        
        INFO: === 2012-02-07 11:19:19,696 [0(4)] DEBUG DataSource - In DS.forName() for 'permission' with DSRequest: null
        
        INFO: === 2012-02-07 11:19:19,696 [0(4)] DEBUG DataSource - Creating instance of DataSource 'permission'
        
        
        SEVERE: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
        org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
        	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
        	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
        	at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
        	at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
        	at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:186)
        	at com.isomorphic.jpa.JPADataSource.getRelationFieldValue(JPADataSource.java:3313)
        	at com.isomorphic.datasource.DataSource.getProperties(DataSource.java:1729)
        	at com.isomorphic.datasource.DataSourceBeanFilter.filter(DataSourceBeanFilter.java:200)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:659)
        	at com.isomorphic.js.JSTranslater.convertIterator(JSTranslater.java:1163)
        	at com.isomorphic.js.JSTranslater.convertCollection(JSTranslater.java:1114)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:621)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:557)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:548)
        	at com.isomorphic.js.JSTranslater.convertMap(JSTranslater.java:1001)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:619)
        	at com.isomorphic.js.JSTranslater.convertIterator(JSTranslater.java:1163)
        	at com.isomorphic.js.JSTranslater.convertCollection(JSTranslater.java:1114)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:621)
        	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:557)
        	at com.isomorphic.js.JSTranslater.toJS(JSTranslater.java:519)
        	at com.isomorphic.rpc.RPCManager.completeResponse(RPCManager.java:1267)
        	at com.isomorphic.rpc.RPCManager.send(RPCManager.java:582)
        	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156)
        	at net.esteh.esdoc.server.web.servlet.EstehIDACallServlet.processRPCTransaction(EstehIDACallServlet.java:34)
        	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
        	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
        	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
        	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
        	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
        	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
        	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
        	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
        	at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
        	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
        	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
        	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
        	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
        	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
        	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
        	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
        	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
        	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        	at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        	at java.lang.Thread.run(Thread.java:680)
        
        INFO: === 2012-02-07 11:19:19,697 [0(4)] WARN  DataSource - Couldn't get value for property 'permissions' for datasource 'role' - ignoring. Actual error: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
        
        INFO: === 2012-02-07 11:19:19,697 [0(4)] INFO  Compression - /esdoc-web/esdoc/sc/IDACall: 363 -> 235 bytes
        If I put change ManyToMany annotation to @ManyToMany(fetch=FetchType.EAGER) I don't have this error.

        Comment


          #5
          Hi.

          Strange. EntityManager should be open at the moment of exception.

          Could you set logging to debug for following packages:

          com.isomorphic.jpa
          com.isomorphic.datasource
          com.isomorphic.rpc

          and post server log.

          Regards,
          Alius

          Comment


            #6
            Here it is:

            Code:
            INFO: === 2012-02-08 08:18:58,212 [0(3)] INFO  RequestContext - URL: '/esdoc-web/esdoc/sc/IDACall', User-Agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7': Safari with Accept-Encoding header
            
            INFO: === 2012-02-08 08:18:58,214 [0(3)] DEBUG DataSource - In DS.forName() for 'transaction' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,215 [0(3)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,215 [0(3)] DEBUG DataSource - Creating instance of DataSource 'Object'
            
            INFO: === 2012-02-08 08:18:58,215 [0(3)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,216 [0(3)] DEBUG DataSource - Creating instance of DataSource 'Object'
            
            INFO: === 2012-02-08 08:18:58,216 [0(3)] DEBUG DataSource - In DS.forName() for 'List' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,217 [0(3)] DEBUG DataSource - Creating instance of DataSource 'List'
            
            INFO: === 2012-02-08 08:18:58,217 [0(3)] DEBUG DataSource - In DS.forName() for 'elem' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,218 [0(3)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,218 [0(3)] DEBUG DataSource - Creating instance of DataSource 'Object'
            
            INFO: === 2012-02-08 08:18:58,218 [0(3)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,219 [0(3)] DEBUG DataSource - Creating instance of DataSource 'Object'
            
            INFO: === 2012-02-08 08:18:58,219 [0(3)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,219 [0(3)] DEBUG DataSource - Creating instance of DataSource 'Object'
            
            INFO: === 2012-02-08 08:18:58,220 [0(3)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,221 [0(3)] DEBUG DataSource - Creating instance of DataSource 'Object'
            
            INFO: === 2012-02-08 08:18:58,221 [0(3)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,222 [0(3)] DEBUG DataSource - Creating instance of DataSource 'Object'
            
            INFO: === 2012-02-08 08:18:58,222 [0(3)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,223 [0(3)] DEBUG DataSource - Creating instance of DataSource 'Object'
            
            INFO: === 2012-02-08 08:18:58,223 [0(3)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,223 [0(3)] DEBUG DataSource - Creating instance of DataSource 'Object'
            
            INFO: === 2012-02-08 08:18:58,224 [0(3)] DEBUG DataSource - In DS.forName() for 'Object' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,224 [0(3)] DEBUG DataSource - Creating instance of DataSource 'Object'
            
            INFO: === 2012-02-08 08:18:58,224 [0(3)] DEBUG RPCManager - Processing 1 requests.
            
            INFO: === 2012-02-08 08:18:58,225 [0(3)] DEBUG DataSource - In DS.forName() for 'role' with DSRequest: com.isomorphic.datasource.DSRequest@cde6a
            
            INFO: === 2012-02-08 08:18:58,227 [0(3)] DEBUG DataSource - In DS.forName() for 'DataSource' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,227 [0(3)] DEBUG DataSource - Creating instance of DataSource 'DataSource'
            
            INFO: === 2012-02-08 08:18:58,228 [0(3)] DEBUG DataSource - In DS.forName() for 'DataSource' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,228 [0(3)] DEBUG DataSource - Creating instance of DataSource 'DataSource'
            
            INFO: === 2012-02-08 08:18:58,229 [0(3)] DEBUG DataSource - In DS.forName() for 'DataSourceField' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,229 [0(3)] DEBUG DataSource - Creating instance of DataSource 'DataSourceField'
            
            INFO: === 2012-02-08 08:18:58,229 [0(3)] DEBUG DataSource - In DS.forName() for 'field' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,230 [0(3)] DEBUG DataSource - In DS.forName() for 'ValueMap' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,230 [0(3)] DEBUG DataSource - Creating instance of DataSource 'ValueMap'
            
            INFO: === 2012-02-08 08:18:58,231 [0(3)] DEBUG JPADSGenerator - Instantiating class net.esteh.esdoc.domain.Role
            
            INFO: === 2012-02-08 08:18:58,232 [0(3)] DEBUG JPADSGenerator - Generating data source 'net.esteh.esdoc.domain.Role_JPA' for class net.esteh.esdoc.domain.Role
            
            INFO: === 2012-02-08 08:18:58,232 [0(3)] DEBUG JPADSGenerator - Generating field 'permissions' of type java.util.Set
            
            INFO: === 2012-02-08 08:18:58,233 [0(3)] DEBUG JPADSGenerator - Plural field skipped: {name=permissions, type=any}
            
            INFO: === 2012-02-08 08:18:58,233 [0(3)] DEBUG JPADSGenerator - Generating field 'name' of type java.lang.String
            
            INFO: === 2012-02-08 08:18:58,233 [0(3)] DEBUG JPADSGenerator - Singular field configuration generated: {name=name, length=255, canEdit=true, required=false, type=text}
            
            INFO: === 2012-02-08 08:18:58,234 [0(3)] DEBUG JPADSGenerator - Generating field 'id' of type java.lang.Long
            
            INFO: === 2012-02-08 08:18:58,234 [0(3)] DEBUG JPADSGenerator - Singular field configuration generated: {hidden=true, primaryKey=true, name=id, length=255, canEdit=false, required=false, type=sequence}
            
            INFO: === 2012-02-08 08:18:58,235 [0(3)] DEBUG JPADSGenerator - Generating field 'description' of type java.lang.String
            
            INFO: === 2012-02-08 08:18:58,235 [0(3)] DEBUG JPADSGenerator - Singular field configuration generated: {name=description, length=255, canEdit=true, required=false, type=text}
            
            INFO: === 2012-02-08 08:18:58,235 [0(3)] DEBUG JPADSGenerator - Generating field 'statusId' of type java.lang.Integer
            
            INFO: === 2012-02-08 08:18:58,236 [0(3)] DEBUG JPADSGenerator - Singular field configuration generated: {name=statusId, length=255, canEdit=true, required=false, type=integer}
            
            INFO: === 2012-02-08 08:18:58,236 [0(3)] DEBUG DataSource - Creating instance of DataSource 'role_inheritsFrom'
            
            INFO: === 2012-02-08 08:18:58,236 [0(3)] DEBUG DataSource - Creating instance of DataSource 'role'
            
            INFO: === 2012-02-08 08:18:58,237 [0(3)] DEBUG DataSource - In DS.forName() for 'permission' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,239 [0(3)] DEBUG DataSource - In DS.forName() for 'DataSource' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,240 [0(3)] DEBUG DataSource - Creating instance of DataSource 'DataSource'
            
            INFO: === 2012-02-08 08:18:58,240 [0(3)] DEBUG DataSource - In DS.forName() for 'DataSource' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,241 [0(3)] DEBUG DataSource - Creating instance of DataSource 'DataSource'
            
            INFO: === 2012-02-08 08:18:58,241 [0(3)] DEBUG DataSource - In DS.forName() for 'DataSourceField' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,242 [0(3)] DEBUG DataSource - Creating instance of DataSource 'DataSourceField'
            
            INFO: === 2012-02-08 08:18:58,242 [0(3)] DEBUG DataSource - In DS.forName() for 'field' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,243 [0(3)] DEBUG DataSource - In DS.forName() for 'ValueMap' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,243 [0(3)] DEBUG DataSource - Creating instance of DataSource 'ValueMap'
            
            INFO: === 2012-02-08 08:18:58,244 [0(3)] DEBUG JPADSGenerator - Instantiating class net.esteh.esdoc.domain.Permission
            
            INFO: === 2012-02-08 08:18:58,244 [0(3)] DEBUG JPADSGenerator - Generating data source 'net.esteh.esdoc.domain.Permission_JPA' for class net.esteh.esdoc.domain.Permission
            
            INFO: === 2012-02-08 08:18:58,244 [0(3)] DEBUG JPADSGenerator - Generating field 'id' of type java.lang.Long
            
            INFO: === 2012-02-08 08:18:58,245 [0(3)] DEBUG JPADSGenerator - Singular field configuration generated: {hidden=true, primaryKey=true, name=id, length=255, canEdit=false, required=false, type=sequence}
            
            INFO: === 2012-02-08 08:18:58,245 [0(3)] DEBUG JPADSGenerator - Generating field 'name' of type java.lang.String
            
            INFO: === 2012-02-08 08:18:58,245 [0(3)] DEBUG JPADSGenerator - Singular field configuration generated: {name=name, length=255, canEdit=true, required=false, type=text}
            
            INFO: === 2012-02-08 08:18:58,246 [0(3)] DEBUG JPADSGenerator - Generating field 'statusId' of type java.lang.Integer
            
            INFO: === 2012-02-08 08:18:58,246 [0(3)] DEBUG JPADSGenerator - Singular field configuration generated: {name=statusId, length=255, canEdit=true, required=false, type=integer}
            
            INFO: === 2012-02-08 08:18:58,246 [0(3)] DEBUG JPADSGenerator - Generating field 'description' of type java.lang.String
            
            INFO: === 2012-02-08 08:18:58,247 [0(3)] DEBUG JPADSGenerator - Singular field configuration generated: {name=description, length=255, canEdit=true, required=false, type=text}
            
            INFO: === 2012-02-08 08:18:58,247 [0(3)] DEBUG DataSource - Creating instance of DataSource 'permission_inheritsFrom'
            
            INFO: === 2012-02-08 08:18:58,247 [0(3)] DEBUG DataSource - Creating instance of DataSource 'permission'
            
            INFO: === 2012-02-08 08:18:58,251 [0(3)] DEBUG RPCManager - Request #1 (DSRequest) payload: {
                criteria:{
                },
                operationConfig:{
                    dataSource:"role",
                    operationType:"fetch",
                    textMatchStyle:"substring"
                },
                startRow:0,
                endRow:75,
                componentId:"isc_RoleListGrid_0",
                appID:"builtinApplication",
                operation:"role_fetch",
                oldValues:{
                }
            }
            
            INFO: === 2012-02-08 08:18:58,251 [0(3)] DEBUG JPADataSource - [builtinApplication.role_fetch] Creating EntityManager and starting transaction.
            
            INFO: === 2012-02-08 08:18:58,252 [0(3)] DEBUG DSRequest - [builtinApplication.role_fetch] Clobbering existing FreeResourcesHandler of type 'com.isomorphic.jpa.JPA2DataSource' with a 'com.isomorphic.jpa.JPA2DataSource'
            
            INFO: === 2012-02-08 08:18:58,252 [0(3)] DEBUG JPADataSource - [builtinApplication.role_fetch] Executing fetch.
            
            INFO: === 2012-02-08 08:18:58,253 [0(3)] DEBUG JPADataSource - [builtinApplication.role_fetch] Query string: select _Role from Role _Role
            
            INFO: Hibernate: select top 2 count(role0_.id) as col_0_0_ from es_role role0_
            INFO: Hibernate: select top 75 role0_.id as id3_, role0_.description as descript2_3_, role0_.name as name3_, role0_.status_id as status4_3_ from es_role role0_
            INFO: === 2012-02-08 08:18:58,273 [0(3)] INFO  DSResponse - [builtinApplication.role_fetch] DSResponse: List with 3 items
            
            INFO: === 2012-02-08 08:18:58,273 [0(3)] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
            
            INFO: === 2012-02-08 08:18:58,274 [0(3)] DEBUG JPADataSource - Committing current transaction.
            
            INFO: === 2012-02-08 08:18:58,276 [0(3)] WARN  DSResponse - Attempted to call getRecord() on a DSResponse with null DataSource
            
            INFO: === 2012-02-08 08:18:58,277 [0(3)] DEBUG DataSource - In DS.forName() for 'role' with DSRequest: com.isomorphic.datasource.DSRequest@cde6a
            
            INFO: === 2012-02-08 08:18:58,277 [0(3)] DEBUG DataSource - Creating instance of DataSource 'role'
            
            INFO: === 2012-02-08 08:18:58,277 [0(3)] DEBUG DataSource - In DS.forName() for 'permission' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,278 [0(3)] DEBUG DataSource - Creating instance of DataSource 'permission'
            
            INFO: === 2012-02-08 08:18:58,278 [0(3)] DEBUG RPCManager - non-DMI response, dropExtraFields: true
            
            INFO: === 2012-02-08 08:18:58,279 [0(3)] DEBUG DataSource - In DS.forName() for 'permission' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,280 [0(3)] DEBUG DataSource - Creating instance of DataSource 'permission'
            
            SEVERE: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
            org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
            	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
            	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
            	at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
            	at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
            	at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:186)
            	at com.isomorphic.jpa.JPADataSource.getRelationFieldValue(JPADataSource.java:3313)
            	at com.isomorphic.datasource.DataSource.getProperties(DataSource.java:1729)
            	at com.isomorphic.datasource.DataSourceBeanFilter.filter(DataSourceBeanFilter.java:200)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:659)
            	at com.isomorphic.js.JSTranslater.convertIterator(JSTranslater.java:1163)
            	at com.isomorphic.js.JSTranslater.convertCollection(JSTranslater.java:1114)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:621)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:557)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:548)
            	at com.isomorphic.js.JSTranslater.convertMap(JSTranslater.java:1001)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:619)
            	at com.isomorphic.js.JSTranslater.convertIterator(JSTranslater.java:1163)
            	at com.isomorphic.js.JSTranslater.convertCollection(JSTranslater.java:1114)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:621)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:557)
            	at com.isomorphic.js.JSTranslater.toJS(JSTranslater.java:519)
            	at com.isomorphic.rpc.RPCManager.completeResponse(RPCManager.java:1267)
            	at com.isomorphic.rpc.RPCManager.send(RPCManager.java:582)
            	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156)
            	at net.esteh.esdoc.server.web.servlet.EstehIDACallServlet.processRPCTransaction(EstehIDACallServlet.java:34)
            	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
            	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
            	at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
            	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
            	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
            	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
            	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
            	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
            	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
            	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
            	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
            	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
            	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
            	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
            	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
            	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
            	at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
            	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
            	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
            	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
            	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
            	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
            	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
            	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
            	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
            	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
            	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
            	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
            	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
            	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
            	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
            	at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
            	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
            	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
            	at java.lang.Thread.run(Thread.java:680)
            
            INFO: === 2012-02-08 08:18:58,281 [0(3)] WARN  DataSource - Couldn't get value for property 'permissions' for datasource 'role' - ignoring. Actual error: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
            
            INFO: === 2012-02-08 08:18:58,283 [0(3)] DEBUG DataSource - In DS.forName() for 'string' with DSRequest: com.isomorphic.datasource.DSRequest@cde6a
            
            INFO: === 2012-02-08 08:18:58,283 [0(3)] DEBUG DataSource - In DS.forName() for 'sequence' with DSRequest: com.isomorphic.datasource.DSRequest@cde6a
            
            INFO: === 2012-02-08 08:18:58,283 [0(3)] DEBUG DataSource - In DS.forName() for 'integer' with DSRequest: com.isomorphic.datasource.DSRequest@cde6a
            
            INFO: === 2012-02-08 08:18:58,284 [0(3)] DEBUG DataSource - In DS.forName() for 'permission' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,284 [0(3)] DEBUG DataSource - Creating instance of DataSource 'permission'
            
            SEVERE: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
            org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
            	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
            	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
            	at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
            	at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
            	at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:186)
            	at com.isomorphic.jpa.JPADataSource.getRelationFieldValue(JPADataSource.java:3313)
            	at com.isomorphic.datasource.DataSource.getProperties(DataSource.java:1729)
            	at com.isomorphic.datasource.DataSourceBeanFilter.filter(DataSourceBeanFilter.java:200)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:659)
            	at com.isomorphic.js.JSTranslater.convertIterator(JSTranslater.java:1163)
            	at com.isomorphic.js.JSTranslater.convertCollection(JSTranslater.java:1114)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:621)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:557)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:548)
            	at com.isomorphic.js.JSTranslater.convertMap(JSTranslater.java:1001)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:619)
            	at com.isomorphic.js.JSTranslater.convertIterator(JSTranslater.java:1163)
            	at com.isomorphic.js.JSTranslater.convertCollection(JSTranslater.java:1114)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:621)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:557)
            	at com.isomorphic.js.JSTranslater.toJS(JSTranslater.java:519)
            	at com.isomorphic.rpc.RPCManager.completeResponse(RPCManager.java:1267)
            	at com.isomorphic.rpc.RPCManager.send(RPCManager.java:582)
            	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156)
            	at net.esteh.esdoc.server.web.servlet.EstehIDACallServlet.processRPCTransaction(EstehIDACallServlet.java:34)
            	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
            	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
            	at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
            	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
            	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
            	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
            	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
            	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
            	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
            	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
            	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
            	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
            	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
            	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
            	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
            	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
            	at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
            	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
            	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
            	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
            	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
            	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
            	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
            	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
            	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
            	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
            	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
            	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
            	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
            	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
            	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
            	at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
            	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
            	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
            	at java.lang.Thread.run(Thread.java:680)
            
            INFO: === 2012-02-08 08:18:58,285 [0(3)] WARN  DataSource - Couldn't get value for property 'permissions' for datasource 'role' - ignoring. Actual error: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
            
            INFO: === 2012-02-08 08:18:58,286 [0(3)] DEBUG DataSource - In DS.forName() for 'permission' with DSRequest: null
            
            INFO: === 2012-02-08 08:18:58,286 [0(3)] DEBUG DataSource - Creating instance of DataSource 'permission'
            
            SEVERE: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
            org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
            	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
            	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
            	at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
            	at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
            	at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:186)
            	at com.isomorphic.jpa.JPADataSource.getRelationFieldValue(JPADataSource.java:3313)
            	at com.isomorphic.datasource.DataSource.getProperties(DataSource.java:1729)
            	at com.isomorphic.datasource.DataSourceBeanFilter.filter(DataSourceBeanFilter.java:200)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:659)
            	at com.isomorphic.js.JSTranslater.convertIterator(JSTranslater.java:1163)
            	at com.isomorphic.js.JSTranslater.convertCollection(JSTranslater.java:1114)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:621)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:557)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:548)
            	at com.isomorphic.js.JSTranslater.convertMap(JSTranslater.java:1001)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:619)
            	at com.isomorphic.js.JSTranslater.convertIterator(JSTranslater.java:1163)
            	at com.isomorphic.js.JSTranslater.convertCollection(JSTranslater.java:1114)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:621)
            	at com.isomorphic.js.JSTranslater.convert(JSTranslater.java:557)
            	at com.isomorphic.js.JSTranslater.toJS(JSTranslater.java:519)
            	at com.isomorphic.rpc.RPCManager.completeResponse(RPCManager.java:1267)
            	at com.isomorphic.rpc.RPCManager.send(RPCManager.java:582)
            	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156)
            	at net.esteh.esdoc.server.web.servlet.EstehIDACallServlet.processRPCTransaction(EstehIDACallServlet.java:34)
            	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
            	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
            	at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
            	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
            	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
            	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
            	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
            	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
            	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
            	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
            	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
            	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
            	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
            	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
            	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
            	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
            	at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
            	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
            	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
            	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
            	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
            	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
            	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
            	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
            	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
            	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
            	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
            	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
            	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
            	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
            	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
            	at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
            	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
            	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
            	at java.lang.Thread.run(Thread.java:680)
            
            INFO: === 2012-02-08 08:18:58,287 [0(3)] WARN  DataSource - Couldn't get value for property 'permissions' for datasource 'role' - ignoring. Actual error: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: net.esteh.esdoc.domain.Role.permissions, no session or session was closed
            
            INFO: === 2012-02-08 08:18:58,289 [0(3)] DEBUG JPADataSource - Releasing entity manager.
            
            INFO: === 2012-02-08 08:18:58,290 [0(3)] INFO  Compression - /esdoc-web/esdoc/sc/IDACall: 363 -> 235 bytes

            Comment


              #7
              Hi,

              Looks like it is something wrong with your configuration (check settings in your glassfish).

              If you will check log you will see that after execution of select transaction is committed but connection is not closed yet. Then JPADataSource tries to lazily load permissions for every role (fails with exception for every row). At the end of the log you can see line
              Code:
              INFO: === 2012-02-08 08:18:58,289 [0(3)] DEBUG JPADataSource - Releasing entity manager.
              At this moment system releases (closes) EntityManager. Lazy-loading exceptions before this line most probably indicate that EntityManager was closed by container.

              Regards,
              Alius

              Comment


                #8
                Hmm, could this be connected with other problem I have reported:
                http://forums.smartclient.com/showthread.php?t=20789?

                Comment


                  #9
                  I'm not sure. Here we deal with closed connection (not transaction).

                  Comment

                  Working...
                  X