我试图从Oracle ADF
调用jasper报告。我已将jar
个文件包含在类路径中
apache-ant-1.7.1.jar
groovy-all-2.0.1.jar
itext-2.1.7.js2.jar
jasperreports-6.1.0.jar
jasperreports-fonts-6.1.0.jar
jasperreports-javaflow-6.1.0.jar
jcommon-1.0.15.jar
jfreechart-1.0.12.jar
poi-3.10.1.jar
以下是我用来调用报告的代码
HttpServletResponse response = getResponse();
ServletOutputStream out = response.getOutputStream();
response.setHeader("Cache-Control", "max-age=0");
response.setContentType("application/pdf");
ServletContext context = getContext();
InputStream fs = new FileInputStream(new File(context.getRealPath("/reports/usman.jasper")));
JasperReport template = (JasperReport) JRLoader.loadObject(fs);
template.setWhenNoDataType(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL);
JasperPrint print;
print = JasperFillManager.fillReport(template, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JasperExportManager.exportReportToPdfStream(print, baos);
out.write(baos.toByteArray());
out.flush();
out.close();
FacesContext.getCurrentInstance().responseComplete();
当我运行代码时,我得到以下错误:
Caused by: java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/util/JRLoader
at Test.b2_action(Test.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:181)
at com.sun.el.parser.AstValue.invoke(AstValue.java:289)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:46)
... 74 more
请帮我解决此错误。我错过了一个罐子吗?
答案 0 :(得分:0)
刚刚重启JDeveloper并构建项目,问题解决了。类路径中缺少类文件。