Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.ClassCastException error when running render task to "postscript" format #1010

Closed
ivkina opened this issue Jul 12, 2022 · 9 comments · Fixed by #1015
Closed

java.lang.ClassCastException error when running render task to "postscript" format #1010

ivkina opened this issue Jul 12, 2022 · 9 comments · Fixed by #1015

Comments

@ivkina
Copy link

ivkina commented Jul 12, 2022

Happens with any report using latest BIRT runtime. It never happened with previous version of BIRT. We are using postscript in some cases when we print reports to a printer and need to tweak print options like collate, number of copies, scale, etc.

Here the simple task render code that fails:

IReportEngine engine = ...;
IReportDocument roiDoc = engine.openReportDocument("//.../file.rptdocument");
IRenderTask task = engine.createRenderTask(roiDoc);
task.setPageNumber(1);
IPostscriptRenderOption options = new PostscriptRenderOption();
options.setOutputFormat("postscript");
options.setPostscriptLevel(3);
options.setAutoPaperSizeSelection(true);
options.setCopies(2);

OutputStream stream = new ByteArrayOutputStream();
task.getRenderOption().setOutputStream(stream);

task.render();

Getting the error below on task.render() call - please, see stack trace.

Thanks,
Aleksey

Jul 12, 2022 10:09:19 AM org.eclipse.birt.report.engine.api.impl.EngineTask handleFatalExceptions
SEVERE: An error happened while running the report. Cause:
java.lang.ClassCastException: class java.util.HashMap cannot be cast to class java.util.Properties (java.util.HashMap and java.util.Properties are in module java.base of loader 'bootstrap')
at org.eclipse.birt.report.engine.emitter.postscript.PostscriptWriter.getFontPath(PostscriptWriter.java:741)
at org.eclipse.birt.report.engine.emitter.postscript.PostscriptWriter.applyFont(PostscriptWriter.java:682)
at org.eclipse.birt.report.engine.emitter.postscript.PostscriptWriter.drawString(PostscriptWriter.java:538)
at org.eclipse.birt.report.engine.emitter.postscript.device.PostscriptPage.drawText(PostscriptPage.java:77)
at org.eclipse.birt.report.engine.layout.emitter.AbstractPage.drawText(AbstractPage.java:97)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.drawTextAt(PageDeviceRender.java:703)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.drawText(PageDeviceRender.java:696)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.visitText(PageDeviceRender.java:142)
at org.eclipse.birt.report.engine.nLayout.area.impl.TextArea.accept(TextArea.java:211)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.visitChildren(PageDeviceRender.java:176)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.visitContainer(PageDeviceRender.java:167)
at org.eclipse.birt.report.engine.nLayout.area.impl.ContainerArea.accept(ContainerArea.java:244)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.visitChildren(PageDeviceRender.java:176)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.visitContainer(PageDeviceRender.java:167)
at org.eclipse.birt.report.engine.nLayout.area.impl.ContainerArea.accept(ContainerArea.java:244)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.visitChildren(PageDeviceRender.java:176)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.visitContainer(PageDeviceRender.java:167)
at org.eclipse.birt.report.engine.nLayout.area.impl.ContainerArea.accept(ContainerArea.java:244)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.visitChildren(PageDeviceRender.java:176)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.visitContainer(PageDeviceRender.java:167)
at org.eclipse.birt.report.engine.nLayout.area.impl.ContainerArea.accept(ContainerArea.java:244)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.visitChildren(PageDeviceRender.java:176)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.visitContainer(PageDeviceRender.java:167)
at org.eclipse.birt.report.engine.nLayout.area.impl.ContainerArea.accept(ContainerArea.java:244)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.visitChildren(PageDeviceRender.java:176)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.addPage(PageDeviceRender.java:435)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.visitPage(PageDeviceRender.java:405)
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.visitContainer(PageDeviceRender.java:164)
at org.eclipse.birt.report.engine.nLayout.area.impl.ContainerArea.accept(ContainerArea.java:244)
at org.eclipse.birt.report.engine.layout.emitter.PageEmitter.startPage(PageEmitter.java:50)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.outputPage(LayoutEngine.java:730)
at org.eclipse.birt.report.engine.nLayout.area.impl.PageArea.outputPage(PageArea.java:555)
at org.eclipse.birt.report.engine.nLayout.area.impl.PageArea.close(PageArea.java:539)
at org.eclipse.birt.report.engine.nLayout.area.impl.RootArea.close(RootArea.java:192)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.closeContainer(LayoutEngine.java:301)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine._endContainer(LayoutEngine.java:378)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.endContainer(LayoutEngine.java:290)
at org.eclipse.birt.report.engine.emitter.ContentEmitterAdapter.endPage(ContentEmitterAdapter.java:72)
at org.eclipse.birt.report.engine.emitter.ContentEmitterUtil.endContent(ContentEmitterUtil.java:98)
at org.eclipse.birt.report.engine.layout.html.buffer.DummyPageBuffer.endContainer(DummyPageBuffer.java:58)
at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.end(HTMLPageLM.java:167)
at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:97)
at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:97)
at org.eclipse.birt.report.engine.api.impl.RenderTask$PageRangeRender.render(RenderTask.java:547)
at org.eclipse.birt.report.engine.api.impl.RenderTask.render(RenderTask.java:273)
at com.deltek.enterprise.system.reporting.birt.engine.BirtNativeConnectionImpl.renderReportPostScript(BirtNativeConnectionImpl.java:1895)
at com.deltek.enterprise.system.reporting.birt.engine.BirtNativeConnectionImpl.getReportData(BirtNativeConnectionImpl.java:447)
at com.deltek.enterprise.system.reporting.birt.engine.BirtNativeConnectionImpl.print(BirtNativeConnectionImpl.java:385)
at com.deltek.enterprise.system.reporting.birt.engine.BirtConnectionImpl.print(BirtConnectionImpl.java:253)
at com.deltek.enterprise.system.reporting.birt.handlers.BirtPrintRequestHandler.print(BirtPrintRequestHandler.java:219)
at com.deltek.enterprise.system.reporting.birt.handlers.BirtPrintRequestHandler.handleRequest(BirtPrintRequestHandler.java:66)
at com.deltek.enterprise.system.reporting.handlers.RequestHandlerChain.handleRequest(RequestHandlerChain.java:38)
at com.deltek.enterprise.system.reporting.birt.application.BirtAppReportRuntime.startRpt(BirtAppReportRuntime.java:204)
at com.deltek.enterprise.system.reporting.birt.application.BirtAppReportRuntime.run(BirtAppReportRuntime.java:82)
at com.deltek.enterprise.system.appmanagement.ReportDispatcher.run(ReportDispatcher.java:328)
at com.deltek.enterprise.system.appmanagement.AppResultSet.doProcessReport(AppResultSet.java:2698)
at com.deltek.enterprise.system.appmanagement.AppResultSet.dispatcherMain(AppResultSet.java:498)
at com.deltek.enterprise.system.appmanagement.AppResultSet.dispatcher(AppResultSet.java:346)
at com.deltek.enterprise.system.appmanagement.Application.dispatcher(Application.java:466)
at com.deltek.enterprise.system.appmanagement.MasterServer.dispatcher(MasterServer.java:798)
at com.deltek.enterprise.system.serverapi.serverapiimpl.masterbean.MasterEJB.dispatcher(MasterEJB.java:34)
at com.deltek.enterprise.system.serverapi.serverapiimpl.masterbean.Master_k2sks9_EOImpl.__WL_invoke(Unknown Source)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invokeInternal(SessionRemoteMethodInvoker.java:54)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:21)
at com.deltek.enterprise.system.serverapi.serverapiimpl.masterbean.Master_k2sks9_EOImpl.dispatcher(Unknown Source)
at com.deltek.enterprise.system.servlets.masterservlet.MasterServlet.service(MasterServlet.java:392)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:295)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:260)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:137)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:353)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:250)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3862)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3829)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:344)
at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
at weblogic.servlet.internal.WebAppServletContext.processSecuredExecute(WebAppServletContext.java:2502)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2351)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2326)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2304)
at weblogic.servlet.internal.ServletRequestImpl.runInternal(ServletRequestImpl.java:1779)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1733)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:272)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:352)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:337)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:57)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:651)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:420)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:360)

claesrosell added a commit to claesrosell/birt that referenced this issue Jul 21, 2022
During reflective access to the "trueTypeFonts" field of
"FontFactoryImpl" the type "Properties" was assumed, but the type has
changed to "HashMap" in OpenPDF. Stopped using reflective access to the
field since there are now API to access the content of "trueTypeFonts".
claesrosell added a commit that referenced this issue Jul 21, 2022
During reflective access to the "trueTypeFonts" field of
"FontFactoryImpl" the type "Properties" was assumed, but the type has
changed to "HashMap" in OpenPDF. Stopped using reflective access to the
field since there are now API to access the content of "trueTypeFonts".
@claesrosell claesrosell reopened this Jul 21, 2022
@claesrosell
Copy link
Contributor

I was a bit fast to merge this change. @ivkina , can you test this build (https://github.com/eclipse/birt/actions/runs/2710745400) when it is done and see if it solves your problem?

@ivkina
Copy link
Author

ivkina commented Jul 21, 2022 via email

@claesrosell
Copy link
Contributor

How are you currently consuming Birt?

@ivkina
Copy link
Author

ivkina commented Jul 21, 2022 via email

@ivkina
Copy link
Author

ivkina commented Jul 21, 2022 via email

@hvbtup
Copy link
Contributor

hvbtup commented Jul 21, 2022

Aleksey, please try to avoid copying the previous message when you reply by email.
It's better to answer directly by clicking on the "view it on GitHub" link.

If you are using the BIRT report engine jars, then you can find them generated automatically from Claes' PR.
Open https://github.com/eclipse/birt/actions/runs/2710745400 and look for the birt-runtime artifact. It contains the JARs you are looking for. Be careful: Do not just add them to the existing JARs, because the files contain version numbers. Before copying the JARs, first remove all the old JARs.

@ivkina
Copy link
Author

ivkina commented Jul 21, 2022

Got it, Thanks for the fix! It is working now for postscript.

How should we consume the fix? Just take all the jars from birt-runtime artifact here or will it be there some kind of an "official" release to download?

Sorry for many questions and thanks again,
Aleksey

@claesrosell
Copy link
Contributor

Next official release will be 4.10. I think that we aim to release 4.10 in alignment to 2022-09, but I really do not know.
Overall I would say that the current state of master is better then 4.9.

@ivkina
Copy link
Author

ivkina commented Jul 21, 2022

Thanks for this update! Will take the fix for now and then upgrade to 4.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants