开发者

IllegalArgumentException: When using array of Objects as the value of SCHEMA_SOURCE property , no two Schemas should share the same targetNamespace

I am using JasperReport/ireport4, I tried to generate a report as below

public void fillReport() throws ParseException, groovyjarjarcommonscli.ParseException, IOException {

    try {
        Driver monDriver = new com.mysql.jdbc.Driver();
        DriverManager.registerDriver(开发者_开发知识库monDriver);
        connection = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/MyDB","", "");
        Map mymap = new HashMap();
        mymap.put("Title", MyTitle);
        mymap.put("legend", legend);
        mymap.put("SQL", Query());
        FacesContext facesContext = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
        InputStream reportStream = facesContext.getExternalContext().getResourceAsStream("C:/Documents and Settings/report2.jasper");
        ServletOutputStream servletOutputStream = response.getOutputStream();
        facesContext.responseComplete();
        response.setContentType("C:/Documents and Settings/report2.pdf");
        JasperRunManager.runReportToPdfStream(reportStream, servletOutputStream, mymap, connection);
        connection.close();
        servletOutputStream.flush();
        servletOutputStream.close();
    } catch (JRException e) {

        e.printStackTrace();}
}

but an error occured.

Caused by: java.lang.IllegalArgumentException:  When using array of Objects as the value of SCHEMA_SOURCE property , no two Schemas should share the same targetNamespace. 
    at org.apache.xerces.impl.xs.XMLSchemaLoader.processJAXPSchemaSource(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.findSchemaGrammar(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.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.DTDConfiguration.parse(Unknown Source)
    at org.apache.xerces.parsers.DTDConfiguration.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:241)
    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.xml.JRXmlLoader.load(JRXmlLoader.java:170)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:154)
    at DAOKPI.Bean.fillReport(Bean.java:1139)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:737)
    at javax.el.BeanELResolver.invoke(BeanELResolver.java:467)
    at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:254)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:228)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:148)
    ... 34 more

here are my libraries

IllegalArgumentException: When using array of Objects as the value of SCHEMA_SOURCE property , no two Schemas should share the same targetNamespace


To anyone using maven encountering this error:

Find out which one of your dependencies has a dependency on xercesImpl.jar and add an exclusion to the given dependency in your POM like so:

<dependency>
    ...
    <exclusions>
    <exclusion>
        <groupId>xerces</groupId>
        <artifactId>xercesImpl</artifactId>
        </exclusion>
    </exclusions>
</dependency>

In my case, the troublemaker dependency was jts, so this is what my dependency declaration now looks like:

<dependency>
    <groupId>com.vividsolutions</groupId>
    <artifactId>jts</artifactId>
    <version>1.11</version>
    <exclusions>
        <exclusion>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            </exclusion>
    </exclusions> 
</dependency>

If you are using m2eclipse, you can find which dependency imports xercesImpl.jar on the Dependency Hierarchy tab of the POM editor.


Do you have xerces.jar in your classpath? Because JasperReports has one already and if you have an older version then there might be conflicts. If so then try using only the one provided by JR.


<dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.6.0</version>
</dependency>

add this dependency using maven. it will solve the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜