2

私は 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

ここに私のライブラリがあります

ここに画像の説明を入力

4

3 に答える 3

2

このエラーが発生した 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 を使用している場合は、POM エディターの [依存関係階層xercesImpl.jar] タブで、どの依存関係がインポートされるかを確認できます。

于 2013-04-04T10:43:51.787 に答える
0

クラスパスにxerces.jarがありますか?JasperReportsにはすでに1つあり、古いバージョンを使用している場合は、競合が発生する可能性があります。その場合は、JRが提供するものだけを使用してみてください。

于 2011-08-27T13:07:37.470 に答える
0
<dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.6.0</version>
</dependency>

maven を使用してこの依存関係を追加します。それは問題を解決します。

于 2019-07-19T03:57:06.910 に答える