Boa tarde!
Tenho uma aplicação JavaFX na qual foi feito com Java 8. Estou migrando para o Java 11 e utilizando o gerenciador de dependências Maven. Até então tudo bem… Porém, quando vou imprimir um relatório é gerado uma exception: net.sf.jasperreports.engine.JRException: java.net.MalformedURLException.
Segue o código da classe em questão:
public void gerarRelatorio() throws JRException {
if (this.getDataInicial().getValue() != null && this.getDataFinal().getValue() != null) {
String situacao;
String relatorio;
String image = "br/com/controleasy/images/logotipo.png";
Date dateInicial = Date.from(this.getDataInicial().getValue().atStartOfDay(ZoneId.systemDefault()).toInstant());
Date dateFinal = Date.from(this.getDataFinal().getValue().atStartOfDay(ZoneId.systemDefault()).toInstant());
if (this.getRadioButtonPagamento().isSelected()) {
relatorio = "DespesasPorPagamento";
RelatoriosDAO.gerarRelatorioPorPeriodo(dateInicial, dateFinal, relatorio, image);
}
if (this.getRadioButtonVencimento().isSelected()) {
if (this.getRadioButtonAPagar().isSelected()) {
situacao = "A pagar";
relatorio = "DespesasPorVencimentoPorSituacao";
RelatoriosDAO.gerarRelatorioPorPeriodoPorSituacao(dateInicial, dateFinal, situacao, relatorio, image);
} else if (this.getRadioButtonPagas().isSelected()) {
situacao = "Pago";
relatorio = "DespesasPorVencimentoPorSituacao";
RelatoriosDAO.gerarRelatorioPorPeriodoPorSituacao(dateInicial, dateFinal, situacao, relatorio, image);
} else if (this.getRadioButtonTodos().isSelected()) {
relatorio = "DespesasPorVencimento";
RelatoriosDAO.gerarRelatorioPorPeriodo(dateInicial, dateFinal, relatorio, image);
}
}
} else {
Alerts.showAlert("Controleasy", "CAMPOS OBRIGATÓRIOS", "PREENCHA AS DATAS CORRETAMENTE", Alert.AlertType.INFORMATION);
}
public static void gerarRelatorioPorPeriodo(Date dataInicial, Date dataFinal, String relatorio, String image) throws JRException {
JasperPrint jasperPrint = null;
@SuppressWarnings("UnusedAssignment")
JasperReport jasperReport = null;
InputStream inputStream = Thread.currentThread().getClass().getResourceAsStream("/br/com/controleasy/relatorios/" + relatorio + ".jrxml");
Map params = new HashMap();
params.put("dataInicial", dataInicial);
params.put("dataFinal", dataFinal);
params.put("idUsuario", Integer.parseInt(MainScreenFXMLController.getId()));
params.put("image", image);
jasperReport = JasperCompileManager.compileReport(inputStream);
jasperPrint = JasperFillManager.fillReport(jasperReport, params, ConnectionFactory.getConnection());
JasperViewer viewer = new JasperViewer(jasperPrint, false);
viewer.setTitle("RELATÓRIO - DESPESAS POR PERÍODO");
viewer.setVisible(true);
viewer.toFront();
}
Acredito que a exception está ocorrendo aqui…
Na versão antiga o mesmo código funciona perfeitamente.
Agradeço desde já!


