使用 Commandbox 4.7.0+00026,我正在尝试打开 Crystal Reports 文档以准备输出为 PDF。我无法打开文件,出现错误
java.lang.NoClassDefFoundError: com/crystaldecisions/reports/common/data/CrystalResultSet
在线的
var rd = rcd.open(reportPath, 0);
我已经确认 CrystalCommon2.jar 在 lib 文件夹中。
这是完整的 CommandBox 任务运行器:
component{
/*
The .jar files from Java Reporting Component SDK are copied to `box\engine\cfml\cli\cfml-web\lib`
*/
property name = "out" inject = "java:java.io.ByteArrayOutputStream";
property name = "crs" inject = "java:com.crystaldecisions.reports.common.data.CrystalResultSet";
property name = "crv" inject = "java:com.crystaldecisions.report.web.viewer.CrystalReportViewer";
property name = "oro" inject = "java:com.crystaldecisions.sdk.occa.report.application.OpenReportOptions";
property name = "rcd" inject = "java:com.crystaldecisions.sdk.occa.report.application.ReportClientDocument";
property name = "ref" inject = "java:com.crystaldecisions.sdk.occa.report.exportoptions.ReportExportFormat";
/* resources
http://www.javathinking.com/2011/09/using-crystal-reports-java-api-to.html
https://stackoverflow.com/questions/3178778/export-crystal-reports-to-pdf-in-java?rq=1
*/
function run(){
var reportPath = "c:\reports\Statement of Account.rpt";
var openAsReadOnly = oro._openAsReadOnly;
var inprocConnectionString = rcd.inprocConnectionString;
var rd = rcd.open(reportPath, 0);
out.reset();
}
}
一些资源表明存在 CRConfig.xml 需求,但我没有成功 - 尝试了无数位置。CRConfig.xml:
<?xml version="1.0" encoding="utf-8"?>
<CrystalReportEngine-configuration>
<reportlocation>..</reportlocation>
<timeout>0</timeout>
<ExternalFunctionLibraryClassNames>
<classname></classname>
</ExternalFunctionLibraryClassNames>
</CrystalReportEngine-configuration>
其他资源认为 CrystalReportsEngine-config.xml 必须存在。同样,不确定它应该放在哪里。
<?xml version="1.0" encoding="utf-8"?>
<CrystalReportEngine-configuration>
<reportlocation>c:\reports\</reportlocation>
<timeout>10</timeout>
<keycode>MyLicenseKeyCodeHere</keycode>
</CrystalReportEngine-configuration>