Uploaded image for project: 'Commons JCS'
  1. Commons JCS
  2. JCS-207

JCSAdmin.jsp throws ClassCastException java.util.LinkedList cannot be cast to [Lorg.apache.commons.jcs3.admin.CacheRegionInfo

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • jcs-3.0
    • jcs-3.1
    • Documentation
    • None

    Description

      The sample JCSAdmin.jsp on URL https://raw.githubusercontent.com/apache/commons-jcs/master/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdmin.jsp as referred to by https://commons.apache.org/proper/commons-jcs/faq.html

      Where can I get the admin jsp?
      You can download the admin jsp here .

      Throws exception when running:

      org.apache.jasper.JasperException: JBWEB004038: An exception occurred processing JSP page /JCSAdmin.jsp at line 254
      
      254
      
      251: 		Retrieve (key) <input type="text" name="key"> &nbsp;
      252: 		(region) <select name="cacheName">
      253: <%
      254:   CacheRegionInfo[] listSelect = (CacheRegionInfo[]) context.get( "cacheInfoRecords" );
      255:   for (CacheRegionInfo record : listSelect)
      256:   {
      257: 	%>
      
      
      Caused by: java.lang.ClassCastException: java.util.LinkedList cannot be cast to [Lorg.apache.commons.jcs3.admin.CacheRegionInfo;
      	at org.apache.jsp.JCSAdmin_jsp._jspService(JCSAdmin_jsp.java:389)
      	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:791)
      	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
      

      Solution

      3 places to fix:
      1)

       line 203 :
      <%
      	CacheElementInfo[] list = (CacheElementInfo[]) context.get( "elementInfoRecords" );
          for (CacheElementInfo element : list)
          {
      %>
      

      should be

      <%
          for (CacheElementInfo element : (java.util.List<CacheElementInfo>)context.get( "elementInfoRecords" ))
          {
      %>
      

      2)

       line 253
      <%
        CacheRegionInfo[] listSelect = (CacheRegionInfo[]) context.get( "cacheInfoRecords" );
        for (CacheRegionInfo record : listSelect)
        {
      

      should be

      <%
          for (CacheRegionInfo record : (java.util.List<CacheRegionInfo>)context.get( "cacheInfoRecords" ))
          {
      

      3)

       line 279
      <%
      	CacheRegionInfo[] list = (CacheRegionInfo[]) context.get( "cacheInfoRecords" );
          for (CacheRegionInfo record : listSelect)
          {
      %>
      

      should be

      <%
          for (CacheRegionInfo record : (java.util.List<CacheRegionInfo>)context.get( "cacheInfoRecords" ))
          {
      %>
      

      Also some styling nitpicking:

       line 229
          <pre>
          	<%=stats%>
          </pre>
      

      should be

      <pre>
      <%=stats%>
      </pre>
      

      (removes the spaces in the rendered page).

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            tv Thomas Vandahl
            levilevi321 Reval Pal
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment