Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8908357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:09:24+00:00 2026-06-15T03:09:24+00:00

I have a jsp to which a servlet passes an object (a collection). the

  • 0

I have a jsp to which a servlet passes an object (a collection). the object becomes a session attribute:

session.setAttribute("groupList", request.getAttribute("groups"));

I use a tag to recursively generate a menu from the content of this collection:

<c:forEach items="${groupList}" var="emp" begin="0" end="10">
        <tag:menuRenderer groupList="${groupList}" />
    </c:forEach>

Those items in the are objects of a class Group. This class contains a list of subgroups subGroups and a list of objects of a different class called students.

My problem is that I can not access this list of students in my tag.
This is the tag code:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib tagdir="/WEB-INF/tags" prefix="tag"%>
<%@ taglib uri='http://java.sun.com/jsp/jstl/functions' prefix='fn' %>
<%@ attribute name="groupList" type="java.util.Collection"%>

<c:forEach var="item" items="${groupList}">

    <li><c:out value="${item.name}" /></li>
    <br>

    <!-- ##### here #### -->
    <li><c:out value="${fn:length(item.students)}" />   <!-- #### doesn't work ####-->
    <li><c:out value="${fn:length(item.subGroups)}" />  <!-- ####     works    #### -->

    <ul>
        <tag:menuRenderer groupList="${item.subGroups}" />
    </ul>
</c:forEach>

The call to item.students causes an exception, but I can’t see what exactly it is because the strack trace only shows where the exception is thrown in the jsp:

SEVERE: Servlet.service() for servlet jsp threw exception
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
    at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:186)
    at org.hibernate.collection.internal.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:137)
    at org.hibernate.collection.internal.PersistentSet.size(PersistentSet.java:156)
    at org.apache.taglibs.standard.functions.Functions.length(Functions.java:202)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.el.parser.AstFunction.getValue(AstFunction.java:112)
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
    at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:986)
    at org.apache.jsp.tag.webmenuRenderer_tag._jspx_meth_c_005fout_005f1(webmenuRenderer_tag.java:202)
    at org.apache.jsp.tag.webmenuRenderer_tag._jspx_meth_c_005fforEach_005f0(webmenuRenderer_tag.java:143)
    at org.apache.jsp.tag.webmenuRenderer_tag.doTag(webmenuRenderer_tag.java:97)
    at org.apache.jsp.tag.webmenuRenderer_tag._jspx_meth_tag_005fmenuRenderer_005f0(webmenuRenderer_tag.java:240)
    at org.apache.jsp.tag.webmenuRenderer_tag._jspx_meth_c_005fforEach_005f0(webmenuRenderer_tag.java:153)
    at org.apache.jsp.tag.webmenuRenderer_tag.doTag(webmenuRenderer_tag.java:97)
    at org.apache.jsp.testMenu2_jsp._jspx_meth_tag_005fmenuRenderer_005f0(testMenu2_jsp.java:173)
    at org.apache.jsp.testMenu2_jsp._jspx_meth_c_005fforEach_005f0(testMenu2_jsp.java:138)
    at org.apache.jsp.testMenu2_jsp._jspService(testMenu2_jsp.java:90)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
    at myPackage.controller.ControllerServlet.doGet(ControllerServlet.java:38)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Nov 29, 2012 5:50:36 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Hello] in context with path [/HibernateTest] threw exception [An exception occurred processing JSP page /testMenu2.jsp at line 19

16: 
17: <ul>
18:     <c:forEach items="${treeMap}" var="emp" begin="0" end="10">
19:         <tag:menuRenderer treeMap="${treeMap}" />
20:     </c:forEach>
21: </ul>
22: 


Stacktrace:] with root cause
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
    at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:186)
    at org.hibernate.collection.internal.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:137)
    at org.hibernate.collection.internal.PersistentSet.size(PersistentSet.java:156)
    at org.apache.taglibs.standard.functions.Functions.length(Functions.java:202)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.el.parser.AstFunction.getValue(AstFunction.java:112)
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
    at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:986)
    at org.apache.jsp.tag.webmenuRenderer_tag._jspx_meth_c_005fout_005f1(webmenuRenderer_tag.java:202)
    at org.apache.jsp.tag.webmenuRenderer_tag._jspx_meth_c_005fforEach_005f0(webmenuRenderer_tag.java:143)
    at org.apache.jsp.tag.webmenuRenderer_tag.doTag(webmenuRenderer_tag.java:97)
    at org.apache.jsp.tag.webmenuRenderer_tag._jspx_meth_tag_005fmenuRenderer_005f0(webmenuRenderer_tag.java:240)
    at org.apache.jsp.tag.webmenuRenderer_tag._jspx_meth_c_005fforEach_005f0(webmenuRenderer_tag.java:153)
    at org.apache.jsp.tag.webmenuRenderer_tag.doTag(webmenuRenderer_tag.java:97)
    at org.apache.jsp.testMenu2_jsp._jspx_meth_tag_005fmenuRenderer_005f0(testMenu2_jsp.java:173)
    at org.apache.jsp.testMenu2_jsp._jspx_meth_c_005fforEach_005f0(testMenu2_jsp.java:138)
    at org.apache.jsp.testMenu2_jsp._jspService(testMenu2_jsp.java:90)
    // and so on

I’d be very happy if somebody could tell me why this doesn’t work!
Do I have to import something?

Thanks in advance! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:09:25+00:00Added an answer on June 15, 2026 at 3:09 am

    The students collection probably comes from a lazy one-to-many relationship and you’re trying to access it in the web tier in which no Hibernate session is active. You should declare the relationship as EAGER in order to have the collection loaded at query time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a servlet which takes us to an existing jsp, say home.jsp. This
I have a jsp tag which takes a javax.el.MethodExpression as attribute: <%@ attribute name="action"
I have a JSP file Signup.jsp which submits to UserDetails servlet which inserts the
I have a jsp/servlet based web app. I have a button Clean Up which
The JSP from which I receive the request may have more then one form
I have one Servlet name EditEvent and one JSP which contains two forms. One
I have a servlet and JSP which share JavaBean instances - the servlet initialises
I have a web application code which uses jsp, servlet and ejb. I created
I have a JSP page which display a list from servlet, it has a
I have a JSP page which passes the HttpServletRequest and HttpServletResponse to a Java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.