Peanut Posted October 5, 2006 Share Posted October 5, 2006 Hello, I've discovered the function JasperCompileManager.verifyDesign, and I wanted to use it in order to avoid my program crashing if the JRXML is not correct.But this function needs a JasperDesign for parameter: this means that you've already called one of the JRXmlLoader.load before... and your program would have certainly crashed in this function ! Indeed, I've tried to put different mistakes in my JRXML file, and each times my program crashes in JRXmlLoader.load, never reaching JasperCompileManager.verifyDesign. What do I miss ? :huh: Link to comment Share on other sites More sharing options...
Teodor Danciu Posted October 5, 2006 Share Posted October 5, 2006 Hi, Well, you wanted to validate your JRXML and you did that! Your file is invalid, this is why the load operation did not succeed.Isn't that what you wanted to do? See if the JRXML is valid or not? It is not. So you can catch the exception and do something with it. The verifyDesign is for after loading the JasperDesign object. Even if the JRXML was parsed OK, maybe there are invalid cross-references or layout problems that need to be validated too. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
Peanut Posted October 5, 2006 Author Share Posted October 5, 2006 OK, so the verifyDesign has nothing to do with XML checking. Thanks. So, as you said, I'm trying to catch exceptions on JRXmlLoader.load : Code:JasperDesign jasperDesign = new JasperDesign();try{ jasperDesign = JRXmlLoader.load(sNomFicJrxml);}catch (JRException e){ System.out.println( "[ERREUR] Problème lors du chargement du modèle JRXML : " + e.getMessage());}That works but I'd like not all that exception buffer to be printed on the screen, but only my println (ie only the last line of this capture) : is it possible ? 5 oct. 2006 14:27:54 org.apache.commons.digester.Digester errorSEVERE: Parse Error at line 19 column 29: L'élément racine du document "jasperReportKO" doit correspondre à la racine DOCTYPE "jasperReport".org.xml.sax.SAXParseException: L'élément racine du document "jasperReportKO" doit correspondre à la racine DOCTYPE "jasperReport". at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.dtd.XMLDTDValidator.rootElementSpecified(Unknown Source) at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source) at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(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.commons.digester.Digester.parse(Digester.java:1647) at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:238) at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:225) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:213) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:167) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:151) at jasper_compile_modele.main(jasper_compile_modele.java:133)[ERREUR] Problème lors du chargement du modèle JRXML : L'élément racine du document "jasperReportKO" doit correspondre à la racine DOCTYPE "jasperReport".I admit it's more a question about Java than about Jasper. :blush: Link to comment Share on other sites More sharing options...
lucianc Posted October 5, 2006 Share Posted October 5, 2006 The exception stacktrace is printed by the XML digester via the Commons Logging library. You can check out the Commons Logging site for instructions on how to configure the library and the underlying implementations. HTH,Lucian 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