How do I fix Runtime Error -java.lang.ClassNotFoundException: org.apache.commons.digester.Digester ?

0

I am using the the following dependendies :

<groupId>net.sf.jasperreports</groupId>
          <artifactId>jasperreports</artifactId>
          <version>6.7.1</version>
      </dependency>
      <dependency>
          <groupId>commons-digester</groupId>
          <artifactId>commons-digester</artifactId>
          <version>2.1</version>

My imports are as follows:

import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.JasperRunManager;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;

 conn = UCP.getConn();        
         JasperReport jasperReport = null; // jrxml
         JasperDesign jasperDesign = null;
         ObjectMapper mapper = new ObjectMapper(); 
         Map prameters = new HashMap ();         
         prameters = mapper.readValue(params, new TypeReference<Map<String, String>>(){});
         String rpt = Navigation.getUrl(report);          
         String realPath=getServletContext().getRealPath("/WEB-INF/"+rpt);
         jasperDesign = JRXmlLoader.load(realPath);         
         jasperReport = JasperCompileManager.compileReport(jasperDesign);      
         byte[] byteStream = JasperRunManager.runReportToPdf(jasperReport, prameters, conn);            
         return     byteStream;        

I get the following runtime error. 

Mar 16, 2019 9:40:24 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [com.servlets.JasperReports] in context with path [/InvestmentClub] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: org.apache.commons.digester.Digester
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1343)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1173)
    at com.servlets.JasperReports.jasperreport(JasperReports.java:98)
    at com.servlets.JasperReports.doPost(JasperReports.java:69)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

 

 

 

 

 

 

akrenitz_1's picture
Joined: Mar 16 2019 - 9:30am
Last seen: 7 months 4 weeks ago

4 Answers:

0

Try deleting common-digester setting. I don't have it in my pom.xml and not having problem.

i.e.

    <dependency>
        <groupId>net.sf.jasperreports</groupId>
        <artifactId>jasperreports</artifactId>
        <version>6.7.1</version>
    </dependency>

hozawa's picture
52292
Joined: Apr 24 2010 - 4:31pm
Last seen: 5 months 4 days ago
0

I didn't remove that object but am receiving a result. However the result is a blank pdf. :(  

akrenitz_1's picture
Joined: Mar 16 2019 - 9:30am
Last seen: 7 months 4 weeks ago
0

Blank pdf means you probably have an error in your jrxml or your code.

hozawa's picture
52292
Joined: Apr 24 2010 - 4:31pm
Last seen: 5 months 4 days ago
0

The report jrxml renders perfectly when viewed from the jasper server. It also renders whne call from a URL. So if you know how the servet should be written as well as on the client side that would help. 

akrenitz_1's picture
Joined: Mar 16 2019 - 9:30am
Last seen: 7 months 4 weeks ago
Feedback