Page 1 of 2 12 LastLast
Results 1 to 20 of 25
  1. #1
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default Jasperreports problem

    Java Code:
    	private JasperPrint generateReport() {
    	JasperPrint jasperPrint = null;
    		try {
    			JasperCompileManager.compileReportToFile("actreport.jrxml");
    			jasperPrint = JasperFillManager.fillReport("actreport.jasper", new HashMap(), new JRTableModelDataSource(qtm));
    			HashMap parameterMap = new HashMap();
    			parameterMap.put("nik", new Integer(750));
    		}
    		catch (JRException e) {
    			e.printStackTrace();
    		}
    		return jasperPrint;
    		}
    It gives me this error :
    Java Code:
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
    	at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:85)
    the line mentioned is :
    JasperCompileManager.compileReportToFile("actrepor t.jrxml");

    And here's the CompileManager.java :
    Source not found
    The JAR file D:\Java ext library\jasperreports-3.7.5.jar has no source attachment.

    Anyone know how to fix this ? or maybe where to get org/apache/commons/digester/Digester ?


    Thanks in advance,
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

  2. #2
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default Re: Jasperreports problem

    Is there someone who ever use jasperreports that can share some light here ?
    I've been trying some jasperreports jar (even the latest 4.1.1 and 4.1.2), and all still give me that error...also I've checked the file, some actually have commons-digester jar file inside, not org.apache one though.


    Thanks in advance,
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

  3. #3
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    4

    Default Re: Jasperreports problem

    What are the libraries that you have added on your project that is relative to jasper report?
    What is the version of your jasper report?
    Did you already add spring.jar on your project library? As I know, spring.jar is needed when linking java and jasper report because it uses XML...

  4. #4
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default Re: Jasperreports problem

    Well, thanks for replying.

    I'm still new to this so I first add jasperwave drop-ins and make the jrxml template...so far it's running fine on preview.
    Then I get jasperreports API, I took several of them from JasperReports Library | Download JasperReports Library software for free at SourceForge.net
    Some are :
    jasperreports-4.1.1-project.zip
    jasperreports-4.1.2.jar
    jasperreports-3.7.5.jar
    jasperreports-3.5.1-applet.jar.zip

    And no, I don't know if spring.jar is needed, but from the error I put some more like :
    commons-digester-2.0.jar
    commons-collections-3.2.1-bin.zip
    commons-collections-3.2.1-src.zip

    So I need spring.jar for this ?
    I'll try to get it then.

    Thanks,
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

  5. #5
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default Re: Jasperreports problem

    spring.jar was downloaded and placed in project build path and problem persists.

    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
    at net.sf.jasperreports.engine.JasperCompileManager.c ompileReportToFile(JasperCompileManager.java:85)

    if I click JasperCompileManager.java:85 it'll pop up an error message :

    85 is not a valid line number in net.sf.jasperreports.engine.JasperCompileManager

    and in Class File Editor will show :

    Source not found
    The source attachment does not contain the source for the file JasperCompileManager.class.
    You can change the source attachment by clicking Change Attached Source below

    and so following it is a button and lots of lines.
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

  6. #6
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default Re: Jasperreports problem

    BTW, why spring is needed ?
    Sorry, kinda confused...
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

  7. #7
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default Re: Jasperreports problem

    OK, it's done...I can make it open the jasperviewer...but now problem is...(may sound stupid)...how to set a relative path to the file ?
    I have the jrxml file in the same package (same folder) with my java files, so I wrote it as :

    JasperCompileManager.compileReportToFile("actrepor t.jrxml");

    but I get this error :
    net.sf.jasperreports.engine.JRException: java.io.FileNotFoundException: actreport.jrxml (The system cannot find the file specified)


    Thanks in advance,
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

  8. #8
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    4

    Default Re: Jasperreports problem

    It says that it cannot see the file you have given.
    Try to input the full path of your report.

    Can you show your code on how you try to view the report.

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Jasperreports problem

    Quote Originally Posted by Levian View Post
    if I click JasperCompileManager.java:85 it'll pop up an error message :

    85 is not a valid line number in net.sf.jasperreports.engine.JasperCompileManager

    and in Class File Editor will show :

    Source not found
    The source attachment does not contain the source for the file JasperCompileManager.class.
    You can change the source attachment by clicking Change Attached Source below

    and so following it is a button and lots of lines.
    This is caused by this:

    Quote Originally Posted by Levian View Post
    Well, thanks for replying.

    I'm still new to this so I first add jasperwave drop-ins and make the jrxml template...so far it's running fine on preview.
    Then I get jasperreports API, I took several of them from JasperReports Library | Download JasperReports Library software for free at SourceForge.net
    Some are :
    jasperreports-4.1.1-project.zip
    jasperreports-4.1.2.jar
    jasperreports-3.7.5.jar
    jasperreports-3.5.1-applet.jar.zip
    I hope you haven't stuck all those versions into your application, as it'll be lucky dip as to which one the JVM is going to pick to run...which may be different to the one the compiler picked to compile with.

    Choose a version (usually the latest stable build if it's a new project) and stick with that.

    Each version should also tell you in the docs what its dependencies are (that is what other libraries it needs to run).

  10. #10
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default Re: Jasperreports problem

    Quote Originally Posted by Tolls View Post
    I hope you haven't stuck all those versions into your application, as it'll be lucky dip as to which one the JVM is going to pick to run...which may be different to the one the compiler picked to compile with.
    No, I pick only 4.1.1, no idea on the stability part though, but it's not the latest so should be fine I think.

    I use the full path as suggested, D:/...../actreport.jrxml and I think this path part is so far solved, but I prefer to use relative path than full path to be honest.
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

  11. #11
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default Re: Jasperreports problem

    Java Code:
    	private void displayReport() {
    		JasperPrint jasperPrint = generateReport();
    		JasperViewer jasperViewer = new JasperViewer(jasperPrint);
    		jasperViewer.setVisible(true);
    	}
    	
    	private JasperPrint generateReport() {
    	JasperPrint jasperPrint = null;
    		try {
    			JasperCompileManager.compileReportToFile("D:/Documents and Settings/Administrator/workspace/TnD2/src/TnD2/actreport.jrxml");
    			jasperPrint = JasperFillManager.fillReport("D:/Documents and Settings/Administrator/workspace/TnD2/src/TnD2/actreport.jrxml.jasper", new HashMap<String, Object>());
    			HashMap<String, Character> parameterMap = new HashMap<String, Character>();
    			parameterMap.put("nik", new Character((char) 6));
    		}
    		catch (JRException e) {
    			e.printStackTrace();
    		}
    		return jasperPrint;
    		}
    
    		JButton btnPrint = new JButton("Print");
    		btnPrint.setBounds(386, 174, 100, 23);
    		btnPrint.setMnemonic(KeyEvent.VK_P);
    		contentPane.add(btnPrint);
    //		btnPrint.setEnabled(false);
    		btnPrint.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent PrintReport) {
    				displayReport();
    			}
    		});
    This now gives me :
    Sep 14, 2011 8:05:09 AM net.sf.jasperreports.engine.query.JRJdbcQueryExecu ter <init>
    WARNING: The supplied java.sql.Connection object is null.

    It's weird cause when I go on the preview, I'll be given a box to enter the parameter value (nik) and once I enter the value, I can see the report exactly as it is with the data intact. So I think the problem is in the above code and not in my jrxml file part.
    However as the jrxml part, it is :
    Java Code:
    	<parameter name="NIK" class="java.lang.String"/>
    	<queryString language="SQL">
    		<![CDATA[SELECT
    	Name, NIK, Act, ActY, Sh, KUK, actinfo
    FROM
    	  viewact
    WHERE
    	NIK = $P{NIK}
    ORDER BY
    	Acting_Year, Acting]]>
    	</queryString>
    	<field name="Name" class="java.lang.String"/>
    	<field name="NIK" class="java.lang.String"/>
    	<field name="Act" class="java.lang.String"/>
    	<field name="ActY" class="java.sql.Timestamp"/>
    	<field name="Sh" class="java.lang.String"/>
    	<field name="KUK" class="java.lang.String"/>
    	<field name="actinfo" class="java.lang.String"/>

    Thanks in advance,
    Last edited by Levian; 09-14-2011 at 03:19 AM.
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

  12. #12
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    4

    Default Re: Jasperreports problem

    Your passing null value on your parameter.
    Java Code:
    try {
        .....
        jasperPrint = JasperFillManager.fillReport("D:/Documents and Settings/Administrator/workspace/TnD2/src/TnD2/actreport.jrxml.jasper", [b]new HashMap<String, Object>()[/b]);
        }
    Use your HashMap parameterMap in filling "nik".
    Java Code:
    try {
        .....
        //Note that I move HashMap
        HashMap<String, Character> parameterMap = new HashMap<String, Character>();
        parameterMap.put("nik", new Character((char) 6));
        //Pass parameterMap
        jasperPrint = JasperFillManager.fillReport("D:/Documents and Settings/Administrator/workspace/TnD2/src/TnD2/actreport.jrxml.jasper", [b]parameterMap[/b]);
       }

  13. #13
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default Re: Jasperreports problem

    I tried that already and when I put it that way, it will give compilation error

    Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
    The method fillReport(String, Map<String,Object>) in the type JasperFillManager is not applicable for the arguments (String, HashMap<String,Character>)


    Thanks in advance,
    Last edited by Levian; 09-14-2011 at 05:55 AM.
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

  14. #14
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    4

    Default Re: Jasperreports problem

    Have you tried to change character to string?

  15. #15
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default Re: Jasperreports problem

    Quote Originally Posted by mine0926 View Post
    Have you tried to change character to string?
    I'm not sure I understand.
    Can you explain a bit of what you mean by that ?
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

  16. #16
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Jasperreports problem

    Since it expects Map<String, Object> then give it Map<String, Object>.
    And is nik upper or lower case?
    In your xml above you have it as NIK, but in your code you have put it in as nik.

  17. #17
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default Re: Jasperreports problem

    OK, I've been through my jrxml file and I can't see any connection setting there, seems only design parts with <band> and the SQL query part as written above.
    Should there be connection setting in the jrxml itself ?

    Thanks in advance,
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

  18. #18
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Jasperreports problem

    No idea.
    Read the Jasper reports documentation, since that should tell you exactly what is needed in that file, and where you need to supply the connection information.

  19. #19
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default Re: Jasperreports problem

    About the "nik", I changed it to caps and problem persists...same error message which basically tells there's no connection, hence no data retrieved.
    Well, I think I'll hold on asking for a while til I'm done re-reading jasper docs.
    hopefully re-read it will make it clear on what the problem is.


    Thanks anyway,
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

  20. #20
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default Re: Jasperreports problem

    Problem fixed, the report shows up.


    Thanks and regards,
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

Page 1 of 2 12 LastLast

Similar Threads

  1. jasperreports API
    By Levian in forum New To Java
    Replies: 0
    Last Post: 09-09-2011, 07:54 AM
  2. JasperReports, pdf and others.
    By hendrix79 in forum New To Java
    Replies: 0
    Last Post: 01-28-2009, 10:33 PM
  3. JasperReports 2.0.5
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 03-14-2008, 06:29 PM
  4. Reports in JasperReports
    By Jack in forum Advanced Java
    Replies: 2
    Last Post: 07-04-2007, 03:09 AM
  5. JasperReports 1.3.4
    By levent in forum Java Software
    Replies: 0
    Last Post: 06-19-2007, 05:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •