Foros del Web » Programación para mayores de 30 ;) » Java »

Problema con JasperReport

Estas en el tema de Problema con JasperReport en el foro de Java en Foros del Web. buenas amigo del foro, estoy tratando de realizar un reporte java con mysql y jasperReport cuando trato de imprimir el reporte me genera un error ...
  #1 (permalink)  
Antiguo 01/04/2013, 14:17
 
Fecha de Ingreso: diciembre-2009
Mensajes: 137
Antigüedad: 14 años, 4 meses
Puntos: 4
Pregunta Problema con JasperReport

buenas amigo del foro, estoy tratando de realizar un reporte java con mysql y jasperReport cuando trato de imprimir el reporte me genera un error

Código PHP:
net.sf.jasperreport.egine.JRExceptionReporteFactura.jasper 
lo estuve analizando en la letra de color me muestra que no carga el reporte detoda manera adjunto el sgte codigo

String template="ReporteFactura.jasper";
JasperReport reporte=(JasperReport) JRLoader.loadObject(template);


la clase del reporte

Código PHP:
package beans
import java.sql.*; 
import java.util.HashMap
import java.util.Map
import net.sf.jasperreports.view.JRViewer.*; 
import net.sf.jasperreports.engine.*; 
import net.sf.jasperreports.engine.util.JRLoader
import net.sf.jasperreports.view.*; 
import net.sf.jasperreports.view.save.JRPdfSaveContributor.*; 
import net.sf.jasperreports.view.JRViewer.*; 
import net.sf.jasperreports.view.save.JRMultipleSheetsXlsSaveContributor.*; 
import java.util.logging.Level
import java.util.logging.Logger
import javax.swing.JOptionPane

/** 
 * 
 * @author GEOVANY 
 */ 
public class IniciarReporte 
        public static final 
String DRIVER="com.mysql.jdbc.Driver"
        public static final 
String RUTA="jdbc:mysql://localhost/Factura"
        public static final 
String USER="root"
        public static final 
String PASSWORD="root"
    public static 
Connection CONEXION
public 
void EjecutarReporte(int Facturathrows ClassNotFoundExceptionSQLException
     


    try 
    { 
            Class.
forName(DRIVER); 
            
CONEXION DriverManager.getConnection(RUTA,USER,PASSWORD); 
            
javax.swing.JOptionPane.showMessageDialog(null,"Conexion establecida");
             
String template="ReporteFactura.jasper"
            
JasperReport reporte=(JasperReportJRLoader.loadObject(template); 


            
Map param=new HashMap(); 

            
param.put("NUM_FACTURA"Factura); 
            
JasperPrint jasperprintJasperFillManager.fillReport(reporte,param,CONEXION);
             
JasperViewer visor=new JasperViewer(jasperprint,false); 
            
visor.setTitle("Geniz Reportes - GSF"); 
            
visor.setVisible(true); 
    } 
    catch(
Exception j
    { 
           
JOptionPane.showMessageDialog(null"Problemas al generar el reporte. \n Detalles: " j);
            
Logger.getLogger(IniciarReporte.class.getName()).log(Level.SEVEREnullj);
     } 


el botón imprimir

Código PHP:
private void cmdGenerarActionPerformed(java.awt.event.ActionEvent evt) {                                           
         
// TODO add your handling code here: 
       
try 
       { 
           
int id=Integer.parseInt(txtReporte.getText()); 
        
report.EjecutarReporte(id); 

       } catch (
ClassNotFoundException ex) { 
            
Logger.getLogger(ReporteFactura.class.getName()).log(Level.SEVEREnullex);
         } catch (
SQLException ex) { 
            
Logger.getLogger(ReporteFactura.class.getName()).log(Level.SEVEREnullex);
         } 
    } 
  #2 (permalink)  
Antiguo 02/04/2013, 15:31
 
Fecha de Ingreso: marzo-2011
Mensajes: 40
Antigüedad: 13 años
Puntos: 1
Sonrisa Respuesta: Problema con JasperReport

hola aimgo..

Pruebale bien si estás mandando la dirección correcta del reporte, de otra forma pruebale en ves de:

String template="ReporteFactura.jasper";

el otro tipo de extensión que generas al compilar el reporte

String template="ReporteFactura.jrxml";

si no tienes ese archivo puedes probar compilando el reporte antes de ubicarlo en el

JasperReport reporte = JasperCompileManager.compileReport(template);

pruebale eso..
espero que te ayude..
  #3 (permalink)  
Antiguo 02/04/2013, 15:42
 
Fecha de Ingreso: marzo-2011
Mensajes: 40
Antigüedad: 13 años
Puntos: 1
Respuesta: Problema con JasperReport

aki un kodigo que puedes Utilizar pruebale haber como te va..

public void financiamientoArticulo(Proform proform) {
try {
String master = System.getProperty("user.dir") + "/src/com/ph/report/FinanReport.jasper";

if (master == null) {
JOptionPane.showMessageDialog(null, "No se encuentra el archivo maestro", "ERROR REPORTE", JOptionPane.ERROR_MESSAGE);
return;
}

JasperReport masterReport = null;
try {
masterReport = (JasperReport) JRLoader.loadObject(master);
} catch (Exception jre) {
JOptionPane.showMessageDialog(null, "Problema al cargar archivo maestro", "ERROR REPORTE", JOptionPane.ERROR_MESSAGE);
System.out.println("Error: " + jre);
return;
}

Map parametro = new HashMap();

parametro.put("articulo", concatArticulo(proform.getItemProforms()));

JasperPrint jasperPrint = JasperFillManager.fillReport(masterReport, parametro, conn);

JasperViewer jviewer = new JasperViewer(jasperPrint, false);
JDialog vistaPrevia = new JDialog(jviewer, true);
vistaPrevia.setTitle("IMPRESIÓN DE ARTICULO FINANCIADO");
vistaPrevia.setContentPane(jviewer.getContentPane( ));
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
vistaPrevia.setBounds(100, 100, d.width - 200, d.height - 200);
vistaPrevia.setLocationRelativeTo(null);
vistaPrevia.validate();
vistaPrevia.setVisible(true);


} catch (Exception ex) {
System.out.println("errrrrrrrrrrrror: " + ex);
}
}
  #4 (permalink)  
Antiguo 04/04/2013, 22:32
 
Fecha de Ingreso: diciembre-2009
Mensajes: 137
Antigüedad: 14 años, 4 meses
Puntos: 4
Respuesta: Problema con JasperReport

Hola nuevamente volverte a molestar ahora me sale otro error
Código PHP:
Errornet.sf.jasperreports.engine.JRExceptionInvalid byte 1 of 1-byte UTF-8 sequence
te coloco el codigo

Código PHP:
public class IniciarReporte {
        public static final 
String DRIVER="com.mysql.jdbc.Driver";
        public static final 
String RUTA="jdbc:mysql://localhost/Factura";
        public static final 
String USER="root";
        public static final 
String PASSWORD="root";
    public static 
Connection CONEXION;
public 
void EjecutarReporte(String Factura)
    {
     
     try
    {
            Class.
forName(DRIVER);
            
CONEXION DriverManager.getConnection(RUTA,USER,PASSWORD);
          
javax.swing.JOptionPane.showMessageDialog(null,"Conexion establecida");

                     
String master System.getProperty("user.dir") + "/src/Reporte/ReporteFactura.jasper";
          if (
master == null) {
            
JOptionPane.showMessageDialog(null"No se encuentra el archivo maestro""ERROR REPORTE"JOptionPane.ERROR_MESSAGE);
            return;
            }
            
JasperReport masterReport null;
 try {
     
masterReport JasperCompileManager.compileReport(master);
 
//masterReport = (JasperReport) JRLoader.loadObject(master);
  
} catch (Exception jre) {
 
JOptionPane.showMessageDialog(null"Problema al cargar archivo maestro""ERROR REPORTE"JOptionPane.ERROR_MESSAGE);
 
System.out.println("Error: " jre);
 return;
 }
            
Map parametro = new HashMap();
            
parametro.put("NUM_FACTURA"Factura);
            
JasperPrint jasperPrint JasperFillManager.fillReport(masterReportparametroCONEXION);
            
JasperViewer jviewer = new JasperViewer(jasperPrintfalse);

          
          

    }
    catch(
Exception j)
    {
           
JOptionPane.showMessageDialog(null"Problemas al generar el reporte. \n Detalles: " j);
           
Logger.getLogger(IniciarReporte.class.getName()).log(Level.SEVEREnullj);
    }
}


Etiquetas: clase, jasperreport, string
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:14.