Page 1 of 1

OrderImpl.fulfillmentGroups, no session or session was close

Posted: Tue Mar 05, 2013 5:50 pm
by pam
Trying to order an item. I am getting following exception-

Code: Select all

SEVERE: failed to lazily initialize a collection of role: org.broadleafcommerce.order.domain.OrderImpl.fulfillmentGroups, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.broadleafcommerce.order.domain.OrderImpl.fulfillmentGroups, 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.readSize(AbstractPersistentCollection.java:119)
   at org.hibernate.collection.PersistentBag.isEmpty(PersistentBag.java:255)
   at org.broadleafcommerce.order.web.CartController.viewCart(CartController.java:138)


How to go about this issue?

Thanks in advance

Re: OrderImpl.fulfillmentGroups, no session or session was close

Posted: Tue Mar 05, 2013 5:58 pm
by phillipuniverse
Where is this happening? Controller, Thymeleaf template?

Re: OrderImpl.fulfillmentGroups, no session or session was close

Posted: Tue Mar 05, 2013 6:04 pm
by phillipuniverse
Sorry, didn't see the last line of your stack trace. Is there an exception happens in the CartController.viewCart() method? If an exception gets thrown then all of your objects are evicted from the hibernate session, so you need to re-establish them. Something like this:

Code: Select all

protected void viewCart(HttpServletRequest requestHttpServletResponse response) {
    
boolean foundException false;
    try { 
        
Order cart CartState.getCart();
        
doSomethingWIthCurrentCart(cart);
    } catch (
Exception e) {
        
//caught an exception, all objects in Hibernate session have been evicted
        
foundException true;
    }
    
//re-establish a hibernate session with this order
    
if (foundException) {
        
cart orderService.findOrderById(cart.getId());
    }

   
//do something with fulfillment groups
}
 

Re: OrderImpl.fulfillmentGroups, no session or session was close

Posted: Tue Mar 05, 2013 6:44 pm
by pam
Thank you for your quick response. Just to update more ... I am working on broadleaf-framework1.0.0. Does your suggestion holds good for this version?

I'll try to modify as mentioned.

-Thanks

Re: OrderImpl.fulfillmentGroups, no session or session was close

Posted: Tue Mar 05, 2013 11:25 pm
by phillipuniverse
Do you mean 2.0.0? 1.0.0 is a VERY VERY old version of Broadleaf and we recommend using Broadleaf 2.0.x at a bare minimum (I believe the latest GA of the 2.0 line is 2.0.8). We released version 2.2.0-GA a few weeks ago so we recommend new sites to start with that version.

That being said, what I described about the exceptions and Hibernate sessions doesn't really have anything to do with Broadleaf but rather how Hibernate/JPA works.

Re: OrderImpl.fulfillmentGroups, no session or session was close

Posted: Wed Mar 06, 2013 12:07 pm
by pam
Thank you for the reply!

Is the latest version of blc (... found on github)
https://github.com/BroadleafCommerce/Br ... mmerce.git (
[maven-release-plugin] prepare release broadleaf-2.2.0-GA )

Could you explain a little more on "Integration" folder available in BroadleafCommerce.git
How is helpful?

-Thank you