JASPERREPORTS

Hi everyone

It磗 making me crazy

I have the following code which should work properly... but the damned doesn磘 do so

Why?

JasperDesign relatorioDefinicao =

JRXmlLoader.load("e:/relatorioMae.jrxml");

JasperReport relatorioCompilado = JasperCompileManager.compileReport(relatorioDefinicao);

JasperPrint relatorioPreenchido =

JasperFillManager.fillReport(rel1, parametros, fonte);

The code above simply loads a XML template from harddisk, compile it and finally populate it with data.

The problem is... I can磘 load the XML template. The path is correct and the file exists

what磗 wrong?

Any help is welcome!!!

[713 byte] By [charlles_cubaa] at [2007-10-3 3:34:41]
# 1

You don't understand how this forum works. You don't ask us what's wrong. You TELL us what's wrong. For example: copy and paste error messages that appear. Tell us what that code does instead of what you think it should do. You know, provide information. Then if it means anything to anybody here, you may get a suggestion about how to fix your problem.

DrClapa at 2007-7-14 21:29:16 > top of Java-index,Java Essentials,Java Programming...
# 2
maybe,String s = getClass().getResource("/").getFile();see where s points to, put the jrxml file there, thenFile f = new File( s + "your.jrxml" ); then load f
mchan0a at 2007-7-14 21:29:16 > top of Java-index,Java Essentials,Java Programming...
# 3

Ok thanks..

I磛e changed the original code so that it磗 easier to understand. Here is

import java.sql.*;

import java.util.HashMap;

import java.util.Map;

import java.util.Vector;

import net.sf.jasperreports.engine.design.*;

import net.sf.jasperreports.engine.xml.JRXmlLoader;

import net.sf.jasperreports.engine.*;

import net.sf.jasperreports.*;

import net.sf.jasperreports.view.*;

import net.*;

import net.sf.*;

public class teste {

public teste(){

try{

Class.forName("com.mysql.jdbc.Driver");

Connection conexao = DriverManager.getConnection("jdbc:mysql://localhost/testes", "root", "mcpmbaibta");

Statement instrucao = conexao.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

ResultSet resultado = instrucao.executeQuery("select * from mae");

/****************************************************************************************************************************/

/*The following code is responsible for generating the report*/

JRResultSetDataSource fonte = new JRResultSetDataSource(resultado);

/*The following line is the problem... it returns the following in Eclipse

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester*/

JasperDesign relatorioDefinicao = JRXmlLoader.load("e:/relatorioMae.jrxml");

JasperReport relatorioCompilado = JasperCompileManager.compileReport(relatorioDefinicao);

JasperPrint relatorioPreenchido = JasperFillManager.fillReport(relatorioCompilado, new HashMap(), fonte);

JasperViewer.viewReport(relatorioPreenchido,false);

}

catch(Exception excecao){

javax.swing.JOptionPane.showMessageDialog(null, excecao.getMessage(), "Detalhes do erro", 0);

}

}

public static void main(String[] args) {

new teste();

}

}

charlles_cubaa at 2007-7-14 21:29:16 > top of Java-index,Java Essentials,Java Programming...
# 4
download digester
mchan0a at 2007-7-14 21:29:16 > top of Java-index,Java Essentials,Java Programming...
# 5
you mean that I have to download another API besides JasperReportsWhat磗 the function of digester?
charlles_cubaa at 2007-7-14 21:29:16 > top of Java-index,Java Essentials,Java Programming...
# 6

Thanks everybody

As suggested I磀 have to download digester. I磛e searched for it on Sun

and found a tutorial describing how to integrate JasperReports into

NetBeans which is very similar to Eclipse integrating.

This tutorial says that as you use more advanced Jasper磗 features you must add other Jars that come along with the API... one the these Jars is digester ;D

I磎 going to try it and see what happens... but I磎 sure everything will be Ok

Thanks

charlles_cubaa at 2007-7-14 21:29:16 > top of Java-index,Java Essentials,Java Programming...