title: JasperReports print pdf
body: <p>I'm trying to use JasperReports to generate a pdf invoice through a serlvet in my application. I installed the JasperReports plug-in through eclipse, and have been running using that, for some reason though my application will not print out my pdf. I'm getting a null pointer that I can't seem to fix.</p>
  
  <p>This is my code:</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse     response) throws ServletException, IOException {
      // TODO Auto-generated method stub
      //String type = request.getParameter("type");
      //int id = Integer.parseInt(request.getParameter("id"));
  
      String jrxmlFileName = "C:/res/jasper/OrderInvoice.jrxml";
      String jasperFileName = "C:/res/jasper/OrderInvoice.jasper";
      String pdfFileName = "C:/res/pdfs/invoice01.pdf";
  
      try
      {
          JasperCompileManager.compileReportToFile(jrxmlFileName, jasperFileName);
  
           // String dbUrl = props.getProperty("jdbc.url");
             String dbUrl = "jdbc:mariadb://localhost:3306/*MY DATABASE*";
             // String dbDriver = props.getProperty("jdbc.driver");
             String dbDriver = "org.mariadb.jdbc.Driver";
             // String dbUname = props.getProperty("db.username");
             String dbUname = "*MY DATABASE USERNAME*";
             // String dbPwd = props.getProperty("db.password");
             String dbPwd = "*MY DATABASE PASSWORD*";
  
             // Load the JDBC driver
             Class.forName(dbDriver);
             // Get the connection
             Connection conn = DriverManager.getConnection(dbUrl, dbUname, dbPwd);
  
          HashMap&lt;String, Object&gt; hm = new HashMap&lt;String, Object&gt;();
          hm.put("OrderId", 1);
          JasperPrint jprint = JasperFillManager.fillReport(jasperFileName, hm, conn).setJasperReportsContext(jasperReportsContext);;
  
          JasperExportManager.exportReportToPdfFile(jprint, pdfFileName);
          conn.close();
      } catch (JRException e)
      {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (SQLException e)
      {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (ClassNotFoundException e)
      {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  </code></pre>
  
  <p>The report I am generating takes in one parameter, the Order Id of a particular order to create a invoice for. That's what is set in the HashMap. I found this code on a JasperReports page.</p>
  
  <p>This is the null pointer I've been receiving:</p>
  
  <pre><code>java.lang.NullPointerException
  at com.jaspersoft.studio.debug.TraceGovernor.setup(TraceGovernor.java:111)
  at com.jaspersoft.studio.debug.TraceGovernor.initMaps(TraceGovernor.java:118)
  at com.jaspersoft.studio.debug.TraceGovernor.beforeReportInit(TraceGovernor.java:162)
  at net.sf.jasperreports.engine.fill.JRFillDatasetScriptlet.beforeReportInit(JRFillDatasetScriptlet.java:74)
  at net.sf.jasperreports.engine.JRAbstractScriptlet.callBeforeReportInit(JRAbstractScriptlet.java:176)
  at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:236)
  at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:115)
  at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:582)
  at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:396)
  at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:90)
  at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:286)
  at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:759)
  at exchange.InvoiceExchange.doGet(InvoiceExchange.java:68)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
  at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1681)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
  at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
  at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
  at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
  at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:466)
  at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:169)
  at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
  at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
  at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
  at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
  at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
  at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
  at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
  at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
  at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
  at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:526)
  at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
  at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
  at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
  at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
  at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
  at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
  at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>Ive found this page <a href="https://stackoverflow.com/questions/38511505/how-can-i-fix-java-lang-nullpointerexception-caused-by-tracegovernor-in-jasperso">How can I fix java.lang.NullPointerException caused by TraceGovernor in Jaspersoft studio plugin?</a>
  But I am unable to complete the solution he found. </p>
  
  <p>I've also tried a few different sample codes online, none of which have worked.</p>