问题描述
我正在使用JasperReport / ireport4,
我试图生成如下报告
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();}
}
但发生错误。
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
这是我的图书馆
推荐答案
对于使用maven遇到此错误的任何人:
To anyone using maven encountering this error:
找出哪个依赖项依赖于 xercesImpl.jar
并在POM中为给定的依赖项添加一个排除项,如下所示:
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>
在我的情况下,麻烦制造者的依赖是 jts
,所以这就是我的依赖声明现在的样子:
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>
如果您使用m2eclipse,您可以找到哪些依赖项导入 xercesImpl.jar
在POM编辑器的 Dependency Hierarchy 选项卡上。
If you are using m2eclipse, you can find which dependency imports xercesImpl.jar
on the Dependency Hierarchy tab of the POM editor.
这篇关于IllegalArgumentException:当使用Objects数组作为SCHEMA_SOURCE属性的值时,没有两个Schema应该共享同一个targetNamespace的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!