lepiyao Posted November 27, 2019 Share Posted November 27, 2019 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(); }[/code] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now