过去几周我一直在使用 JasperReports,尽管我遵循了教程,但我无法实现 Scriptlet(例如 https://community.jaspersoft.com/blog/scriptlet-example-jaspersoft- 6x-begineers-hello-world-sample-example) 到牙齿。
我有一个名为 ImageFormatterScriptlet 的 scriptlet,现在我只想运行它。它在预览中执行,但在使用 java 代码编译时则不然。
我总是收到以下错误:
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
C:\develop\eclipse-installations\integration1\eclipse\rm_requirementsTypes_1554205368772_548397.java:272: error: package enco.sox2.cdo.server.reports.internal.scriptlets does not exist
value = ((enco.sox2.cdo.server.reports.internal.scriptlets.ImageFormatterScriptlet)parameter_ImageFormatterScriptlet_SCRIPTLET.getValue()).extractImagesAndSave(); //$JR_EXPR_ID=23$
^
C:\develop\eclipse-installations\integration1\eclipse\rm_requirementsTypes_1554205368772_548397.java:410: error: package enco.sox2.cdo.server.reports.internal.scriptlets does not exist
value = ((enco.sox2.cdo.server.reports.internal.scriptlets.ImageFormatterScriptlet)parameter_ImageFormatterScriptlet_SCRIPTLET.getValue()).extractImagesAndSave(); //$JR_EXPR_ID=23$
^
C:\develop\eclipse-installations\integration1\eclipse\rm_requirementsTypes_1554205368772_548397.java:548: error: package enco.sox2.cdo.server.reports.internal.scriptlets does not exist
value = ((enco.sox2.cdo.server.reports.internal.scriptlets.ImageFormatterScriptlet)parameter_ImageFormatterScriptlet_SCRIPTLET.getValue()).extractImagesAndSave(); //$JR_EXPR_ID=23$
^
3 errors
.
Filling out enco/sox2/rm/master_report.jrxml
我认为可能是: 无法解析为 Jaspersoft Studio 类型
但事实并非如此。
我导入 jar,创建 scriptlet,但它总是抛出此异常!该类位于所述文件夹中,由于它在预览中工作,所以我完全傻眼了。
我正在使用 Windows 7、JasperReports Plugin for Eclipse、6.1.1(我知道,它很旧)
编辑:有时重新启动后会抛出此异常:
[ERROR] net.sf.jasperreports.engine.JRException: Error loading scriptlet class: enco.sox2.workspace.ImageFormatterScriptlet.
enco.sox2.reportmanager.ReportException: net.sf.jasperreports.engine.JRException: Error loading scriptlet class: enco.sox2.workspace.ImageFormatterScriptlet.
at enco.sox2.reportmanager.ReportCommand.fillReport(ReportCommand.java:110)
at enco.sox2.reportmanager.ReportCommand.export(ReportCommand.java:165)
at enco.sox2.reportmanager.ReportCommand.export(ReportCommand.java:159)
at enco.sox2.reportmanager.ReportManager.generateReportToStream(ReportManager.java:175)
at enco.sox2.cdo.server.reports.service.CdoReportService.generateReportToStream(CdoReportService.java:87)
at enco.sox2.workspace.cdo.server.internal.CreateReportIndication.responding(CreateReportIndication.java:103)
at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndicationWithMonitoring.responding(CDOServerIndicationWithMonitoring.java:177)
at org.eclipse.net4j.signal.IndicationWithMonitoring.responding(IndicationWithMonitoring.java:93)
at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedOutput(IndicationWithResponse.java:106)
at org.eclipse.net4j.signal.Signal.doOutput(Signal.java:346)
at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:75)
at org.eclipse.net4j.signal.IndicationWithMonitoring.execute(IndicationWithMonitoring.java:66)
at org.eclipse.net4j.signal.Signal.runSync(Signal.java:283)
at org.eclipse.net4j.signal.Signal.run(Signal.java:162)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: net.sf.jasperreports.engine.JRException: Error loading scriptlet class: enco.sox2.workspace.ImageFormatterScriptlet.
at net.sf.jasperreports.engine.scriptlets.DefaultScriptletFactory.getScriptlet(DefaultScriptletFactory.java:115)
at net.sf.jasperreports.engine.scriptlets.DefaultScriptletFactory.getScriplets(DefaultScriptletFactory.java:90)
at net.sf.jasperreports.engine.fill.JRFillDataset.createScriptlets(JRFillDataset.java:512)
at net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:631)
at net.sf.jasperreports.engine.fill.BaseReportFiller.setParameters(BaseReportFiller.java:436)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:523)
at net.sf.jasperreports.parts.subreport.SubreportFillPart.fill(SubreportFillPart.java:174)
at net.sf.jasperreports.engine.part.FillPart.fill(FillPart.java:77)
at net.sf.jasperreports.engine.fill.PartReportFiller.fillPart(PartReportFiller.java:406)
at net.sf.jasperreports.engine.fill.PartReportFiller.fillParts(PartReportFiller.java:385)
at net.sf.jasperreports.engine.fill.PartReportFiller.fillDetail(PartReportFiller.java:337)
at net.sf.jasperreports.engine.fill.PartReportFiller.fillReport(PartReportFiller.java:280)
at net.sf.jasperreports.engine.fill.PartReportFiller.fill(PartReportFiller.java:214)
at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:396)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:91)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:456)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:863)
at enco.sox2.reportmanager.ReportCommand.fillReport(ReportCommand.java:97)
... 16 more
Caused by: java.lang.ClassNotFoundException: enco.sox2.workspace.ImageFormatterScriptlet cannot be found by enco.sox2.jasperreports_1.0.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:484)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:395)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:387)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:174)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRClassLoader.java:114)
at net.sf.jasperreports.engine.scriptlets.DefaultScriptletFactory.getScriptlet(DefaultScriptletFactory.java:110)
... 33 more
!ENTRY enco.sox2.cdo.server.reports 4 0 2019-04-02 15:13:16.794
!MESSAGE net.sf.jasperreports.engine.JRException: Error loading scriptlet class: enco.sox2.workspace.ImageFormatterScriptlet.
!STACK 0
enco.sox2.reportmanager.ReportException: net.sf.jasperreports.engine.JRException: Error loading scriptlet class: enco.sox2.workspace.ImageFormatterScriptlet.
at enco.sox2.reportmanager.ReportCommand.fillReport(ReportCommand.java:110)
at enco.sox2.reportmanager.ReportCommand.export(ReportCommand.java:165)
at enco.sox2.reportmanager.ReportCommand.export(ReportCommand.java:159)
at enco.sox2.reportmanager.ReportManager.generateReportToStream(ReportManager.java:175)
at enco.sox2.cdo.server.reports.service.CdoReportService.generateReportToStream(CdoReportService.java:87)
at enco.sox2.workspace.cdo.server.internal.CreateReportIndication.responding(CreateReportIndication.java:103)
at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndicationWithMonitoring.responding(CDOServerIndicationWithMonitoring.java:177)
at org.eclipse.net4j.signal.IndicationWithMonitoring.responding(IndicationWithMonitoring.java:93)
at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedOutput(IndicationWithResponse.java:106)
at org.eclipse.net4j.signal.Signal.doOutput(Signal.java:346)
at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:75)
at org.eclipse.net4j.signal.IndicationWithMonitoring.execute(IndicationWithMonitoring.java:66)
at org.eclipse.net4j.signal.Signal.runSync(Signal.java:283)
at org.eclipse.net4j.signal.Signal.run(Signal.java:162)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: net.sf.jasperreports.engine.JRException: Error loading scriptlet class: enco.sox2.workspace.ImageFormatterScriptlet.
at net.sf.jasperreports.engine.scriptlets.DefaultScriptletFactory.getScriptlet(DefaultScriptletFactory.java:115)
at net.sf.jasperreports.engine.scriptlets.DefaultScriptletFactory.getScriplets(DefaultScriptletFactory.java:90)
at net.sf.jasperreports.engine.fill.JRFillDataset.createScriptlets(JRFillDataset.java:512)
at net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:631)
at net.sf.jasperreports.engine.fill.BaseReportFiller.setParameters(BaseReportFiller.java:436)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:523)
at net.sf.jasperreports.parts.subreport.SubreportFillPart.fill(SubreportFillPart.java:174)
at net.sf.jasperreports.engine.part.FillPart.fill(FillPart.java:77)
at net.sf.jasperreports.engine.fill.PartReportFiller.fillPart(PartReportFiller.java:406)
at net.sf.jasperreports.engine.fill.PartReportFiller.fillParts(PartReportFiller.java:385)
at net.sf.jasperreports.engine.fill.PartReportFiller.fillDetail(PartReportFiller.java:337)
at net.sf.jasperreports.engine.fill.PartReportFiller.fillReport(PartReportFiller.java:280)
at net.sf.jasperreports.engine.fill.PartReportFiller.fill(PartReportFiller.java:214)
at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:396)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:91)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:456)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:863)
at enco.sox2.reportmanager.ReportCommand.fillReport(ReportCommand.java:97)
... 16 more
Caused by: java.lang.ClassNotFoundException: enco.sox2.workspace.ImageFormatterScriptlet cannot be found by enco.sox2.jasperreports_1.0.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:484)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:395)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:387)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:174)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRClassLoader.java:114)
at net.sf.jasperreports.engine.scriptlets.DefaultScriptletFactory.getScriptlet(DefaultScriptletFactory.java:110)
... 33 more
我该如何解决这个问题?
提前致谢。
当你提到“我导入jar”时,你的意思是把jar放在你的jasperserver目录下吗?如果没有,您必须这样做,即您将需要,
就我而言,我发现
Error loading Scriptlet class
是通过添加jar文件解决的,参考error-loading-scriptlet-class和JRAbstractScriptlet。