-1

I am working in java swing application with Jasper report in eclipse. I installed jasper plug in in eclipse and did import jasper viewer (JasViewer_V1_10) libraries/jar files in project.

Now, I am having an exception at JasperCompileManager.compileReport(jDesign), which I don't understand what is wrong with the jar's file.

net.sf.jasperreports.engine.JRException: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 435; cvc-complex-type.3.2.2: Attribute 'uuid' is not allowed to appear in element 'jasperReport'.

I don't know what is wrong with this below code: -

JasperDesign jDesign = JRXmlLoader.load(new File("").getAbsolutePath()+ "/src/reports/Blank_A4.jrxml");         
JasperReport jReprt = JasperCompileManager.compileReport(jDesign);

TIA

Alex K
  • 22,315
  • 19
  • 108
  • 236
Alpha
  • 167
  • 1
  • 13
  • `/src/` is a problem - you should not be referencing `src` in you code - instead use `Class#getResource` or `Class#getResourceAsStream` – MadProgrammer Jun 08 '23 at 03:40
  • [JasperSoft](https://community.jaspersoft.com/ireport-designer/issues/5784); [GitHub](https://github.com/fortesinformatica/jasper-rails/issues/2) or you could just manually update the `jrxml` [for example](https://stackoverflow.com/questions/11467874/cvc-complex-type-3-2-2-attribute-uuid-is-not-allowed-to-appear-in-element-jas) – MadProgrammer Jun 08 '23 at 03:43
  • You should also consider pre-compiling the reports, maybe as part of your build process, and include the resulting report into your package, this will be much faster at runtime – MadProgrammer Jun 08 '23 at 03:44
  • @MadProgrammer: - I tried to update the manually by referring to your example, but I did not understand the solution, will you please help me out that what is '\w*-\w*-\w*-\w*-\w*' mean & regular expression n solution? – Alpha Jun 08 '23 at 03:57

1 Answers1

0

This problem is not something relate to swing. when the given xml is processed by "Jasper" , that xml has an attribute named 'uuid' inside 'jasperReport' element. But SAXParser fails because that attribute is unexpected (not defined in the schema used by Jasper this runtime version)

What it means?

the designer you use might be a newer version and at runtime you might be using a previous version. at runtime 'Jasper' doesn't expect this attribute, but designer has generated xml file with that attribute.

Solution :

probably , in the designer , there might an option to save the xml file with backward compatible option (by providing the specific version )

hunter
  • 3,963
  • 1
  • 16
  • 19
  • - In source view of report I saw this uuid field in XML with some value. Do you know how can i save this to previous version in eclipse, I am stuck with this error the whole day & did not found any solution : uuid="e83b3c62-cb80-4b02-bfc7-08b9781a7ef1" this is the value in xml – Alpha Jun 08 '23 at 04:23
  • you are using iReport plugin for eclipse? – hunter Jun 08 '23 at 04:25
  • No, I installed jasper Studio plug in in Eclipse & did import JasViewer_V1_10 jars file. – Alpha Jun 08 '23 at 04:27
  • - Do you recommend any other free reporting tool for java swing app, as this is the first report, so I can switch to any other free reporting tool at this stage, if this error does not solve. – Alpha Jun 08 '23 at 04:34
  • I think you are using an old viewer , try to use a newer jasper viewer , at least 4.x . recommended to use 5.5.0 – hunter Jun 08 '23 at 04:36
  • - link to download 5.5.0 or how can I update this? First time I am using this jasper, so help would be appreciate. – Alpha Jun 08 '23 at 04:38
  • my jasper studio version in Eclipse is 6.20.5, which is the latest. – Alpha Jun 08 '23 at 04:40
  • if you use maven, just add the dependency with correct version numbers in the pom , otherwise try this link https://sourceforge.net/projects/jasperreports/files/archive/jasperreports/JasperReports%205.5.0/ – hunter Jun 08 '23 at 04:46