我正在尝试使用prpt从Java代码生成报告。但是在将数据写入pdf文件时失败,看起来像jar问题。
注意:从Kettle作业中调用prpt文件。
我尝试从项目中排除所有xml-apis
的maven依赖项。
KettleEnvironment.init();
JobMeta jobmeta = new JobMeta(fileName, repository);
Job job = new Job(repository, jobmeta);
job.initializeVariablesFrom(null);
job.getJobMeta().setInternalKettleVariables(job);
for(Entry<String, String> param: params.entrySet()) {
jobmeta.setParameterValue(param.getKey(), param.getValue());
}
job.copyParametersFrom(jobmeta);
job.activateParameters();
job.execute(0, null);
job.waitUntilFinished();
job.setFinished(true);
错误消息:
Caused by: org.pentaho.reporting.engine.classic.core.ReportDataFactoryException: Caught Kettle Exception: Check your configuration
at org.pentaho.reporting.engine.classic.extensions.datasources.kettle.KettleDataFactory.queryData(KettleDataFactory.java:100)
at org.pentaho.reporting.engine.classic.core.CompoundDataFactory.queryStaticInternal(CompoundDataFactory.java:172)
at org.pentaho.reporting.engine.classic.core.CompoundDataFactory.queryStatic(CompoundDataFactory.java:154)
at org.pentaho.reporting.engine.classic.core.cache.CachingDataFactory.queryInternal(CachingDataFactory.java:408)
at org.pentaho.reporting.engine.classic.core.cache.CachingDataFactory.queryStatic(CachingDataFactory.java:151)
at org.pentaho.reporting.engine.classic.core.CompoundDataFactory.queryStaticInternal(CompoundDataFactory.java:168)
at org.pentaho.reporting.engine.classic.core.CompoundDataFactory.queryStatic(CompoundDataFactory.java:154)
at org.pentaho.reporting.engine.classic.core.CompoundDataFactory.queryData(CompoundDataFactory.java:67)
at org.pentaho.reporting.engine.classic.core.states.datarow.DefaultFlowController.performQueryData(DefaultFlowController.java:256)
at org.pentaho.reporting.engine.classic.core.states.datarow.DefaultFlowController.performQuery(DefaultFlowController.java:192)
at org.pentaho.reporting.engine.classic.core.states.process.ProcessState.initializeForMasterReport(ProcessState.java:318)
at org.pentaho.reporting.engine.classic.core.layout.output.AbstractReportProcessor.prepareReportProcessing(AbstractReportProcessor.java:442)
at org.pentaho.reporting.engine.classic.core.layout.output.AbstractReportProcessor.processReport(AbstractReportProcessor.java:1433)
at org.pentaho.reporting.engine.classic.core.modules.gui.pdf.PdfExportTask.run(PdfExportTask.java:134)
at org.pentaho.di.trans.steps.pentahoreporting.PentahoReportingOutput.processReport(PentahoReportingOutput.java:278)
... 3 more
Caused by: java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V
at org.pentaho.reporting.libraries.base.util.XMLParserFactoryProducer.createSecureDocBuilderFactory(XMLParserFactoryProducer.java:36)
at org.pentaho.reporting.libraries.xmlns.parser.DomTreeResourceFactory.create(DomTreeResourceFactory.java:75)
at org.pentaho.reporting.libraries.resourceloader.DefaultResourceManagerBackend.create(DefaultResourceManagerBackend.java:225)
at org.pentaho.reporting.libraries.docbundle.BundleResourceManagerBackend.create(BundleResourceManagerBackend.java:142)
at org.pentaho.reporting.libraries.resourceloader.ResourceManager.create(ResourceManager.java:382)
at org.pentaho.reporting.libraries.resourceloader.ResourceManager.create(ResourceManager.java:334)
at org.pentaho.reporting.engine.classic.extensions.datasources.kettle.KettleTransFromFileProducer.loadTransformation(KettleTransFromFileProducer.java:124)
at org.pentaho.reporting.engine.classic.extensions.datasources.kettle.AbstractKettleTransformationProducer.performQuery(AbstractKettleTransformationProducer.java:232)
at org.pentaho.reporting.engine.classic.extensions.datasources.kettle.KettleDataFactory.queryData(KettleDataFactory.java:96)
答案 0 :(得分:0)
最后,我从一些博客中找到了解决方案。解决方案是在pom文件中添加以下依赖项。
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>`
添加此依赖项解决了我的问题java.lang.AbstractMethodError:javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava / lang / String; Z)V