Getting NestedNullException

Hi,
I'm always getting this exception 

'javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/commons/beanutils/NestedNullException'

and the root cause

'java.lang.ClassNotFoundException: org.apache.commons.beanutils.NestedNullException'

, everytime i run my function on my backing bean.
And on the Console Log on my eclipse, it shown that 'JRBeanCollectionDataSource' that cause this exception.

I'm using a simple commandButton (with ajax="false") in my.xhtml file to trigger the function on my backing bean.
Any solution for this ?

 

public void printPDF() throws JRException, IOException {
 
        List<PersonTest> dataSource = new ArrayList<>();
        dataSource.add(new PersonTest("Tester","One"));
        dataSource.add(new PersonTest("Asdsa","Two"));
        dataSource.add(new PersonTest("Wasdsaw","Three"));
        String filename = "names.pdf";
 
        String jasperPath ="/resources/report/report.jasper";
        this.pdf(null, jasperPath, dataSource, filename);
 
    }
 
    public void pdf(Map<String, Object> params, String jasperPath, List<?> dataSource, String fileName) throws JRException, IOException {
        String relativeWebPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath(jasperPath);
        File file = new File(relativeWebPath);
 
        JRBeanCollectionDataSource source = new JRBeanCollectionDataSource(dataSource, false);
 
        JasperPrint print = JasperFillManager.fillReport(file.getPath(), params, source);        
        HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
        response.addHeader("Content-disposition", "attatchment;filename=" + fileName);
 
        ServletOutputStream stream = response.getOutputStream();
        JasperExportManager.exportReportToPdfStream(print, stream);
        FacesContext.getCurrentInstance().responseComplete();
    }

lepiyao's picture
Joined: Nov 25 2019 - 11:05pm
Last seen: 2 years 6 months ago

0 Answers:

No answers yet
Feedback