'java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/util/JRLoader
I'm trying to call jasper report from Oracle ADF. I've include below jar files into the class path
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
Below is the code I'm using to call the report
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();
When i run the code i get below error:
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
Please help me resolve this error. am i missing a jar ?
Solution 1:[1]
Just restarted the JDeveloper and build the project and problem was solved. class files were missing from the class path.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Usman Riaz |
