Jump to content
Changes to the Jaspersoft community edition download ×

urgent Help needed !!!!


Recommended Posts

By: Mohamed Kreifeur - moh2100

urgent Help needed !!!!

2003-08-18 12:35

Hi guys

I used to create reports with crystal report on windows platform. But right now, we are changing the platform, we are moving to open source (linux, mysql, tomcat and java,...)

I have proposed to my colleagues the Jasperreport as reporting tool to wotk with.

 

I am starting creationg some reports (japerreports) using iReport, and evry thing is ok until here.

 

When I try tyo use my report within java class I got errors like:

ang.NoClassDefFoundError: org/apache/commons/digester/Digester

at dori.jasper.engine.xml.JRXmlLoader.prepareDigester(JRXmlLoader.java:428)

at dori.jasper.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:370)

at dori.jasper.engine.xml.JRXmlLoader.load(JRXmlLoader.java:357)

at dori.jasper.engine.xml.JRXmlLoader.load(JRXmlLoader.java:337)

at dori.jasper.engine.xml.JRXmlLoader.load(JRXmlLoader.java:323)

at dori.jasper.engine.JasperManager.loadXmlDesign(JasperManager.java:1017)

at Test.main(Test.java:21)

Exception in thread "main"

 

Note that I'm using Ecplispe editor, and when I compile it's fine but when I run it i got that error.

 

Here is my code:

 

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;

import java.util.HashMap;

import java.util.Map;

 

import dori.jasper.engine.JRException;

import dori.jasper.engine.JasperManager;

import dori.jasper.engine.JasperPrint;

import dori.jasper.engine.JasperReport;

import dori.jasper.engine.design.JasperDesign;

 

class Test {

static Connection conn=null;

public static void main (String args[])

 

{ JasperDesign jsdDesignReport = new JasperDesign();

try

{ System.out.println("starting...");

jsdDesignReport =JasperManager.loadXmlDesign("c:\EnvJava\NewTimeSheet\Reports\projectLst.xml");

System.out.println("succefully loaded");

//JasperReport jsrReport = JasperManager.loadReport("reports\ProjectsLst.jasper");

JasperReport jsrReport = JasperManager.compileReport(jsdDesignReport);

System.out.println("succefully compiled");

conn=connect();

System.out.println("succefully connected");

Map param = new HashMap();

param.put("test", "hello this");

 

JasperPrint jspPrintRep = JasperManager.fillReport(jsrReport, param, conn);

System.out.println("succefully created");

JasperManager.printReportToPdfFile(jspPrintRep,"c:\EnvJava\NewTimeSheet\Reports\projectLst.xml");

System.out.println("succefully Compelted");

}catch(JRException jre){

System.out.println("Error :" +jre.getMessage());;

}

}

 

static public Connection connect()

{ Connection conn = null;

String error="";

try{

String sUrl = "jdbc:mysql://localhost/tsdb02";

String sDriver = "com.mysql.jdbc";

 

//Load & register the driver class

DriverManager.registerDriver(new com.mysql.jdbc.Driver());

 

//Make a connection to ODBC datasource

conn=DriverManager.getConnection(sUrl,"myname","xxx");

return conn;

}catch (SQLException see){

error="Could not connect to db";

System.out.println(error + ": " + see.getMessage());

}finally{ return conn;}

}

 

public void disconnect(Connection con)

{ String error="";

try{

if (con!=null) con.close();

}catch(SQLException sqle){

error="Unable to close the db connection";

System.out.println(error + ": " + sqle.getMessage());

}

}

}

 

and when I tried to run from command line a got another error :

Exception in thread "main" java.lang.NoClassDefFoundError: dori/jasper/engine/JR

Exception

 

I am very upset, could you help me ? please

I spent two days playing with classpath, pathes,...

and no solution

 

Any help is very appreciated

 

Moh

 

 

 

 

 

By: David Hardwick - dhardwick

RE: urgent Help needed !!!!

2003-08-18 13:11

#1) Others had problems running parts of this from within Eclipse, for now, to reduce the number of possibilities, just run this from the regular command line using ANT in MSDOS window

 

#2) Here is my lib directory...

C:JasperReportsjasperreports-0.5.0lib

ant-1.5.1.jar

bsh-1.2b6.jar

commons-beanutils-1.5.jar

commons-collections-2.1.jar

commons-digester-1.3.jar

commons-logging-1.0.2.jar

commons-logging-api-1.0.2.jar

hsqldb-1.61.jar

itext-0.96.jar

jakarta-poi-1.5.1-final-20020615.jar

LICENSE.ant.txt

LICENSE.bsh.txt

LICENSE.commons.txt

LICENSE.hsqldb.txt

LICENSE.itext.txt

LICENSE.poi.txt

LICENSE.xerces.txt

msbase.jar -- To connect to MSSQL2K

mssqlserver.jar -- To connect to MSSQL2K

msutil.jar -- To connect to MSSQL2K

servlet.jar

tools.jar -- Get from JRE lib

xercesImpl.jar

xmlParserAPIs.jar

 

#3) Working with ANT from the command-line (instead of within Eclipse until we get things working), see if you lib directory looks like mine and if you can run the build.xml for any of the examples.

 

#4) If you can run the examples, then which one did you use/mimic to create this one?

 

No worries, we'll figure this out. I've been using this tool and it's a good choice.

 

Regards,

 

daveh

 

 

 

 

By: Mohamed Kreifeur - moh2100

RE: urgent Help needed !!!!

2003-08-18 13:30

Thanks for aswering me so quikly

As I told you, I am using iReport-0.1.0 tool to create quikly my reports and then a I ll call them from my java code.

so in my lib directory of iReport-0.1.0 I have:

Directory of C:iReport-0.1.0lib

 

2003/08/18 04:26p <DIR> .

2003/08/18 04:26p <DIR> ..

2002/10/02 10:55a 717,666 ant.jar

2002/10/23 10:53p 110,681 commons-beanutils.jar

2002/10/21 11:36a 165,119 commons-collections.jar

2002/08/13 10:28a 93,881 commons-digester.jar

2002/09/26 10:20p 18,404 commons-logging-api.jar

2002/09/26 10:20p 26,388 commons-logging.jar

2002/05/10 10:04p 114 COPY.tools.jar.HERE.txt

2002/01/25 05:25p 180,902 hsqldb.jar

2003/01/14 03:17p 556,504 itext-0.96.jar

2002/06/15 07:43a 465,718 jakarta-poi-1.5.1-final-20020615.jar

2003/04/16 12:36a 425,541 jasperreports-0.4.6.jar

2003/08/18 04:26p 0 test.txt

2002/04/21 12:39a 4,824,546 tools.jar

2002/11/11 07:25p 834,966 xercesImpl.jar

2002/11/11 07:25p 83,089 xmlParserAPIs.jar

 

I am not familiar with ant, i am triny to do that right now, i have just installed ant-1.5.4

Could you give the build file content, plz to run jasper report

 

I think you th einformation u need, unless ask me and I will give what you want

 

thanks verrrrrrrry much for helping

(sorry for my english)

Moh

 

 

 

 

 

 

 

By: David Hardwick - dhardwick

RE: urgent Help needed !!!!

2003-08-18 14:18

Okay, for ANT, add the environment variable

 

ANT_HOME C:Program Filesjakarta-ant-1.4.1

 

so your system can find ant when you type 'ant' at the command line.

 

As for the build files, it's best to use the ones that come with the Jasper examples. Do you have the following directory?

 

C:JasperReportsjasperreports-0.5.0demosamples

 

specifically, we'll go into the shapes directory under the samples and run 'ant -buildfile build.xml' (ant uses build.xml by default but no harm in being explicit).

 

Okay, i need to take off for the day (i'm on the east coast), but keep hacking away at this specific example and get ant going ---which is very very easy to do, not a big deal and this will be something you use for ever...it's an awesome tool.

 

If you don't have that sample directory, then go to the jasper.sourceforge.net website and get the full zip with samples.

 

See you tomorrow,

daveh

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...