Classe não está gerando .jrprint (iReport)

1 resposta
M

Boa tarde.
A seguinte classe não está gerando o arquivo .jrprint:

public class VisualizarInscricoesReport {


		private static final Logger logger = Logger
				.getLogger(ProfessoresPorTitulacaoReport.class.getName());

		private static final String REPORT_DIRECTORY = "./reports";
		private static final String FILE_NAME = "VisualizarInscricoes"; 
		private static final String EXTENSION_NAME = ".jasper";
		private static final String EXTENSION_PRINT = ".jrprint";
		
		private static final String SAVE_PATH = REPORT_DIRECTORY + "/" + FILE_NAME ;

		public void exibir(String codTurma) throws InvocationTargetException{
			try{

				Map<String, Object> parameterMap = new HashMap<String, Object>();

				parameterMap.put("turmaParam", codTurma);
//				 logger.debug("Compilação");
				 //JasperCompileManager.compileReportToFile(SAVE_PATH);

				//ArrayList<Inscricao> inscricoes = 
				logger.debug("Preenchimento");
				JasperFillManager.fillReportToFile(SAVE_PATH  + EXTENSION_NAME,
						parameterMap, new JRBeanCollectionDataSource(
								getBeanCollection(codTurma)));

				logger.debug("Exibição");
				File file = new File(SAVE_PATH + EXTENSION_PRINT);
				JasperPrint jasperPrint;
				jasperPrint = (JasperPrint) JRLoader.loadObject(file);
				JasperViewer.viewReport(jasperPrint, false);
			}
			catch (JRException e) {

				JOptionPane.showMessageDialog(null, "Erro na compilação do relatório.");
				
				e.printStackTrace();
				
				logger.error("Relatório de avaliação por aluno.", e);
				JOptionPane.showMessageDialog(null,
						"Houve um erro durante a produção do relatório de avaliação: \n" + 
						e.getMessage(), "SCA",
						JOptionPane.ERROR_MESSAGE);
			}
		}
		

		@SuppressWarnings("finally")
		public static ArrayList<Inscricao> getBeanCollection(String codTurma){

			InscricaoRepositorio repositorio = RepositorioFabrica.
				getInscricaoRepositorio();
			ArrayList<Inscricao> inscricoes = null;
			try {
				inscricoes = repositorio.obterInscricoesPorTurma(codTurma);
			} catch (RepositorioException e) {
				JOptionPane.showMessageDialog(null, "Problema gerando relatório", 
						"Erro", JOptionPane.ERROR_MESSAGE);
			}
			finally{
				return inscricoes;//retornando duas inscrições
			}
		}
		


}
e está dando o seguinte erro:
net.sf.jasperreports.engine.JRException: java.io.FileNotFoundException: .\reports\VisualizarInscricoes.jrprint
	at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:84)
	at sca.app.VisualizarInscricoesReport.exibir(VisualizarInscricoesReport.java:59)
	at sca.app.VisualizarInscricoesPresenter.visualizarRelatorio(VisualizarInscricoesPresenter.java:191)
	at sca.app.VisualizarInscricoesPresenter.actionPerformed(VisualizarInscricoesPresenter.java:54)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: .\reports\VisualizarInscricoes.jrprint
	... 29 more
net.sf.jasperreports.engine.JRException: java.io.FileNotFoundException: .\reports\VisualizarInscricoes.jrprint
	at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:84)
	at sca.app.VisualizarInscricoesReport.exibir(VisualizarInscricoesReport.java:59)
	at sca.app.VisualizarInscricoesPresenter.visualizarRelatorio(VisualizarInscricoesPresenter.java:191)
	at sca.app.VisualizarInscricoesPresenter.actionPerformed(VisualizarInscricoesPresenter.java:54)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: .\reports\VisualizarInscricoes.jrprint
	... 29 more

Ah! O relatório tem conteúdo sim, pois o Arraylist inscricoes tem dois objetos inscricoes nele.
Não consigo entender o que está acontecendo.

1 Resposta

M

O mais estranho é que apenas um dos relatórios dá esse problema, o outro funciona normalmente.

Criado 4 de agosto de 2010
Ultima resposta 5 de ago. de 2010
Respostas 1
Participantes 1