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

Error generating reports with barcodes on native image #156

Closed
redddcyclone opened this issue Oct 29, 2024 · 43 comments · Fixed by #157
Closed

Error generating reports with barcodes on native image #156

redddcyclone opened this issue Oct 29, 2024 · 43 comments · Fixed by #157
Assignees
Labels
bug Something isn't working

Comments

@redddcyclone
Copy link

redddcyclone commented Oct 29, 2024

Hello all,

I'm getting the following errors when generating reports containing barcodes (Barcode4J) on a native image application:

10:56:46,634 SEVERE [org.primefaces.application.exceptionhandler.PrimeExceptionHandler] java.awt.Component.x: java.lang.NoSuchFieldError: java.awt.Component.x
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$Support.getFieldID(JNIFunctions.java:1357)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions.GetFieldID(JNIFunctions.java:449)
        at [email protected]/java.awt.Component.initIDs(Native Method)
        at [email protected]/java.awt.Component.<clinit>(Component.java:627)
        at [email protected]/java.lang.Class.ensureInitialized(DynamicHub.java:604)
        at [email protected]/sun.awt.CustomCursor.<init>(CustomCursor.java:48)
        at [email protected]/sun.awt.X11CustomCursor.<init>(X11CustomCursor.java:44)
        at [email protected]/sun.awt.X11.XCustomCursor.<init>(XCustomCursor.java:43)
        at [email protected]/sun.awt.X11.XToolkit.createCustomCursor(XToolkit.java:1201)
        at org.apache.batik.bridge.CursorManager.<clinit>(CursorManager.java:146)
        at org.apache.batik.bridge.BridgeContext.<init>(BridgeContext.java:1162)
        at org.apache.batik.bridge.BridgeContext.<init>(BridgeContext.java:292)
        at net.sf.jasperreports.renderers.AbstractSvgDataToGraphics2DRenderer.getRootNode(AbstractSvgDataToGraphics2DRenderer.java:170)
        at net.sf.jasperreports.renderers.AbstractSvgDataToGraphics2DRenderer.getDimension(AbstractSvgDataToGraphics2DRenderer.java:122)
        at net.sf.jasperreports.pdf.JRPdfExporter$InternalImageProcessor.processGraphics2D(JRPdfExporter.java:2015)
        at net.sf.jasperreports.pdf.JRPdfExporter$InternalImageProcessor.process(JRPdfExporter.java:1707)
        at net.sf.jasperreports.pdf.JRPdfExporter$InternalImageProcessor.access$1300(JRPdfExporter.java:1657)
        at net.sf.jasperreports.pdf.JRPdfExporter.exportImage(JRPdfExporter.java:1597)
        at net.sf.jasperreports.pdf.JRPdfExporter.exportElements(JRPdfExporter.java:1262)
        at net.sf.jasperreports.pdf.JRPdfExporter.exportPage(JRPdfExporter.java:1211)
        at net.sf.jasperreports.pdf.JRPdfExporter.exportReportToStream(JRPdfExporter.java:1104)
        at net.sf.jasperreports.pdf.JRPdfExporter.exportReport(JRPdfExporter.java:667)
        at com.blahblah.blah.util.RelatorioUtil.geraArquivoRelatorio(RelatorioUtil.java:158)
        at com.blahblah.blah.util.RelatorioUtil.gerarRelatorio(RelatorioUtil.java:74)
        at com.blahblah.blah.util.RelatorioUtil.gerarRelatorio(RelatorioUtil.java:88)
        at com.blahblah.blah.controller.administrativo.deposito.DepositoProdutoComPatrimonioBean.actionImprimirEtiquetas(DepositoProdutoComPatrimonioBean.java:189)
        at com.blahblah.blah.controller.administrativo.deposito.DepositoProdutoComPatrimonioBean_ClientProxy.actionImprimirEtiquetas(Unknown Source)
        at [email protected]/java.lang.reflect.Method.invoke(Method.java:580)
        at org.apache.el.parser.AstValue.invoke(AstValue.java:253)
        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:267)
        at org.apache.myfaces.view.facelets.el.ContextAwareTagMethodExpression.invoke(ContextAwareTagMethodExpression.java:96)
        at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:67)
        at org.primefaces.application.DialogActionListener.processAction(DialogActionListener.java:54)
        at jakarta.faces.component.UICommand.broadcast(UICommand.java:65)
        at jakarta.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:1245)
        at jakarta.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:426)
        at jakarta.faces.component.UIViewRoot._process(UIViewRoot.java:1717)
        at jakarta.faces.component.UIViewRoot.processApplication(UIViewRoot.java:927)
        at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:43)
        at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:172)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:125)
        at jakarta.faces.webapp.FacesServlet.service(FacesServlet.java:223)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:63)
        at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:67)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:133)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:65)
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:247)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:111)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:108)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$9$1.call(UndertowDeploymentRecorder.java:645)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:152)
        at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:91)
        at io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$1.handleRequest(UndertowDeploymentRecorder.java:126)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:284)
        at io.undertow.server.DefaultExchangeHandler.handle(DefaultExchangeHandler.java:18)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$5$2.run(UndertowDeploymentRecorder.java:445)
        at [email protected]/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
        at [email protected]/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at [email protected]/java.lang.Thread.runWith(Thread.java:1596)
        at [email protected]/java.lang.Thread.run(Thread.java:1583)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:896)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:872)
10:58:58,454 SEVERE [org.primefaces.application.exceptionhandler.PrimeExceptionHandler] Could not initialize class org.apache.batik.bridge.CursorManager: java.lang.NoClassDefFoundError: Could not initialize class org.apache.batik.bridge.CursorManager
        at org.apache.batik.bridge.BridgeContext.<init>(BridgeContext.java:1162)
        at org.apache.batik.bridge.BridgeContext.<init>(BridgeContext.java:292)
        at net.sf.jasperreports.renderers.AbstractSvgDataToGraphics2DRenderer.getRootNode(AbstractSvgDataToGraphics2DRenderer.java:170)
        at net.sf.jasperreports.renderers.AbstractSvgDataToGraphics2DRenderer.getDimension(AbstractSvgDataToGraphics2DRenderer.java:122)
        at net.sf.jasperreports.pdf.JRPdfExporter$InternalImageProcessor.processGraphics2D(JRPdfExporter.java:2015)
        at net.sf.jasperreports.pdf.JRPdfExporter$InternalImageProcessor.process(JRPdfExporter.java:1707)
        at net.sf.jasperreports.pdf.JRPdfExporter$InternalImageProcessor.access$1300(JRPdfExporter.java:1657)
        at net.sf.jasperreports.pdf.JRPdfExporter.exportImage(JRPdfExporter.java:1597)
        at net.sf.jasperreports.pdf.JRPdfExporter.exportElements(JRPdfExporter.java:1262)
        at net.sf.jasperreports.pdf.JRPdfExporter.exportPage(JRPdfExporter.java:1211)
        at net.sf.jasperreports.pdf.JRPdfExporter.exportReportToStream(JRPdfExporter.java:1104)
        at net.sf.jasperreports.pdf.JRPdfExporter.exportReport(JRPdfExporter.java:667)
        at com.blahblah.blah.util.RelatorioUtil.geraArquivoRelatorio(RelatorioUtil.java:158)
        at com.blahblah.blah.util.RelatorioUtil.gerarRelatorio(RelatorioUtil.java:74)
        at com.blahblah.blah.util.RelatorioUtil.gerarRelatorio(RelatorioUtil.java:88)
        at com.blahblah.blah.controller.administrativo.deposito.DepositoProdutoAguardandoPatrimonioBean.actionImprimirEtiquetas(DepositoProdutoAguardandoPatrimonioBean.java:150)
        at com.blahblah.blah.controller.administrativo.deposito.DepositoProdutoAguardandoPatrimonioBean_ClientProxy.actionImprimirEtiquetas(Unknown Source)
        at [email protected]/java.lang.reflect.Method.invoke(Method.java:580)
        at org.apache.el.parser.AstValue.invoke(AstValue.java:253)
        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:267)
        at org.apache.myfaces.view.facelets.el.ContextAwareTagMethodExpression.invoke(ContextAwareTagMethodExpression.java:96)
        at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:67)
        at org.primefaces.application.DialogActionListener.processAction(DialogActionListener.java:54)
        at jakarta.faces.component.UICommand.broadcast(UICommand.java:65)
        at jakarta.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:1245)
        at jakarta.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:426)
        at jakarta.faces.component.UIViewRoot._process(UIViewRoot.java:1717)
        at jakarta.faces.component.UIViewRoot.processApplication(UIViewRoot.java:927)
        at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:43)
        at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:172)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:125)
        at jakarta.faces.webapp.FacesServlet.service(FacesServlet.java:223)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:63)
        at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:67)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:133)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:65)
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:247)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:111)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:108)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$9$1.call(UndertowDeploymentRecorder.java:645)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:152)
        at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:91)
        at io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$1.handleRequest(UndertowDeploymentRecorder.java:126)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:284)
        at io.undertow.server.DefaultExchangeHandler.handle(DefaultExchangeHandler.java:18)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$5$2.run(UndertowDeploymentRecorder.java:445)
        at [email protected]/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
        at [email protected]/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at [email protected]/java.lang.Thread.runWith(Thread.java:1596)
        at [email protected]/java.lang.Thread.run(Thread.java:1583)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:896)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:872)

The AWT related error happens on the first try only. Then the CursorManager related one happens every time I try to generate a report with barcodes.

These are the elements in the .jrxml files:

<element kind="component" uuid="06dfb06b-9d18-442d-af20-78384f162156" x="25" y="189" width="192" height="32">
	<component kind="barcode4j:Code39">
		<codeExpression><![CDATA[$F{patr_temporario}]]></codeExpression>
	</component>
	<property name="com.jaspersoft.studio.unit.x" value="px"/>
	<property name="com.jaspersoft.studio.unit.y" value="px"/>
	<property name="com.jaspersoft.studio.unit.width" value="px"/>
	<property name="com.jaspersoft.studio.unit.height" value="px"/>
</element>
<element kind="component" uuid="59ba84fb-e3cc-4b85-804a-40344ab342c5" x="0" y="9" width="128" height="31">
	<component kind="barcode4j:Code39">
		<codeExpression><![CDATA[$F{patr_temporario}]]></codeExpression>
	</component>
	<property name="com.jaspersoft.studio.unit.x" value="px"/>
	<property name="com.jaspersoft.studio.unit.y" value="px"/>
	<property name="com.jaspersoft.studio.unit.width" value="px"/>
	<property name="com.jaspersoft.studio.unit.height" value="px"/>
</element>
<element kind="component" uuid="1f3d7d3c-9a1f-4d7d-9f12-43a5c5985a53" x="25" y="202" width="192" height="32">
	<component kind="barcode4j:Code39">
		<codeExpression><![CDATA[$F{numero}]]></codeExpression>
	</component>
	<property name="com.jaspersoft.studio.unit.x" value="px"/>
	<property name="com.jaspersoft.studio.unit.y" value="px"/>
	<property name="com.jaspersoft.studio.unit.width" value="px"/>
	<property name="com.jaspersoft.studio.unit.height" value="px"/>
</element>

Thanks in advance!

@redddcyclone
Copy link
Author

Also, I don't know if it's related, but is this warning normal?

[WARNING] [io.quarkus.arc.deployment.SplitPackageProcessor] Detected a split package usage which is considered a bad practice and should be avoided. Following packages were detected in multiple archives:
- "org.krysalis.barcode4j" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.impl" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.impl.upcean" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.impl.codabar" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.impl.postnet" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.tools" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.impl.datamatrix" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.impl.int2of5" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.impl.fourstate" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.output.bitmap" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.output.eps" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.impl.pdf417" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.output.svg" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.impl.code39" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.output" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.impl.code128" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]
- "org.krysalis.barcode4j.output.java2d" found in [net.sf.barcode4j:barcode4j:2.1, org.primefaces.extensions:barcode4j-light:2.3.0]

It happens in both dev and native mode

@redddcyclone
Copy link
Author

redddcyclone commented Oct 29, 2024

Also, I tried generating this report (as it's included in an integration test as shown by @melloware) but only an empty PDF is generated.

Update: I noticed that the test report is empty only when a datasource is passed to fillFromRepo. When using an empty datasource, the report with the barcodes is generated just fine, at least in dev mode. Now I'll try on the native build.

@melloware
Copy link
Contributor

barcode4j.pdf

Weird I get the above PDF?

I think i know what the bBarcode4J issue is PF uses BC4J "light" and Jasper uses BC4J full two different JARS and coordinates

let me investigate this but I am not having any issues generating barcodes.

Can you create the smallest possible Quarkus reproducer? Or update my Integrations tests here to show the failure?

@melloware
Copy link
Contributor

try excluding org.primefaces.extensions:barcode4j-light from the pom.xml

@melloware melloware added the bug Something isn't working label Oct 29, 2024
@melloware
Copy link
Contributor

the only thing I see different than my integration is this...

<property name="com.jaspersoft.studio.unit.x" value="px"/>
	<property name="com.jaspersoft.studio.unit.y" value="px"/>
	<property name="com.jaspersoft.studio.unit.width" value="px"/>
	<property name="com.jaspersoft.studio.unit.height" value="px"/>

@redddcyclone
Copy link
Author

Another update: the test report in native mode gives the same errors I stated in the first post. In dev mode it was generated just fine.

@melloware I'm gonna try the suggested exclusion, soon I'll report results here. If possible I'll create a reproducer too

@redddcyclone
Copy link
Author

the only thing I see different than my integration is this...

<property name="com.jaspersoft.studio.unit.x" value="px"/>
	<property name="com.jaspersoft.studio.unit.y" value="px"/>
	<property name="com.jaspersoft.studio.unit.width" value="px"/>
	<property name="com.jaspersoft.studio.unit.height" value="px"/>

Actually I tried with the test report, which does not contains these properties, and the same happened. I'm waiting for the native build to finish after the exclusions you mentioned to report new results.

@redddcyclone
Copy link
Author

Update: nope, warnings about split package disappeared but the same error happens

@melloware
Copy link
Contributor

melloware commented Oct 29, 2024

I just did a native build of the Integration Tests and then hit localhost:8080/jasper/barcode4j/pdf and it works fine for me.

That is also what our CI/CD pipeline does and reports a 200OK

image

@redddcyclone
Copy link
Author

Can this issue be related somehow? May I be missing something?

@melloware
Copy link
Contributor

Looks like the same error but then why can't i reproduce locally or in CI/CD GitHub Native build?

Also how are you building the native are you running this in the /integration-tests folder mvn -Dquarkus.native.native-image-xmx=13g -Pnative-docker ???

when its done run docker run -i --rm -p 8080:8080 jasperreports/integration-test:999-SNAPSHOT and hit localhost:8080/jasper/barcode4j/pdf

@redddcyclone
Copy link
Author

I have only tried the .jrxml file, I didn't try to run the integration tests in my environment. I'm trying it now and waiting for the build to finish. Also, I'm only using mvn package -Pnative for compiling my project.

@redddcyclone
Copy link
Author

@melloware compiled the integration tests, though not as a Docker container but only native, and got the exact same error:

2024-10-29 13:05:01,774 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /jasper/barcode4j/pdf failed, error id: 32368af8-767a-4700-b5e8-f3bbdfe9df14-1: java.lang.NoSuchFieldError: java.awt.Component.x
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$Support.getFieldID(JNIFunctions.java:1357)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions.GetFieldID(JNIFunctions.java:449)
        at [email protected]/java.awt.Component.initIDs(Native Method)
        at [email protected]/java.awt.Component.<clinit>(Component.java:627)
        at [email protected]/java.lang.Class.ensureInitialized(DynamicHub.java:604)
        at [email protected]/sun.awt.CustomCursor.<init>(CustomCursor.java:48)
        at [email protected]/sun.awt.X11CustomCursor.<init>(X11CustomCursor.java:44)
        at [email protected]/sun.awt.X11.XCustomCursor.<init>(XCustomCursor.java:43)
        at [email protected]/sun.awt.X11.XToolkit.createCustomCursor(XToolkit.java:1201)
        at org.apache.batik.bridge.CursorManager.<clinit>(CursorManager.java:146)
        at org.apache.batik.bridge.BridgeContext.<init>(BridgeContext.java:1162)
        at org.apache.batik.bridge.BridgeContext.<init>(BridgeContext.java:292)
        at net.sf.jasperreports.renderers.AbstractSvgDataToGraphics2DRenderer.getRootNode(AbstractSvgDataToGraphics2DRenderer.java:170)
        at net.sf.jasperreports.renderers.AbstractSvgDataToGraphics2DRenderer.getDimension(AbstractSvgDataToGraphics2DRenderer.java:122)
        at net.sf.jasperreports.pdf.JRPdfExporter$InternalImageProcessor.processGraphics2D(JRPdfExporter.java:2015)
        at net.sf.jasperreports.pdf.JRPdfExporter$InternalImageProcessor.process(JRPdfExporter.java:1707)
        at net.sf.jasperreports.pdf.JRPdfExporter$InternalImageProcessor.access$1300(JRPdfExporter.java:1657)
        at net.sf.jasperreports.pdf.JRPdfExporter.exportImage(JRPdfExporter.java:1597)
        at net.sf.jasperreports.pdf.JRPdfExporter.exportElements(JRPdfExporter.java:1262)
        at net.sf.jasperreports.pdf.JRPdfExporter.exportPage(JRPdfExporter.java:1211)
        at net.sf.jasperreports.pdf.JRPdfExporter.exportReportToStream(JRPdfExporter.java:1104)
        at net.sf.jasperreports.pdf.JRPdfExporter.exportReport(JRPdfExporter.java:667)
        at io.quarkiverse.jasperreports.it.AbstractJasperResource.exportPdf(AbstractJasperResource.java:118)
        at io.quarkiverse.jasperreports.it.JasperReportsBarcode4JResource.pdf(JasperReportsBarcode4JResource.java:44)
        at io.quarkiverse.jasperreports.it.JasperReportsBarcode4JResource_ClientProxy.pdf(Unknown Source)
        at io.quarkiverse.jasperreports.it.JasperReportsBarcode4JResource$quarkusrestinvoker$pdf_fe18bbd0681631d69c713c79539b66ac84392ec3.invoke(Unknown Source)
        at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
        at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
        at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at [email protected]/java.lang.Thread.runWith(Thread.java:1596)
        at [email protected]/java.lang.Thread.run(Thread.java:1583)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:896)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:872)

@redddcyclone
Copy link
Author

@melloware just tried the Docker build and it works fine. It only fails when compiled as -Pnative. Can this have something to do with my environment? What could it be?

@melloware
Copy link
Contributor

yep because that Docker image is the BARE MINIMUM image with proper font library installation for AWT and Fonts. That is why its documented here: https://github.com/quarkiverse/quarkus-jasperreports?tab=readme-ov-file#docker

@melloware
Copy link
Contributor

So it sounds like your native image running bare metal doesn't have stuff AWT needs to reach.

@dmlloyd
Copy link

dmlloyd commented Oct 29, 2024

Are you including the Quarkus AWT extension?

@melloware
Copy link
Contributor

yep Quarkus AWT definitely there as Jasper does everything with AWT rendering.

melloware added a commit that referenced this issue Oct 29, 2024
@melloware
Copy link
Contributor

melloware commented Oct 29, 2024

@dmlloyd it was being brought in by POI but do you think it matters if I declare it as a first class citizen of this extension?

I am trying it with this PR: #157

@dmlloyd
Copy link

dmlloyd commented Oct 29, 2024

I think it should work even if it's a transitive dependency, but maybe good to double-check.

@melloware
Copy link
Contributor

what is even weirder is our Native Integration Tests pass on CI/CD and its doing the same.

mvn -B install -Dnative -Dquarkus.native.container-build -Dnative.surefire.skip -Dquarkus.native.native-image-xmx=13g

@redddcyclone
Copy link
Author

I don't know how much this can affect this whole question, but I was building under WSL. I'm now trying under a real Linux environment. Soon I'll post the results.

@melloware
Copy link
Contributor

melloware commented Oct 29, 2024

oh so another note on WSL i always copy the files locally when building native image and not ru nfrom /mnt/c as that is actually network calls and I have seen the native compiler freaker out

for example

cp -R /mnt/c/dev/quarkus/quarkus-jasperreports/ .

@redddcyclone
Copy link
Author

OK, I tried moving the files to the internal WSL storage, same error happened but mentioning a different class:

15:23:20,635 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /jasper/barcode4j/pdf failed, error id: e248d332-b6a3-4840-8519-6d49b56ed39a-1: java.lang.NoSuchMethodError: sun.awt.X11.XErrorHandlerUtil.globalErrorHandler(JJ)I
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1341)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1326)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions.GetStaticMethodID(JNIFunctions.java:437)
        at [email protected]/sun.java2d.xr.XRSurfaceData.initIDs(Native Method)
        at [email protected]/sun.java2d.xr.XRSurfaceData.initXRSurfaceData(XRSurfaceData.java:106)
        at [email protected]/sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:127)
        at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:129)
        at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:319)
        at [email protected]/sun.awt.X11GraphicsEnvironment.initStatic(X11GraphicsEnvironment.java:64)
        at [email protected]/sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:59)
        at [email protected]/sun.awt.PlatformGraphicsInfo.createGE(PlatformGraphicsInfo.java:37)
        at [email protected]/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:91)
        at [email protected]/java.awt.GraphicsEnvironment$LocalGE.<clinit>(GraphicsEnvironment.java:82)
        at [email protected]/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:104)
        at net.sf.jasperreports.engine.util.JRGraphEnvInitializer.initializeGraphEnv(JRGraphEnvInitializer.java:58)
        at net.sf.jasperreports.engine.fill.BaseReportFiller.<init>(BaseReportFiller.java:138)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:273)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:82)
        at net.sf.jasperreports.engine.fill.JRFiller.createBandReportFiller(JRFiller.java:252)
        at net.sf.jasperreports.engine.fill.JRFiller.createReportFiller(JRFiller.java:272)
        at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:157)
        at net.sf.jasperreports.engine.JasperFillManager.fillFromRepo(JasperFillManager.java:671)
        at io.quarkiverse.jasperreports.it.JasperReportsBarcode4JResource.pdf(JasperReportsBarcode4JResource.java:41)
        at io.quarkiverse.jasperreports.it.JasperReportsBarcode4JResource_ClientProxy.pdf(Unknown Source)
        at io.quarkiverse.jasperreports.it.JasperReportsBarcode4JResource$quarkusrestinvoker$pdf_fe18bbd0681631d69c713c79539b66ac84392ec3.invoke(Unknown Source)
        at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
        at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
        at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at [email protected]/java.lang.Thread.runWith(Thread.java:1596)
        at [email protected]/java.lang.Thread.run(Thread.java:1583)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:896)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:872)

@melloware
Copy link
Contributor

ok its like AWT is not available in your WSL is what it looks like.

@melloware
Copy link
Contributor

NOTE: I am also switching PrimeFaces to use the same Barcode4J as Jasper so we don't run into this again: quarkiverse/quarkus-primefaces#275

@redddcyclone
Copy link
Author

redddcyclone commented Oct 29, 2024

I tried compiling under a Linux VM and at least the integration tests worked fine. I'm gonna try with my app.

So this has something to do with WSL then? Do you think of anything I could do to make it work?

UPDATE: My app worked fine compiling under the Linux VM. I'm gonna try with another WSL distro, preferably the same I used in the VM.

@melloware
Copy link
Contributor

i use Ubuntu in my WSL distro. What do you use?

@redddcyclone
Copy link
Author

I was using Ubuntu too, now I tried with Rocky Linux. It worked on the Rocky VM but also failed under Rocky WSL... the Rocky WSL enviroment is brand new, the only difference to the VM is that the WSL image is a minimal one, whereas the VM one is full with GUI.

@redddcyclone
Copy link
Author

redddcyclone commented Oct 29, 2024

Another update: I tried running the same executable I produced under WSL on the VM and it worked fine. Then I tried copying the executable I built on the VM to WSL and got the error again.

So:

  • I only get the error when running the image under WSL, no matter which environment I used to compile the native image
  • The image compiled under WSL runs fine on the VM environment

Maybe WSL is really missing something, but what? JAVA_HOME points to Mandrel (same as GRAALVM_HOME) in both environments.

@dmlloyd
Copy link

dmlloyd commented Oct 29, 2024

Maybe the error is somehow misleading and there's a basic dependency missing (like libX11.so or something related to it that could conceivably be missing from a headless distro)?

@redddcyclone
Copy link
Author

redddcyclone commented Oct 29, 2024

Maybe that is the case. I just tried running the executable under WSL with the flag -Djava.awt.headless=true and it worked! But isn't this flag already being set by default when compiling the native image? At least it shows on the build command as -J-Djava.awt.headless=true

/root/mandrel-java21-23.1.5.0-Final/bin/native-image -J-Dlogging.initial-configurator.min-level=500 -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-DCoordinatorEnvironmentBean.transactionStatusManagerEnable=false -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 -J-Duser.language=en -J-Dfile.encoding=UTF-8 --features=io.quarkus.awt.runtime.graal.DarwinAwtFeature,io.quarkus.hibernate.orm.runtime.graal.DisableLoggingFeature,org.hibernate.graalvm.internal.GraalVMStaticFeature,io.quarkus.caffeine.runtime.graal.CacheConstructorsFeature,io.quarkus.runner.Feature,io.quarkus.primefaces.runtime.PrimeFacesFeature,io.quarkiverse.itext.openpdf.runtime.OpenPDFFeature,io.quarkus.runtime.graal.DisableLoggingFeature,io.quarkus.websockets.client.runtime.DisableLoggingFeature,io.quarkiverse.poi.runtime.graal.POIFeature,io.quarkus.jdbc.postgresql.runtime.graal.SQLXMLFeature -J--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED -J--add-exports=java.security.jgss/sun.security.jgss=ALL-UNNAMED -J--add-opens=java.base/java.text=ALL-UNNAMED -J--add-opens=java.base/java.io=ALL-UNNAMED -J--add-opens=java.base/java.lang.invoke=ALL-UNNAMED -J--add-opens=java.base/java.util=ALL-UNNAMED -H:+UnlockExperimentalVMOptions -H:BuildOutputJSONFile=Blahblah-runner-build-output-stats.json -H:-UnlockExperimentalVMOptions -H:+UnlockExperimentalVMOptions -H:+GenerateBuildArtifactsFile -H:-UnlockExperimentalVMOptions --strict-image-heap -H:+UnlockExperimentalVMOptions -H:+AllowFoldMethods -H:-UnlockExperimentalVMOptions -J-Djava.awt.headless=true --no-fallback --link-at-build-time -H:+UnlockExperimentalVMOptions -H:+ReportExceptionStackTraces -H:-UnlockExperimentalVMOptions -H:+AddAllCharsets --enable-url-protocols=http,https -H:NativeLinkerOption=-no-pie --enable-monitoring=heapdump -H:+UnlockExperimentalVMOptions -H:-UseServiceLoaderFeature -H:-UnlockExperimentalVMOptions -J--add-exports=org.graalvm.nativeimage/org.graalvm.nativeimage.impl=ALL-UNNAMED --exclude-config io\.netty\.netty-codec /META-INF/native-image/io\.netty/netty-codec/generated/handlers/reflect-config\.json --exclude-config io\.netty\.netty-handler /META-INF/native-image/io\.netty/netty-handler/generated/handlers/reflect-config\.json Blahblah-runner -jar Blahblah-runner.jar

I also tried running an X server on the host computer and setting DISPLAY to its IP just to see what would happen. The application does try to open the X display, though the error happens anyway.

@dmlloyd
Copy link

dmlloyd commented Oct 29, 2024

Passing -J-Dkey=value sets the system property for the JVM of native-image, but I believe that you also need -Djava.awt.headless=true (without the -J) to pass the property to the actual build image too.

@redddcyclone
Copy link
Author

redddcyclone commented Oct 30, 2024

Well, I tried adding it to the native image build args, but I still have to pass it to the executable when running it. Does anyone know if it is possible to set this parameter to always apply by default in the image? I already tried with quarkus.native.additional-build-args but it didn't solve this problem

@melloware
Copy link
Contributor

@redddcyclone it might be good to ask this on Zulip channel because this is interesting. I always build to the ubi-minimal Docker Image as you have seen and never had an issue but this is weird?

melloware added a commit that referenced this issue Oct 30, 2024
melloware added a commit that referenced this issue Oct 30, 2024
melloware added a commit that referenced this issue Oct 30, 2024
@melloware melloware self-assigned this Oct 30, 2024
@redddcyclone
Copy link
Author

Ok, I'm gonna ask about this on the chat.

Thanks a lot @melloware and @dmlloyd!

melloware added a commit that referenced this issue Oct 30, 2024
@melloware
Copy link
Contributor

OK submitted fix...

@BuildStep
    SystemPropertyBuildItem sysPropHeadless(NativeConfig nativeConfig) {
        if (nativeConfig.enabled()) {
            // see https://github.com/quarkiverse/quarkus-jasperreports/issues/156
            return new SystemPropertyBuildItem("java.awt.headless", "true");
        }
        return null;
    }

lets see if CI/CD pipeline doesn't complain

@redddcyclone
Copy link
Author

@melloware should the latest code in the main branch work without specifying this parameter? I tried the integration test and it didn't work without setting -Djava.awt.headless=true manually

@melloware
Copy link
Contributor

hmmm according to everyone it should i mean its pretty clear what its doing...

@redddcyclone
Copy link
Author

I'm gonna do another try just in case

@redddcyclone
Copy link
Author

@melloware sorry, it worked just fine, it was my mistake. Thanks a lot!

@melloware
Copy link
Contributor

@all-contributors add @dmlloyd for question

Copy link
Contributor

@melloware

I've put up a pull request to add @dmlloyd! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants