aknudtso Posted June 6, 2013 Share Posted June 6, 2013 I get the following error when trying to open my report from java:cannot assign instance of net.sf.jasperreports.engine.base.JRBaseTextField to field net.sf.jasperreports.engine.base.JRBaseParagraph.paragraphContainer of type net.sf.jasperreports.engine.JRParagraphContainer in instance of net.sf.jasperreports.engine.base.JRBaseParagraph: cannot assign instance of net.sf.jasperreports.engine.base.JRBaseTextField to field net.sf.jasperreports.engine.base.JRBaseParagraph.paragraphContainer of type net.sf.jasperreports.engine.JRParagraphContainer in instance of net.sf.jasperreports.engine.base.JRBaseParagraphI'm upgrading from iReport 3.7.* to 5.1.0 where my report can be compiled and previewed without any trouble both before and after the upgrade. After the upgrade however the only time I can get java to open up the report (.jasper file) is if the report is completely blank. If I attempt to introduce a Text Field, Static Text or anything else I've tried the above error is displayed.The report I'm using looks like this:<?xml version="1.0" encoding="UTF-8"?><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Incident" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="f7b31fbb-2c2d-42bd-bba7-508b39f291e4"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <parameter name="NUMBER" class="java.lang.Integer"> <defaultValueExpression><![CDATA[new Integer(1)]]></defaultValueExpression> </parameter> <queryString> <![CDATA[sELECT * FROM REPORT_INCIDENT]]> </queryString> <field name="ID" class="java.lang.Number"/> <background> <band splitType="Stretch"/> </background> <title> <band height="351" splitType="Stretch"> <textField> <reportElement uuid="12dadc34-86a9-4919-aab0-c78902fd67fd" x="258" y="115" width="100" height="20"/> <textElement/> <textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression> </textField> </band> </title> <detail> <band height="21"/> </detail> <pageFooter> <band height="24" splitType="Stretch"/> </pageFooter></jasperReport>[/code]And the java I'm using looks like this:String form = "Incident";Map<String, Object> parameters = new HashMap<String, Object>();parameters.put("NUMBER", new Integer(1));JasperPrint jasperPrint = null;try{ //Custom function, just retrieves the file from a default directory, have tried several different alternative and all give the same result InputStream IncidentStream = NORAC.getJasperAsStream(form); JasperReport jasperReport = (JasperReport) JRLoader.loadObject(IncidentStream); jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, getConnection());}catch (JRException ex){ jServerGroupStatusPanel.showStatusMessageError(ex.getLocalizedMessage()); Trace.error(this, ex + ": " + ex.getMessage());}catch(ClassCastException ex){ Trace.error(this, ex + ": " + ex.getMessage());}catch (SQLException ex){ Trace.error(this, ex + ": " + ex.getMessage());}JasperViewer jv = new JasperViewer(jasperPrint, false);jv.setVisible(true);[/code]Putting in a filename string or any type of inputStream I've attempted in both the lines:JasperReport jasperReport = (JasperReport) JRLoader.loadObject(IncidentStream);[/code]andjasperPrint = JasperFillManager.fillReport(jasperReport, parameters, getConnection());[/code]Leads the the same error above. I've installed different versions of iReport and tried various different .jars and am stuck. Any help would be appreciated.Recompiling the report through java led to some different and interesting errors:InputStream IncidentStream = NORAC.getJasperAsStream(form);JasperReport compiledIncident = JasperCompileManager.compileReport(IncidentStream);jasperPrint = JasperFillManager.fillReport(compiledIncident, parameters, getConnection());Led to the following error:0 [AWT-EventQueue-0] WARN net.sf.jasperreports.engine.component.ComponentsEnvironment - Found two components for namespace http://jasperreports.sourceforge.net/jasperreports/componentsE:net.sf.jasperreports.engine.JRException: org.apache.xerces.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.: org.apache.xerces.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.Currently looking into how to solve these issues, if you have any ideas I'd appreciate the help. I'll update this space with any new information I find.Update: I was able to add a few jasper .jar files into java libraries which made a error complaining about the UUID start which makes me think I have a old .jar somewhere that is messing me up but I can't seem to find it in iReport or included anywhere in java. Strangely enough changing the report to backwards compatible to 4.5.0 to remove UUID reverted back to the above error again. Still looking for more alternatives and solutions.Both iReport and java contain the following libraries (as well as a ojdbc6.jar one exclusive to iReport) however only jasperreports-5.1.0.jar seems to allow any additional functionality.jasperreports-5.1.0.jarcommons-beanutils-1.8.2.jarcommons-collections-3.2.1.jarcommons-digester-2.1.jarcommons-logging-1.1.jariText-2.1.7.js2.jarjasperreports-core-renderer.jarjasperreports-extensions-3.5.3.jarlog4j-1.2.15.jarpoi-3.7-20101029.jar Link to comment Share on other sites More sharing options...
Thomas Zimmer Posted June 6, 2013 Share Posted June 6, 2013 Which version of jasperreports library do you use in java?your report uses a newer spec of jasperreports (you can see it by the "uuid=..." attribute of the text field, so you cannot use an old library version.did you try to recompile the jrxml in java?would be helpful to post the complete stack trace.Cheers, Thomashttp://www.thomaszimmer.net Link to comment Share on other sites More sharing options...
aknudtso Posted June 6, 2013 Author Share Posted June 6, 2013 I hadn't been using anything other then jasperreports-3.7.*.jar in my java libraries previously and upgrading it to jasperreports-5.1.0.jar doesn't change anything I'm seeing I've included various other libraries without any success what would you suggest? I also have tried a backwards compatibility option (to get it back to around 3.7.0 and remove uuid) but that didn't get rid of or change the error message The complete error is: java.lang.ClassCastException: cannot assign instance of net.sf.jasperreports.engine.base.JRBaseTextField to field net.sf.jasperreports.engine.base.JRBaseParagraph.paragraphContainer of type net.sf.jasperreports.engine.JRParagraphContainer in instance of net.sf.jasperreports.engine.base.JRBaseParagraph at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2063) at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1241) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1976) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1894) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1777) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1970) at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:498) at net.sf.jasperreports.engine.base.JRBaseTextElement.readObject(JRBaseTextElement.java:1366) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1004) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1872) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1777) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369) at java.util.ArrayList.readObject(ArrayList.java:733) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1004) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1872) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1777) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1970) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1894) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1777) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1970) at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:498) at net.sf.jasperreports.engine.base.JRBaseReport.readObject(JRBaseReport.java:823) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1004) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1872) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1777) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369) at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:201) at com.arinc.aim.report.module.norac.dialog.IncidentDialog.jViewActionPerformed(IncidentDialog.java:905) at com.arinc.aim.report.module.norac.dialog.IncidentDialog.access$1300(IncidentDialog.java:88) at com.arinc.aim.report.module.norac.dialog.IncidentDialog$10.actionPerformed(IncidentDialog.java:388) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) at org.pushingpixels.substance.internal.utils.RolloverButtonListener.mouseReleased(RolloverButtonListener.java:124) at java.awt.Component.processMouseEvent(Component.java:6505) at javax.swing.JComponent.processMouseEvent(JComponent.java:3321) at java.awt.Component.processEvent(Component.java:6270) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) at java.awt.Container.dispatchEventImpl(Container.java:2273) at java.awt.Window.dispatchEventImpl(Window.java:2719) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729) at java.awt.EventQueue.access$200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:688) at java.awt.EventQueue$3.run(EventQueue.java:686) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:702) at java.awt.EventQueue$4.run(EventQueue.java:700) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:699) at com.arinc.aim.core.swing.SystemEventQueueManager$1.dispatchEvent(SystemEventQueueManager.java:73) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) Link to comment Share on other sites More sharing options...
aknudtso Posted June 13, 2013 Author Share Posted June 13, 2013 When compiling at runtime I get the following error: net.sf.jasperreports.engine.JRException: org.apache.xerces.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence. at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:249) at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:228) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:216) at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:199) at com.arinc.aim.report.module.norac.dialog.IncidentDialog.jViewActionPerformed(IncidentDialog.java:906) at com.arinc.aim.report.module.norac.dialog.IncidentDialog.access$1300(IncidentDialog.java:89) at com.arinc.aim.report.module.norac.dialog.IncidentDialog$10.actionPerformed(IncidentDialog.java:389) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) at org.pushingpixels.substance.internal.utils.RolloverButtonListener.mouseReleased(RolloverButtonListener.java:124) at java.awt.Component.processMouseEvent(Component.java:6505) at javax.swing.JComponent.processMouseEvent(JComponent.java:3321) at java.awt.Component.processEvent(Component.java:6270) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) at java.awt.Container.dispatchEventImpl(Container.java:2273) at java.awt.Window.dispatchEventImpl(Window.java:2719) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729) at java.awt.EventQueue.access$200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:688) at java.awt.EventQueue$3.run(EventQueue.java:686) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:702) at java.awt.EventQueue$4.run(EventQueue.java:700) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:699) at com.arinc.aim.core.swing.SystemEventQueueManager$1.dispatchEvent(SystemEventQueueManager.java:73) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) Caused by: org.apache.xerces.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence. at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown Source) at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source) at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source) at org.apache.xerces.impl.XMLEntityScanner.skipString(Unknown Source) at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.commons.digester.Digester.parse(Digester.java:1647) at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:241) Link to comment Share on other sites More sharing options...
Solution lucianc Posted June 14, 2013 Solution Share Posted June 14, 2013 The ClassCastException and the duplicate component warning indicate that you have two JasperReports jars on your classpath.The MalformedByteSequenceException says that you are not reading a JRXML file but something else (mabye a compiled report *.jasper file).Regards,Lucian Link to comment Share on other sites More sharing options...
aknudtso Posted June 17, 2013 Author Share Posted June 17, 2013 I didn't realize I was trying to compile through the .jasper instead of the .jrxml, once I fixed that I was able to get everything running with a few small changes. Ultimately I ended up trying to open the report through the jasper file and catching the error if it fails and then trying to recompile through the jrxml as a fail-safe. This worked really well throughout my tests. One oddity however was I had to manually go into the XML file and remove all entries with "" since they all caused errors, after removing these I was able to run the report as intended. I also had to change the compatibility version to 4.5.0 or before in order to get rid of the uuid errors. I most likely still have a old .jar file floating around that is causing my issue but this will work for now until I can devote more time to it. Thanks everyone for the help. Link to comment Share on other sites More sharing options...
lucianc Posted June 18, 2013 Share Posted June 18, 2013 Try enabling debug logging for net.sf.jasperreports.extensions.DefaultExtensionsRegistry, it should tell you on startup where it finds JR extensions property resources. 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