IllegalArgumentException: при использовании массива объектов в качестве значения свойства SCHEMA_SOURCE никакие две схемы не должны совместно использовать одно и то же targetNamespace - PullRequest
1 голос
/ 27 августа 2011

Я использую JasperReport / ireport4, я попытался сгенерировать отчет как показано ниже

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();}
}

, но произошла ошибка.

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

вот мои библиотеки

enter image description here

Ответы [ 2 ]

2 голосов
/ 04 апреля 2013

Для всех, кто использует maven, встречается эта ошибка:

Узнайте, какая из ваших зависимостей имеет зависимость от xercesImpl.jar и добавьте исключение к данной зависимости в вашем POM, например:

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

В моем случае зависимость смутьяна была jts, так вот как теперь выглядит мое объявление зависимости:

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

Если вы используете m2eclipse, вы можете найти, какую зависимость импортировать xercesImpl.jar на вкладке Иерархия зависимостей редактора POM.

0 голосов
/ 27 августа 2011

У вас есть xerces.jar в вашем классе? Поскольку JasperReports уже есть, и если у вас более старая версия, то могут возникнуть конфликты. Если это так, попробуйте использовать только тот, который предоставлен JR.

...