Erro com Ireport

3 respostas
I

Pessoal, estou com um problema na geração de relatórios com Ireport via código Java.

As classes Java estão dentro de src e os .class dentro de bin.
Dentro de cada uma colquei uma classe que gera o relatório (na src o cod Java e na bin o .class), coloquei também o relatório que estou querendo gerar. Porém está me dizendo que não pode encontrar o .jasper.

O que pode estar acontecendo: Abaixo o erro:

[list]java.io.FileNotFoundException: TabPrecos.jasper

at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:75)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:515)

at interfaceGrafica.relatorios.Relatorios_Jasper.geraRelatorio(Relatorios_Jasper.java:95)

at interfaceGrafica.Principal$13.actionPerformed(Principal.java:299)

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.AbstractButton.doClick(Unknown Source)

at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)

at javax.swing.plaf.basic.BasicMenuItemUI$Handler.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)
NESTED BY :

java.io.FileNotFoundException: TabPrecos.jasper

at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:75)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:515)

at interfaceGrafica.relatorios.Relatorios_Jasper.geraRelatorio(Relatorios_Jasper.java:95)

at interfaceGrafica.Principal$13.actionPerformed(Principal.java:299)

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.AbstractButton.doClick(Unknown Source)

at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)

at javax.swing.plaf.basic.BasicMenuItemUI$Handler.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)
NESTED BY :

net.sf.jasperreports.engine.JRException: TabPrecos.jasper

at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:75)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:515)

at interfaceGrafica.relatorios.Relatorios_Jasper.geraRelatorio(Relatorios_Jasper.java:95)

at interfaceGrafica.Principal$13.actionPerformed(Principal.java:299)

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.AbstractButton.doClick(Unknown Source)

at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)

at javax.swing.plaf.basic.BasicMenuItemUI$Handler.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: TabPrecos.jasper

 31 more

net.sf.jasperreports.engine.JRException: Erro ao gerar o relatório.

TabPrecos.jasper

at interfaceGrafica.relatorios.Relatorios_Jasper.geraRelatorio(Relatorios_Jasper.java:101)

at interfaceGrafica.Principal$13.actionPerformed(Principal.java:299)

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.AbstractButton.doClick(Unknown Source)

at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)

at javax.swing.plaf.basic.BasicMenuItemUI$Handler.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)[/list]

Vale ressaltar que com no Ireport o relatório está sendo gerado sem nenhum problema.
Muito Grato

3 Respostas

Tomassoni

você esta tenho problemas com o caminho relativo…
tente usar

String curentPath = System.getProperty("user.dir") + "/"; //Aqui pega o diretório corrente
        curentPath = curentPath.replace('\','/');  //troca as barras
       String pathJasper = curentPath + "/relatorios/Erros/RelatorioErroPorProduto.jasper"; //Aqui vc coloca o resto da configuração do diretório

De um System.out no curentPath e veja o que ele pega, ai no String pathJasper vc coloca o resto do caminho…

paulo.ubuntu

é bem simples…
no Ireport manda ele compilar o relatorio…isso o fará gerar .Jasper

vá até a pasta onde ele gerou o .jasper…e leve-o até o diretorio onde vc esta esrevendo seu código java

Abraços

I

Tem um arquivo .jasper tanto no diretorio src quanto no bin (pois não sei de onde ele vai pegar, então pra garantir está nos dois).

Mandei imprimir o nome do diretorio, tá imprimindo corretamente:

relatorios/TabPrecos.

TabPrecos está dentro de relatórios que está dentro da pasta onde chamo gero o Relatorio.

Criado 26 de novembro de 2007
Ultima resposta 26 de nov. de 2007
Respostas 3
Participantes 3