Jasper Report não gera relatório no arquivo.jar

1 resposta
jards

Olá,

meu projeto gera relatórios e manda direto para impressora usando o Jasper Report. Funciona muito bem quando estou usando o NetBeans. Quando construo arquivo .jar e tento executá-lo, o programa não imprimi mais o relatório.
Tentei visualizar mais tambem não conseguir.

OBS: A Classe que chama o relatorio estar no mesmo diretorio dos reslatorios .jasper

Classe que chama o Relatorio:
package relatorios;

import banco.ConectaBancodeDados;
import idao.idaoRelatorios;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;

/**
 *
 * @author Administrador
 */
public class Relatorios {
    Map parametros = new HashMap();
    JasperPrint jasperPrint;
    idaoRelatorios idaoRelatorios = new idaoRelatorios();
    private final String nomeAplicacao = "CADERNO DE QUESTÕES";
    private final InputStream formularioPesquisa = getClass().getResourceAsStream("formularioPesquisa.jasper");

    public void formularioPesquisa(int codCaderno, int quantImpressoes) {
        try {
            parametros.put("nomeAplicacao", nomeAplicacao);
            parametros.put("codCaderno", codCaderno);

            for(int i=0; i < quantImpressoes; i++){
                parametros.remove("numeroFormulario");
                parametros.put("numeroFormulario", idaoRelatorios.getSeguencial());
                jasperPrint = JasperFillManager.fillReport(formularioPesquisa, parametros, ConectaBancodeDados.getConnection());
                JasperViewer.viewReport(jasperPrint);
            }
            
            JOptionPane.showMessageDialog(null, "Impressão Realizada com Sucesso!");

        } catch (JRException ex) {
            Logger.getLogger(Relatorios.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

ao rodar o .jar pelo shell do DOS apresenta o seguinte erro:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at java.io.ObjectInputStream$PeekInputStream.read(Unknown Source)
        at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
        at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Sour
ce)
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        at java.io.ObjectInputStream.<init>(Unknown Source)
        at net.sf.jasperreports.engine.util.ContextClassLoaderObjectInputStream.
<init>(ContextClassLoaderObjectInputStream.java:57)
        at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:19
5)
        at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillMa
nager.java:361)
        at relatorios.Relatorios.formularioPesquisa(Relatorios.java:40)
        at frames.JInternalFrameImprimirFormularioPesquisa.jButtonImprimirAction
Performed(JInternalFrameImprimirFormularioPesquisa.java:114)
        at frames.JInternalFrameImprimirFormularioPesquisa.access$000(JInternalF
rameImprimirFormularioPesquisa.java:21)
        at frames.JInternalFrameImprimirFormularioPesquisa$1.actionPerformed(JIn
ternalFrameImprimirFormularioPesquisa.java:63)
        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 Sour
ce)
        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)

Alguém pode me ajudar com esse problema?
Obrigado...

1 Resposta

jards

Ae galera…

Solucionei o problema…

Criado 8 de abril de 2009
Ultima resposta 8 de abr. de 2009
Respostas 1
Participantes 1