reset password
Author Message
rishiskeshav91
Posts: 7
Posted 19:04 Mar 04, 2015 |

Hello professor,

I am getting the following error while rendering the JSP page.

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

I debuged my controller part to confirm whether SecurityUtils.getUser() is returning user object and I am getting the object. The values are being passed to the JSP correctly. When I try to access it in JSP, I am getting this error. 

May I know what is my mistake here ? 

Thanks 

rishiskeshav91
Posts: 7
Posted 19:49 Mar 04, 2015 |

I could solve that issue.

I just called the userDao method again to get the user object like 

User user = SecurityUtils.getUser();

model.put("runways", userDao.getUser(user.getId()).getPlan().getRunway());

But I want to understand what was the need to do it like above. Why other way wont work ?

Thanks,

cysun
Posts: 2935
Posted 21:31 Mar 04, 2015 |

You probably used a User object saved in session. Read the explanation about detached object here.