We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

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

murali
murali asked
on
Medium Priority
552 Views
Last Modified: 2010-08-05

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)

Comment
Watch Question

Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.