2006 IR Open Discussion Posted August 18, 2006 Share Posted August 18, 2006 By: J. Lagunilla - lagu6494 Extremely urgent!! 2003-04-16 02:54 Hi to everybody! In order to localize and format some particular text fields, I use my own class, named Utils. Here is an example of how I'm using it: <textField> <reportElement x="0" y="0" width="50" height="11" forecolor="#000000"/> <textElement textAlignment="Left"/> <textFieldExpression> Utils.getMessage("lblVehicle")</textFieldExpression> </textField> Well, the problem is that I get a java.lang.NoClassDefFoundError. Here is the stack trace: java.lang.NoClassDefFoundError: Utils at SessionReport.evaluate(SessionReport.java:133) at dori.jasper.engine.fill.JRCalculator.evaluate(JRCalculator.java:678) at dori.jasper.engine.fill.JRCalculator.evaluate(JRCalculator.java:614) at dori.jasper.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:342) at dori.jasper.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:329) at dori.jasper.engine.fill.JRFillBand.evaluate(JRFillBand.java:360) at dori.jasper.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:305) at dori.jasper.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:245) at dori.jasper.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:160) at dori.jasper.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:463) at dori.jasper.engine.fill.JRFiller.fillReport(JRFiller.java:143) at dori.jasper.engine.JasperFillManager.fillReport(JasperFillManager.java:348) Any workaround for this? It's really urgent for me... Regards. Jordi. By: schroffd - schroffd RE: Extremely urgent!! 2003-04-16 03:21 Hi, use a scriptlet to forward your request to your Util class. Then you can use ((Scriptlet)$P{REPORT_SCRIPTLET}).yourMethod(String) to call your getMessage() method. For more details about how to use scriptlets take a look at the scriptlet sample. By: J. Lagunilla - lagu6494 RE: Extremely urgent!! 2003-04-16 03:57 Thank you very much, Denis!! Is your answer related to the 'scriptletClass' attribute of the jasperreport tag? By: J. Lagunilla - lagu6494 RE: Extremely urgent!! 2003-04-16 04:09 Hi, Denis: If I set the scriptletClass attribute to my Scriptlet class, I get the same error as above, that is, a java.lang.ClassNotFoundException: Scriptlet. By: Giulio Toffoli - gt78 RE: Extremely urgent!! 2003-04-16 04:18 Are you using tomcat? If yes try to put your class in the classes directory of main tomcat structure (in this way this class is visible from all tomcat enviroments but sure from jasperreports too) or jar it and put the jar into lib directory. Giulio By: J. Lagunilla - lagu6494 RE: Extremely urgent!! 2003-04-16 04:26 Hi, Giulio: I'm not using Tomcat, I'm using JasperReports form a standalone app. Thanx. Jordi. By: schroffd - schroffd RE: Extremely urgent!! 2003-04-16 04:34 Are you using a packaged class? Then you have to write the complete class name including package. If you want to use your own class 'Utils' as your scriptlet-class you have to add 'extends JRDefaultScriptlet' to your class declaration. So the default methods like before/afterDetailEval ... are implemented as well. After that the part of the code you have to add to your xml file should of course not be ((Scriptlet)$P{REPORT_SCRIPTLET}).yourMethod(String) , but ((!!YOUR_SCRIPTLET_CLASS!!)$P{REPORT_SCRIPTLET}).yourMethod(String). And make sure that your method returns a string-Object. If both, xml-file and scriptlet-class(or package-dirs), are in the same directory there shouldn't be such an error any more. By: J. Lagunilla - lagu6494 RE: Extremely urgent!! 2003-04-16 04:49 Hi, Denis: I still getting the error. I'm not using a a packaged class. Here's a more clear example of my situation: I have a dir named 'classes' with Utils.class and SessionReport.jasper, among others. The session report uses static methods in Utils.class, as described above. I also have a lib dir where all the libraries needed are placed. I'm using JBuilder 8. I really don't know why the JasperReport's library is not founding my Utils.class file. I still thinking about it... Thank you very much... By: Chuck Deal - cdeal RE: Extremely urgent!! 2003-04-16 06:01 Try to fully qualify your class name. com.company.application.Utils.method() If the class is in your classpath, then that should do what you want. By: Victor Gieci - drummer RE: Extremely urgent!! 2003-04-22 05:59 Hello. I think I had a similar problem some weeks ago. There is a dumm but working solutions to this: you can re-write you utils class so that it supports not-static methods (in fact you can just add new instance methods that will call the static ones) and pass a reference to its instance as a part of report parameters. I realize that may not be the most clever solution, but it definitelly works. <parameter name="Xutil" class="com.xy.util.JasperReportUtil"/> Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now