2004 IR Help Posted August 23, 2006 Share Posted August 23, 2006 By: anantha - ananthapus net.sf.jasperreports.engine.JRException: Erro 2005-04-19 14:54 Hi, I get this error when executing my java class file. The class file is part of the .ear file and the /lib directory in the .ear file has the jasper jar files. The snippet of the code where my error happens is: try { log.debug("ready to create the report design template"); reportDesign = createReportTemplate(labelsNoSpace, reportTitle, this.isHTML); if (reportDesign == null){ log.debug("error while creating the report template."); }else { log.debug("report design is compiled"); log.debug("ready to compile the report"); tradeReport = JasperCompileManager.compileReport(reportDesign); log.debug("report is compiled"); } } The createReportTemplate method is where I create the template and that is passed onto the compile manager. I'm stuck and any help will be appreciated. Anantha By: Lukas - loester RE: net.sf.jasperreports.engine.JRException: Erro 2005-04-20 04:51 You did not post the whole error It would also help to know in which line the error happens (see the stacktrace). By: anantha - ananthapus RE: net.sf.jasperreports.engine.JRException: 2005-04-20 09:50 On the console, I get this error also..... symbol : class JRFillParameter location: class DraftedTradesReportJasper parameter_REPORT_DATA_SOURCE = (JRFillParameter)parsm.get("REPORT_DATA_S OURCE"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:63: ca nnot resolve symbol symbol : variable parsm location: class DraftedTradesReportJasper parameter_REPORT_DATA_SOURCE = (JRFillParameter)parsm.get("REPORT_DATA_S OURCE"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:64: ca nnot resolve symbol symbol : class JRFillParameter location: class DraftedTradesReportJasper parameter_REPORT_SCRIPTLET = (JRFillParameter)parsm.get("REPORT_SCRIPTLE T"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:64: ca nnot resolve symbol symbol : variable parsm location: class DraftedTradesReportJasper parameter_REPORT_SCRIPTLET = (JRFillParameter)parsm.get("REPORT_SCRIPTLE T"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:65: ca nnot resolve symbol symbol : class JRFillParameter location: class DraftedTradesReportJasper parameter_H0 = (JRFillParameter)parsm.get("H0"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:65: ca nnot resolve symbol symbol : variable parsm location: class DraftedTradesReportJasper parameter_H0 = (JRFillParameter)parsm.get("H0"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:67: ca nnot resolve symbol symbol : class JRFillField location: class DraftedTradesReportJasper field_Swap = (JRFillField)fldsm.get("Swap"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:67: ca nnot resolve symbol symbol : variable fldsm location: class DraftedTradesReportJasper field_Swap = (JRFillField)fldsm.get("Swap"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:68: ca nnot resolve symbol symbol : class JRFillField location: class DraftedTradesReportJasper field_CDS_Physical = (JRFillField)fldsm.get("CDS_Physical"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:68: ca nnot resolve symbol symbol : variable fldsm location: class DraftedTradesReportJasper field_CDS_Physical = (JRFillField)fldsm.get("CDS_Physical"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:70: ca nnot resolve symbol symbol : class JRFillVariable location: class DraftedTradesReportJasper variable_PAGE_NUMBER = (JRFillVariable)varsm.get("PAGE_NUMBER"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:70: ca nnot resolve symbol symbol : variable varsm location: class DraftedTradesReportJasper variable_PAGE_NUMBER = (JRFillVariable)varsm.get("PAGE_NUMBER"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:71: ca nnot resolve symbol symbol : class JRFillVariable location: class DraftedTradesReportJasper variable_COLUMN_NUMBER = (JRFillVariable)varsm.get("COLUMN_NUMBER"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:71: ca nnot resolve symbol symbol : variable varsm location: class DraftedTradesReportJasper variable_COLUMN_NUMBER = (JRFillVariable)varsm.get("COLUMN_NUMBER"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:72: ca nnot resolve symbol symbol : class JRFillVariable location: class DraftedTradesReportJasper variable_REPORT_COUNT = (JRFillVariable)varsm.get("REPORT_COUNT"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:72: ca nnot resolve symbol symbol : variable varsm location: class DraftedTradesReportJasper variable_REPORT_COUNT = (JRFillVariable)varsm.get("REPORT_COUNT"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:73: ca nnot resolve symbol symbol : class JRFillVariable location: class DraftedTradesReportJasper variable_PAGE_COUNT = (JRFillVariable)varsm.get("PAGE_COUNT"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:73: ca nnot resolve symbol symbol : variable varsm location: class DraftedTradesReportJasper variable_PAGE_COUNT = (JRFillVariable)varsm.get("PAGE_COUNT"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:74: ca nnot resolve symbol symbol : class JRFillVariable location: class DraftedTradesReportJasper variable_COLUMN_COUNT = (JRFillVariable)varsm.get("COLUMN_COUNT"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:74: ca nnot resolve symbol symbol : variable varsm location: class DraftedTradesReportJasper variable_COLUMN_COUNT = (JRFillVariable)varsm.get("COLUMN_COUNT"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:75: ca nnot resolve symbol symbol : class JRFillVariable location: class DraftedTradesReportJasper variable_ScritturaGroup_COUNT = (JRFillVariable)varsm.get("ScritturaGrou p_COUNT"); ^ C:beauser_projectsdomainsScritturaDemoDraftedTradesReportJasper.java:75: ca nnot resolve symbol symbol : variable varsm location: class DraftedTradesReportJasper variable_ScritturaGroup_COUNT = (JRFillVariable)varsm.get("ScritturaGrou p_COUNT"); ^ 58 errors By: Lukas - loester RE: net.sf.jasperreports.engine.JRException: Erro 2005-04-20 10:01 The compiler cannot find the classes. You must use System.setProperty("jasper.reports.compile.class.path",...) where ... is the path of the jasper jar AND the path to your compiled classes. Also it might be a good idea to use System.setProperty("jasper.reports.compile.temp",...) to set the path where the .jasper files are stored (unless you get the compiled jasper as a stream and store it yourself). Hope this helps By: anantha - ananthapus RE: net.sf.jasperreports.engine.JRException: 2005-04-20 10:54 Hi, Thanks for your reply. One clarification though. 1) I have the jasper-0.6.4.jar in my .ear file. So it should be able to find it. 2) I don't have any .jasper files. The code above is in my report class file. I want to create the template at run time and compile the report. Is it possible? By: anantha - ananthapus RE: net.sf.jasperreports.engine.JRException: 2005-04-20 07:58 Hi, Here is the stacktrace. 2005-04-20 10:38:46,862 DEBUG [ExecuteThread: '13' for queue: 'weblogic.kernel.Default'] com.ipicorp.scrittura.web.reports.DraftedTradesReportJasper - error while compiling the design: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: See error messages above. net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: See error messages above. at net.sf.jasperreports.engine.design.JRAbstractJavaCompiler.compileReport(JRAbstractJavaCompiler.java:155) at net.sf.jasperreports.engine.design.JRDefaultCompiler.compileReport(JRDefaultCompiler.java:149) at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:255) at com.ipicorp.scrittura.web.reports.DraftedTradesReportJasper.runReport(DraftedTradesReportJasper.java:139) at com.ipicorp.scrittura.web.reports.CustomReportJasper.createCustomReport(CustomReportJasper.java:73) at com.ipicorp.scrittura.web.events.TradeReportsEvent.process(TradeReportsEvent.java:120) at com.ipicorp.mvc.Controller.doPost(Controller.java:288) at com.ipicorp.mvc.Controller.doGet(Controller.java:139) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170) 2 My actual code is private static JasperDesign createReportTemplate(List labelsNoSpace, String title, boolean isHTML) { try { // creating the template JasperDesign jasperDesign = new JasperDesign(); jasperDesign.setName("DraftedTradesReportJasper"); jasperDesign.setPageWidth(792); jasperDesign.setPageHeight(612); // jasperDesign.setColumnWidth(515); jasperDesign.setColumnSpacing(0); jasperDesign.setLeftMargin(20); jasperDesign.setRightMargin(20); jasperDesign.setTopMargin(30); jasperDesign.setBottomMargin(30); // Fonts JRDesignReportFont normalFont = new JRDesignReportFont(); normalFont.setName("Arial_Normal"); normalFont.setDefault(true); normalFont.setFontName("Arial"); normalFont.setSize(12); normalFont.setPdfFontName("Helvetica"); normalFont.setPdfEncoding("Cp1252"); normalFont.setPdfEmbedded(false); jasperDesign.addFont(normalFont); JRDesignReportFont boldFont = new JRDesignReportFont(); boldFont.setName("Arial_Bold"); boldFont.setDefault(false); boldFont.setFontName("Arial"); boldFont.setSize(12); boldFont.setBold(true); boldFont.setPdfFontName("Helvetica-Bold"); boldFont.setPdfEncoding("Cp1252"); boldFont.setPdfEmbedded(false); jasperDesign.addFont(boldFont); JRDesignReportFont hyperlinkFont = new JRDesignReportFont(); hyperlinkFont.setName("Arial_Underline"); hyperlinkFont.setDefault(false); hyperlinkFont.setFontName("Arial"); hyperlinkFont.setSize(12); hyperlinkFont.setUnderline(true); hyperlinkFont.setBold(true); hyperlinkFont.setPdfFontName("Helvetica-Bold"); hyperlinkFont.setPdfEncoding("Cp1252"); hyperlinkFont.setPdfEmbedded(false); jasperDesign.addFont(hyperlinkFont); JRDesignReportFont titleFont = new JRDesignReportFont(); titleFont.setName("Arial_Title"); titleFont.setDefault(false); titleFont.setFontName("Arial"); titleFont.setSize(20); titleFont.setBold(true); titleFont.setPdfFontName("Helvetica-Bold"); titleFont.setPdfEncoding("Cp1252"); titleFont.setPdfEmbedded(false); jasperDesign.addFont(titleFont); // populating the detail band that contains the textFields JRDesignBand titleBand = new JRDesignBand(); JRDesignBand headerBand = new JRDesignBand(); JRDesignBand columnBand = new JRDesignBand(); headerBand.setHeight(18); columnBand.setHeight(30); titleBand.setHeight(400); JRDesignField field = null; JRDesignTextField textField = null; JRDesignExpression expression = null; JRDesignParameter parameter = null; JRDesignLine line = null; int pixelWidth = 730; int totalColumnWitdh = 730 / labelsNoSpace.size(); int columnWitdh = totalColumnWitdh - 5; //Group JRDesignGroup group = new JRDesignGroup(); group.setName("ScritturaGroup"); group.setMinHeightToStartNewPage(60); // add the title parameter and field parameter = new JRDesignParameter(); parameter.setName("ReportTitle"); parameter.setValueClass(java.lang.String.class); jasperDesign.addParameter(parameter); textField = new JRDesignTextField(); textField.setX(0); textField.setY(0); textField.setWidth(450); textField.setHeight(30); textField.setStretchWithOverflow(true); textField.setTextAlignment(JRTextElement.TEXT_ALIGN_LEFT); textField.setFont(titleFont); log.debug("ready to create the report expression"); expression = new JRDesignExpression(); expression.setValueClass(java.lang.String.class); expression.setText("$P{ReportTitle}"); textField.setExpression(expression); titleBand.addElement(textField); log.debug("title expression is successful."); // adding the image (parameter + place holder) parameter = new JRDesignParameter(); parameter.setName("scritturaChart"); parameter.setValueClass(java.awt.Image.class); jasperDesign.addParameter(parameter); JRDesignImage image = new JRDesignImage(); expression = new JRDesignExpression(); expression.setValueClass(java.awt.Image.class); expression.setText("$P{scritturaChart}"); image.setExpression(expression); image.setX(100); image.setY(35); image.setWidth(500); image.setHeight(300); titleBand.addElement(image); log.debug("chart expression is successful"); //for each labels/columns adding necessary elements log.debug("size of label array is " + labelsNoSpace.size()); for (int i = 0; i < labelsNoSpace.size(); i++) { log.debug("inside the label loop"); // adding a parameter for each header parameter = new JRDesignParameter(); parameter.setName("H" + i); parameter.setValueClass(java.lang.String.class); jasperDesign.addParameter(parameter); // adding a textField each header textField = new JRDesignTextField(); textField.setX(i * totalColumnWitdh); textField.setY(1); textField.setWidth(columnWitdh); textField.setHeight(15); textField.setStretchWithOverflow(true); textField.setTextAlignment(JRTextElement.TEXT_ALIGN_CENTER); textField.setFont(boldFont); expression = new JRDesignExpression(); expression.setValueClass(java.lang.String.class); expression.setText("$P{" + "H" + i + "}"); textField.setExpression(expression); headerBand.addElement(textField); line = new JRDesignLine(); line.setX(0); line.setY(17); line.setWidth(730); line.setHeight(1); line.setForecolor(new Color(0x80, 0x80, 0x80)); line.setPositionType(JRElement.POSITION_TYPE_FLOAT); headerBand.addElement(line); // adding Fields for each column field = new JRDesignField(); field.setName((String) labelsNoSpace.get(i)); field.setValueClass(java.lang.String.class); jasperDesign.addField(field); // adding a textField for the column textField = new JRDesignTextField(); textField.setX(i * totalColumnWitdh); textField.setY(2); textField.setWidth(columnWitdh); textField.setHeight(15); textField.setStretchWithOverflow(true); textField.setTextAlignment(JRTextElement.TEXT_ALIGN_CENTER); textField.setBlankWhenNull(true); textField.setFont(normalFont); expression = new JRDesignExpression(); expression.setValueClass(java.lang.String.class); expression.setText("$F{" + (String) labelsNoSpace.get(i) + "}"); textField.setExpression(expression); if ("ID".equals(labelsNoSpace.get(i)) && isHTML) { // adding hyperlink expression = new JRDesignExpression(); expression.setValueClass(java.lang.String.class); expression.setText(""controller?e=auditsearch&i=" + $F{" + (String) labelsNoSpace.get(i) + "}"); Map hyperlinkTypeMap = JRXmlConstants.getHyperlinkTypeMap(); byte type = ((Byte) (hyperlinkTypeMap.get("Reference"))).byteValue(); textField.setHyperlinkType(type); textField.setHyperlinkReferenceExpression(expression); textField.setFont(hyperlinkFont); textField.setForecolor(Color.blue); } columnBand.addElement(textField); line = new JRDesignLine(); line.setX(0); line.setY(17); line.setWidth(730); line.setHeight(0); line.setForecolor(new Color(0x80, 0x80, 0x80)); line.setPositionType(JRElement.POSITION_TYPE_FLOAT); columnBand.addElement(line); } // adding modified Bands jasperDesign.setTitle(titleBand); jasperDesign.setDetail(columnBand); group.setGroupHeader(headerBand); jasperDesign.addGroup(group); return jasperDesign; }catch (Exception e){ log.debug("Error while creating the report design template" + e); return null; } } By: JAmol - jamol RE: net.sf.jasperreports.engine.JRException: 2005-07-19 23:37 hi buddy, This code is using jasper to develop report. I am also using APIs for same but having problem for displaying image on report . can any body inform me what do we mean by $P, such as $F means field from database and $V means value of variable.. how should I display an image by retriving from database or from local disk. and how should I do that. regards, JAmol By: Denny Valliant - xenden RE: net.sf.jasperreports.engine.JRException: 2005-07-20 00:56 Did you randomly pick a message? Heh. $P means param, as passable in a hashmap. I've found easiest for me is to use a URL, and there was an interestin g post a little while back about using URLs and images from a databse or file system. Very kewl. Just like this project. Good Luck! By: Lukas - loester RE: net.sf.jasperreports.engine.JRException: Erro 2005-04-21 02:59 If you mean .jasper file with template then yes, it's possible. You can use JasperCompileManager.compileReportToStream(...) to compile a jrxml file/stream to a .jasper file/stream. I have my files in a .war file myself, and it was necessary to at least set the path of the classes it uses in the way described above to get rid of the same compile errors that you posted. If you mean .xrxml with template then I guess even that is possible - generate it dynamically, pass it to the compile method mentioned above and use the compiled stream to fill and format the report. Cheers, Lukas By: Lucas Persona - persona RE: net.sf.jasperreports.engine.JRException: Erro 2005-08-25 06:58 When using a report to Stream compilation approach, it's still needed to set jasper classpath... however, I have them inside my ear (APP-INFlib) and cannot find a way to set the correct compile path within my code. Any ideas on this? Thanks, Lucas By: Lucas Persona - persona RE: net.sf.jasperreports.engine.JRException: Erro 2005-08-25 10:49 Instead of trying to compile on runtime now I get all reports pre-compiled during the build (through an ant script and jrc taskdef) and packed inside a jar. When recovering the report: URL url = getClass().getClassLoader().getResource("/reportName.jasper"); JasperReport jasperReport = (JasperReport) JRLoader.loadObject(url); It works...and hope this will help someone else. Lucas 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