Announcement Announcement Module
Collapse
No announcement yet.
JasperReport Nullpointer exception in Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JasperReport Nullpointer exception in

    Hai all

    I am trying to show a jasper report through COntroller instead of what is followed in the CVS.when iam using the report i am getting following error


    java.lang.NullPointerException
    org.springframework.web.servlet.view.jasperreports .AbstractJasperReportsView.populateHeaders(Abstrac tJasperReportsView.java:561)
    org.springframework.web.servlet.view.jasperreports .AbstractJasperReportsView.renderMergedOutputModel (AbstractJasperReportsView.java:497)
    org.springframework.web.servlet.view.AbstractView. render(AbstractView.java:250)
    org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:928)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:705)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:625)
    org.springframework.web.servlet.FrameworkServlet.s erviceWrapper(FrameworkServlet.java:386)
    org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:346)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:689)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

    mycode is

    ReportController2 implements Controller{
    protected final Log logger=LogFactory.getLog(getClass());
    private DataSource datasource;
    JasperReportsPdfView reportView=new JasperReportsPdfView();
    public ModelAndView handleRequest(HttpServletRequest request,HttpServletResponse response)
    {
    //Set the source jasper file
    reportView.setUrl("/WEB-INF/reports/Springreport.jasper");
    //set the jdbcdatasource
    reportView.setJdbcDataSource(datasource);
    //set the exp params for the html format
    Map expparams=new HashMap();
    expparams.put("net.sf.jasperreports.engine.export. JRHtmlExporterParameter.IMAGES_URI","/WEB-INF/reports/images");
    reportView.setExporterParameters(expparams);

    logger.info("The class is"+reportView.getClass());

    Map model=new HashMap();
    model.put("format",".pdf");
    model.put("Springparameter","Good Try");


    return new ModelAndView(reportView,model);
    }

    public void setDataSource(DataSource ds)
    {
    logger.info("The datasource in reportview is"+ds);
    this.datasource =ds;
    }


    Help pls
    Aniesh U.K

  • #2
    Aniesh,

    Check out the posting here on JIRA [http://opensource2.atlassian.com/pro...owse/SPR-1241] for more details on this.

    In 1.3 you will be able to use the JasperReportsViewResolver. You can manually construct a report instance and the code is shown in the JIRA post.

    Rob

    Comment


    • #3
      Hai robh

      Thanks for u kind reply.I got an idea.I think i was missing applicationContext in mycode.Let me try with that and report to u.


      Thanks
      Aniesh U.K

      Comment

      Working...
      X