所以我在过去一周左右的时间里完成了大量无用的谷歌搜索和堆栈探索,仍然无法让我的第一个.jrxml充满数据并转换为.pdf ...我真的如果你能用大量的手持技术来帮助我,那就表示赞赏。
使用Ant + Ivy编译我的.jrxml会给我带来3个错误,这些错误都与名为 mondrian 的模糊目录有关,具体来说:
tuples[idx] = new JRMondrianTuple(position, factory);
class file for Position not found
hierarchies[i] = new JRMondrianHierarchy(axisHierarchies[i]);
class file for Hierarchy not found
mondrianMember = new JRMondrianMember(member, this);
class file for Member not found
每个前面都有:
C:\jasperreports-6.3.0\src\net\sf\jasperreports\olap\mondrian\JR...java:...:
构建文件是:
<project name="aaa" default="test" basedir=".">
<property name="sample.dir" value="aaa"/>
<property name="sample.base.name" value="aaa"/>
<property name="sample.app.name" value="${sample.base.name}App"/>
<property name="sample.report.name" value="reportDesign.jrxml" />
<target name="javac">
<ant dir="../" target="javac"/>
</target>
<target name="compile">
<ant dir="../" target="compile"/>
</target>
<target name="test" >
<echo message="==================================="/>
<antcall target="javac" />
<antcall target="compile" />
<ant dir="../" target="test"/>
</target>
</project>
同时,使用以下方式以编程方式进行编译:
try {
JasperCompileManager.compileReportToFile(".reportDesign.jrxml","compiledReport.jasper");
System.out.println("Done!");
} catch (JRException e) {
e.printStackTrace();
}
给我错误(NoClassDefFoundError),添加外部JAR应该已经修复但没有。
Filling report...
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections/map/ReferenceMap
at net.sf.jasperreports.engine.component.ComponentsEnvironment.<init>(ComponentsEnvironment.java:56)
at net.sf.jasperreports.engine.component.ComponentsEnvironment.getInstance(ComponentsEnvironment.java:76)
at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.getSchemaLocations(JRReportSaxParserFactory.java:93)
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.configureParser(BaseSaxParserFactory.java:153)
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.createParser(BaseSaxParserFactory.java:108)
at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createParser(JRXmlDigesterFactory.java:1580)
at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createDigester(JRXmlDigesterFactory.java:1549)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:263)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:219)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:194)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:185)
at net.sf.jasperreports.engine.JasperCompileManager.compileToFile(JasperCompileManager.java:253)
at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:554)
at Main.main(Main.java:20)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.map.ReferenceMap
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 14 more