aspose file tools*
The moose likes Other Open Source Projects and the fly likes Jasper report error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Jasper report error " Watch "Jasper report error " New topic
Author

Jasper report error

sandevni periyapperuma
Greenhorn

Joined: Jul 09, 2007
Posts: 1
Hi experts
I am getting an an exception
org.xml.sax.SAXNotRecognizedException: http://apache.org/xml/features/validation/dynamic

This worked before when i use jboss 3.2. I converted the system on to jboss 4.0 and now i am getting this error
these are the libs i am using

jasper reports version 1.3.4
commons-beanutils-1.5.jar
commons-collections-2.1.jar
commons-digester-1.7.jar
commons-logging-1.0.2.jar
gnujaxp.jar
xmlparserv2.jar

11:02:36,554 ERROR [Digester] Digester.getParser:
org.xml.sax.SAXNotRecognizedException: http://apache.org/xml/features/validation/dynamic
at gnu.xml.aelfred2.JAXPFactory.setFeature(JAXPFactory.java:102)
at org.apache.commons.digester.parser.XercesParser.configureXerces(XercesParser.java:185)
at org.apache.commons.digester.parser.XercesParser.newSAXParser(XercesParser.java:138)
at org.apache.commons.digester.ParserFeatureSetterFactory.newSAXParser(ParserFeatureSetterFactory.java:71)
at org.apache.commons.digester.Digester.getParser(Digester.java:692)
at org.apache.commons.digester.Digester.getXMLReader(Digester.java:899)
at org.apache.commons.digester.Digester.parse(Digester.java:1647)
at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:239)
at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:226)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:214)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:168)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:152)


here is my class

package ecspider.util;

import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.util.JRSaver;
import net.sf.jasperreports.engine.data.JRXmlDataSource;

import java.util.Map;
import java.io.StringReader;
import java.io.IOException;
import java.io.File;

import oracle.xml.parser.v2.DOMParser;
import oracle.xml.parser.v2.XMLDocument;
import oracle.xml.parser.v2.XMLParseException;
import org.xml.sax.SAXException;




public class PdfCreator {

private static PdfCreator thisInstance;

private PdfCreator(){
System.out.println("constructor");
}

public static PdfCreator getInstance(){


if(thisInstance == null){

thisInstance = new PdfCreator();
}

return thisInstance;

}

/* Method Description : Creates a pdf report file
Parameters
templateFilePath : path of the xml where the report is defined
xmlBuffer : StringBuffer which contains the data in xml format, needed for the report
selectExpression : the XPath select expression to create the data source
pdfFilePath : path for the pdf file to be created
parameters : parameters to be passed for the report
*/
public void createPdf(String templateFilePath,StringBuffer xmlBuffer,String selectExpression,String pdfFilePath,Map parameters){

//----------------------------------------creating the XMLDocument object using string buffer

// javax.xml.parsers.SAXParser parser;
DOMParser parser;
XMLDocument xmlDoc;

parser = new DOMParser();
parser.setPreserveWhitespace(true);


String xmlText = xmlBuffer.toString();
StringReader xmlStream = new StringReader(xmlText);

try{
parser.parse(xmlStream);
}
catch(XMLParseException e){
System.out.println("XMLParseException ");
e.printStackTrace();
}
catch(SAXException e1){
System.out.println("SAXException");
e1.printStackTrace();
}
catch(IOException e2){
System.out.println("IOException");
e2.printStackTrace();
}
xmlDoc = parser.getDocument();


//---------------------------------------------------------------------------------------------

try{
//get the file path of the xml template file and creates a JasperDesign object
JasperDesign jasperDesign = JRXmlLoader.load(templateFilePath);

//compile the JasperDesign object into a JasperReport object
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

//fill the JasperReport object and creates a JasperPrint object
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,new JRXmlDataSource(xmlDoc, selectExpression));

//export the JasperPrint object into a pdf file
JasperExportManager.exportReportToPdfFile(jasperPrint,pdfFilePath);

}
catch(JRException e){
System.out.println("within JRException");
System.out.println(e.getMessage());
e.printStackTrace();
}
}

/*
Method Description : Compile a report template xml file, and save the compiled report as a file, in the specified path
File name will be ReportName.jasper
Parameters
templateFilePath : path of the xml where the report is defined
reportPath : path where the compiled JasperReport object is going to be saved as a file
Return : created .jasper file
*/
public File compileReportTemplate(String templateFilePath,String reportPath){
File destFile = null;

try{



//get the file path of the xml template file and creates a JasperDesign object
JasperDesign jasperDesign = JRXmlLoader.load(templateFilePath);

//compile the JasperDesign object into a JasperReport object
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

//creates a file in the specified path
destFile = new File(reportPath + "/" + jasperReport.getName() + ".jasper");

//saves the JasperReport object into the created file
JRSaver.saveObject(jasperReport, destFile);
System.out.print("End of compileReportTemplate method");
}
catch(JRException e){
System.out.println(e.getMessage());
e.printStackTrace();
}

return destFile;
}

}
please help me to slove thia as i was strugglinhg with this for 3 days
thanks
Geoff Nihmrat
Greenhorn

Joined: Nov 12, 2004
Posts: 2
Getting the same problem when using resin 3.1

However things work fine when I override the xml configuration to use xerces.
So it seems like the parser is just missing the feature (go figure) :[
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jasper report error