TIBCOSoftware / jasperreports

JasperReports® - Free Java Reporting Library
https://community.jaspersoft.com/downloads/community-edition/
GNU Lesser General Public License v3.0
1.07k stars 404 forks source link

Jasperstudio 7.0 can't load .jrtx file (unrecognized field isStrikeThrough) #454

Closed N-Bojovic closed 4 months ago

N-Bojovic commented 4 months ago

Hi,

I wanted to update my ReportStyleTemplate.jrtx file to a new style from within Jasperstudio 7.0, but when I open this file it throws this exception (see bellow). When I change all attributes that start with 'is' (isStrikeThrough -> strikeThrough; isDefault -> default; isBold -> bold) I don't have this error anymore and file can be converted to a new style. Is it safe to change those properties to be without prefix 'is', or reason for this is something else and I should fix this problem differently?

net.sf.jasperreports.jackson.util.JacksonRuntimeException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "isStrikeThrough" (class net.sf.jasperreports.engine.design.JRDesignStyle), not marked as ignorable (31 known properties: "vImageAlign", "default", "vTextAlign", "fill", "bold", "name", "underline", "hTextAlign", "radius", "blankWhenNull", "pen", "backcolor", "mode", "pdfEncoding", "forecolor", "markup", "paragraph", "fontSize", "style", "hImageAlign", "strikeThrough", "fontName", "rotation", "box", "pdfFontName", "pattern", "pdfEmbedded", "parentStyle", "scaleImage", "italic", "conditionalStyle"]) at [Source: (ByteArrayInputStream); line: 7, column: 97] (through reference chain: net.sf.jasperreports.engine.JRSimpleTemplate["style"]->java.util.ArrayList[0]->net.sf.jasperreports.engine.design.JRDesignStyle["isStrikeThrough"]) at net.sf.jasperreports.jackson.util.JacksonUtil.loadXml(JacksonUtil.java:309) at net.sf.jasperreports.engine.xml.JacksonReportLoader.loadTemplate(JacksonReportLoader.java:84) at net.sf.jasperreports.engine.xml.JRXmlTemplateLoader.loadTemplate(JRXmlTemplateLoader.java:218) at net.sf.jasperreports.engine.xml.JRXmlTemplateLoader.load(JRXmlTemplateLoader.java:257) at com.jaspersoft.studio.editor.JRtxEditor.xml2model(JRtxEditor.java:54) at com.jaspersoft.studio.editor.AMultiEditor.init(AMultiEditor.java:305) at org.eclipse.ui.internal.EditorReference.initialize(EditorReference.java:353) at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:344) at jdk.internal.reflect.GeneratedMethodAccessor257.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:971) at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:936) at org.eclipse.e4.core.internal.di.InjectorImpl.internalInject(InjectorImpl.java:142) at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:386) at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:313) at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:202) at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:91) at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:60) at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:42) at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:132) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:995) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:659) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:763) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:728) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:712) at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.lambda$0(PartServiceImpl.java:105) at org.eclipse.e4.ui.services.internal.events.UIEventHandler.lambda$0(UIEventHandler.java:38) at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:183) at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:133) at org.eclipse.swt.widgets.Display.syncExec(Display.java:4803) at org.eclipse.e4.ui.workbench.swt.DisplayUISynchronize.syncExec(DisplayUISynchronize.java:34) at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38) ... Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "isStrikeThrough" (class net.sf.jasperreports.engine.design.JRDesignStyle), not marked as ignorable (31 known properties: "vImageAlign", "default", "vTextAlign", "fill", "bold", "name", "underline", "hTextAlign", "radius", "blankWhenNull", "pen", "backcolor", "mode", "pdfEncoding", "forecolor", "markup", "paragraph", "fontSize", "style", "hImageAlign", "strikeThrough", "fontName", "rotation", "box", "pdfFontName", "pattern", "pdfEmbedded", "parentStyle", "scaleImage", "italic", "conditionalStyle"]) at [Source: (ByteArrayInputStream); line: 7, column: 97] (through reference chain: net.sf.jasperreports.engine.JRSimpleTemplate["style"]->java.util.ArrayList[0]->net.sf.jasperreports.engine.design.JRDesignStyle["isStrikeThrough"]) at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:61) at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:1132) at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:2202) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1705) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1683) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:320) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177) at com.fasterxml.jackson.dataformat.xml.deser.WrapperHandlingDeserializer.deserialize(WrapperHandlingDeserializer.java:122) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:359) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:28) at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:314) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177) at com.fasterxml.jackson.dataformat.xml.deser.WrapperHandlingDeserializer.deserialize(WrapperHandlingDeserializer.java:122) at com.fasterxml.jackson.dataformat.xml.deser.XmlDeserializationContext.readRootValue(XmlDeserializationContext.java:91) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4730) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3714) at net.sf.jasperreports.jackson.util.JacksonUtil.loadXml(JacksonUtil.java:305) ... 91 more

teodord commented 4 months ago

Are you sure it is Jaspersoft Studio 7 that you are using? I tried it myself and it works.

Can you attach here your JRTX file?

Thanks, Teodor

N-Bojovic commented 4 months ago

I'm using JS7.

This file format is not supported to be attached on this platform but here is the content of it:

<?xml version="1.0"?>
<!DOCTYPE jasperTemplate
  PUBLIC "-//JasperReports//DTD Template//EN"
  "http://jasperreports.sourceforge.net/dtds/jaspertemplate.dtd">

<jasperTemplate>
    <style name="SuperFont" fontName="Arial"  isStrikeThrough="false" pdfFontName="Helvetica" />
    <style name="Font6" style="SuperFont" fontSize="6"/>
    <style name="Font8" style="SuperFont" fontSize="8"/>
    <style name="Font9" style="SuperFont" fontSize="9"/>
    <style name="Font10" isDefault="true" style="SuperFont" fontSize="10"/>
    <style name="Font12" style="SuperFont" fontSize="12"/>
    <style name="Font14" style="SuperFont" fontSize="14"/>
    <style name="Font16" style="SuperFont" fontSize="16"/>
    <style name="Font20" style="SuperFont" fontSize="20"/>
    <style name="BoldFont6" style="Font6" isBold="true" pdfFontName="Helvetica-Bold"/>
    <style name="BoldFont8" style="Font8" isBold="true" pdfFontName="Helvetica-Bold"/>
    <style name="BoldFont9" style="Font9" isBold="true" pdfFontName="Helvetica-Bold"/>
    <style name="BoldFont10" style="Font10" isBold="true" pdfFontName="Helvetica-Bold"/>
    <style name="BoldFont12" style="Font12" isBold="true" pdfFontName="Helvetica-Bold"/>
    <style name="BoldFont14" style="Font14" isBold="true" pdfFontName="Helvetica-Bold"/>
    <style name="BoldFont16" style="Font16" isBold="true" pdfFontName="Helvetica-Bold"/>
</jasperTemplate>
teodord commented 4 months ago

It seems you are affected by the same JSS7 bug and should try the same workaround as explained here: https://github.com/TIBCOSoftware/jasperreports/issues/453

Thank you, Teodor

N-Bojovic commented 4 months ago

I already did that, but the problem occurs when I open file that I want to update through Jasper Studio 7, not during update. So at the end what I did is removed "is" prefix and then open file in JS7, when it was correctly loaded I could execute conversion. My question is now if those changes I did on properties (e.g. isBold -> bold) will have any impact in my reports?

teodord commented 4 months ago

If you are saying that your existing JRTX files still point to a DTD, it means they are very old. Prior to JasperReports version 6.3.0 from 2016, when we deprecated DTD and replaced it with XSD. If that's the case, then you need to use Jaspersoft Studio 6 or older to upgrade them from DTD to XSD and then use JSS7 to migrate to the new syntax. So you do it in two steps. In version 7 we decided to no longer read DTD based files as they are very old.

I hope this helps. Teodor

N-Bojovic commented 4 months ago

Indeed, this is really old jrtx file. Do you have any tip how to do this from JR6 (DTD to XSD)?

teodord commented 4 months ago

Just open the file in designer/editor, simulate a fake change and save it back.

I hope this helps. Teodor

N-Bojovic commented 4 months ago

For some reason it's not working for this .jrtx file. On the other hand I had few .jrxml templates based on DTD and when I open them in JR6 and made dummy change it did remove DTD section. Either way, I have fixed .jrtx manually, so I think this thread can be closed.

Thanks teodord!