• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

Unable to load uordisplay.Beandisplay due to a java.lang.InstantiationException exception


Hi.. , I am working with the display tag.
While i am using the decoraters with  the display tag i am getting the Exception
like: Unable to load uordisplay.Beandisplay due to a java.lang.InstantiationException exception

Can any body help me  to come out of this error.

        My package is:uordisplay.  
        My Bean is:Beandisplay
        My jsp page is:Uordisplay.

my code is:
---Beandisplay.java---
package uordisplay;
import org.displaytag.decorator.TableDecorator;
public class Beandisplay extends TableDecorator{

      private String img;

 /**
 * getter methods
 *
 */
 public Beandisplay(){
 }
 public Beandisplay(String img){
       this.img=img;

 }

 public String getImage(){
            Beandisplay lobj = (Beandisplay)getCurrentRowObject();      
            return "&lt;a href=\""+">"+ "<img src = '"+lobj.getImage()+"'  width='100' height='100'/>"+"</a>";

      }

/**
 *setter methods
 *
 */


 public void setImage(String img){
       this.img=img;
 }

}

<%@ taglib uri="/WEB-INF/displaytag.tld" prefix="display"%>
  <jsp:directive.page contentType="text/html; charset=UTF-8" />
<%@ page language = "java" import = "java.util.*" import = "uordisplay.Beandisplay"%>

  <center><h3>Auto-paging , Sorting of long lists</h3>
   
 <%       
      Beandisplay bd[] = new Beandisplay[7];
                bd[0] = new Beandisplay("img");
      bd[1] = new Beandisplay("def");
      bd[2] = new Beandisplay("ghi");
      bd[3] = new Beandisplay("jkl");
      bd[4] = new Beandisplay("mno");
      bd[5] = new Beandisplay("poq");
      bd[6] = new Beandisplay("rst");
      ArrayList list=new ArrayList();
      list.add(bd[0]);
                list.add(bd[1]);
                list.add(bd[2]);
                list.add(bd[3]);
                list.add(bd[4]);
                list.add(bd[5]);
                list.add(bd[6]);
      session.setAttribute("lister",list);
 %>
      <hr width=40%><br>
               <display:table  cellpadding="19" name="sessionScope.lister" pagesize="5" defaultsort="1"     defaultorder="ascending" decorator="uordisplay.Beandisplay">

            <display:column property="image" title="Car Image"       
      </display:table>
      </center>



While running  this on Tomcat I am getting the error :

javax.servlet.ServletException: Unable to load uordisplay.Beandisplay due to a java.lang.InstantiationException exception
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
      org.apache.jsp.Uordisplay_jsp._jspService(org.apache.jsp.Uordisplay_jsp:105)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

0
murali
Asked:
murali
1 Solution
 
fargoCommented:
Hi,

Check the get method

public String getImage(){
          Beandisplay lobj = (Beandisplay)getCurrentRowObject();    
          return "&lt;a href=\""+">"+ "<img src = '"+lobj.getImage()+"'  width='100' height='100'/>"+"</a>";

     }

is something getting null here?? The instantiation exception generally occurs when the instantiation of bean methods are getting null pointer.

regards,
fargo

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now