public class RelatorioQtdAgendamentoDiaPerito extends HttpServlet {
private static final long serialVersionUID = -5506132259589301021L;
private Logger logger = Logger.getLogger(RelatorioQtdAgendamentoDiaPerito.class);
/**
*
* @param req
* @param res
* @throws javax.servlet.ServletException
* @throws java.io.IOException
*/
@SuppressWarnings("unchecked")
@Override
protected void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String sep = File.separator;
logger.info("Criando uma conexão ...");
DBConnectMySQL dao = null;
try {
dao = new DBConnectMySQL();
} catch (SQLException ex) {
logger.error(ex);
} catch (InstantiationException ex) {
logger.error(ex);
} catch (IllegalAccessException ex) {
logger.error(ex);
} catch (ClassNotFoundException ex) {
logger.error(ex);
}
logger.info("Conexão: " + dao.getConnection());
String path = getServletContext().getRealPath("/");
String pathJasper =
new StringBuilder()
.append(path)
.append("content")
.append(sep)
.append("reports")
.append(sep)
.toString();
String pathImages =
new StringBuilder()
.append(path)
.append("content")
.append(sep)
.append("images")
.append(sep)
.toString();
logger.info("Inserindo parametros no Map ...");
Map parametros = new HashMap();
parametros.put("SUBREPORT_DIR", pathJasper);
parametros.put("IMAGES_URI", pathImages);
parametros.put("DATAINICIAL", req.getParameter("dataInicial"));
parametros.put("DATAFINAL", req.getParameter("dataFinal"));
try {
logger.info("Caminho : " + path);
logger.info("CaminhoJasper: " + pathJasper);
logger.info("CaminhoImages: " + pathImages);
logger.info("Parametros : " + parametros);
logger.info(pathJasper + "RelatorioQtdAgendamentoDiaPeritoSAPE.pdf");
logger.info("Criando impressão ...");
JasperPrint impressao = JasperFillManager.fillReport(
new StringBuilder()
.append(pathJasper)
.append("RelatorioQtdAgendamentoDiaPeritoSAPE.jasper")
.toString(),
parametros,
dao.getConnection()
);
logger.info("Exportando o pdf ...");
JasperExportManager.exportReportToPdfFile(
impressao,
new StringBuilder()
.append(path)
.append("Relatorio")
.append(sep)
.append("RelatorioQtdAgendamentoDiaPeritoSAPE.pdf")
.toString()
);
logger.info("Redirecionando para o pdf ...");
res.sendRedirect("RelatorioQtdAgendamentoDiaPeritoSAPE.pdf");
} catch (Exception ex) {
logger.error("Erro ao gerar o relatorio: " + ex);
} finally {
if ( dao != null && dao.getConnection() != null) {
try {
dao.connectionClose();
} catch (SQLException ex) {
logger.error(ex);
}
}
}
}
}
log
[04/08/2008 04:46:40, 0] INFO [http-8080-1] (RelatorioQtdAgendamentoDiaPerito.java:44) ### Criando uma conexão ... ###
[04/08/2008 04:46:40,359] INFO [http-8080-1] (RelatorioQtdAgendamentoDiaPerito.java:57) ### Conexão: com.mysql.jdbc.Connection@9903f4 ###
[04/08/2008 04:46:40,359] INFO [http-8080-1] (RelatorioQtdAgendamentoDiaPerito.java:77) ### Inserindo parametros no Map ... ###
[04/08/2008 04:46:40,359] INFO [http-8080-1] (RelatorioQtdAgendamentoDiaPerito.java:85) ### Caminho : C:\Subversion\agenda\FONTES\agenda\build\web\ ###
[04/08/2008 04:46:40,359] INFO [http-8080-1] (RelatorioQtdAgendamentoDiaPerito.java:86) ### CaminhoJasper: C:\Subversion\agenda\FONTES\agenda\build\web\content\reports\ ###
[04/08/2008 04:46:40,375] INFO [http-8080-1] (RelatorioQtdAgendamentoDiaPerito.java:87) ### CaminhoImages: C:\Subversion\agenda\FONTES\agenda\build\web\content\images\ ###
[04/08/2008 04:46:40,375] INFO [http-8080-1] (RelatorioQtdAgendamentoDiaPerito.java:88) ### Parametros : {SUBREPORT_DIR=C:\Subversion\agenda\FONTES\agenda\build\web\content\reports\, IMAGES_URI=C:\Subversion\agenda\FONTES\agenda\build\web\content\images\, DATAINICIAL=04/08/2008, DATAFINAL=08/08/2008} ###
[04/08/2008 04:46:40,375] INFO [http-8080-1] (RelatorioQtdAgendamentoDiaPerito.java:89) ### C:\Subversion\agenda\FONTES\agenda\build\web\content\reports\RelatorioQtdAgendamentoDiaPeritoSAPE.pdf ###
[04/08/2008 04:46:41,484] INFO [http-8080-1] (RelatorioQtdAgendamentoDiaPerito.java:91) ### Criando impressão ... ###
[04/08/2008 04:46:41,594] ERROR [http-8080-1] (RelatorioQtdAgendamentoDiaPerito.java:115) ### Erro ao gerar o relatorio: java.lang.NullPointerException ###
esta dando um erro na funcao JasperFillManager.fillReport …
mas eu jah testei o caminho do jasper, esta apontando para o lugar certo
jah testei o hash, nem ele nem nenhum dos parametros esta nulo
e jah testei a conexao, sim … esta retornando uma conexao valida
no ireport o relatorio esta rodando, entao nao deve ser nenhum erro no relatorio e eu jah verifiquei o nome dos parametros, sao os mesmo na minha aplicacao

ajuda
[]'s
