Jump to content
We've recently updated our Privacy Statement, available here ×

Jasper 6.4 : NullPointerException in Barcode4j


vlimkar

Recommended Posts

After upgrading jasper server 5.6.1 to 6.4.0 we are getting below error when report is having Barcode (The referenced field is null). Report is running fine in 5.6.1

net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRRuntimeException: java.lang.NullPointerException: Parameter msg must not be empty
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:545)
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$20(ReportControler.java:520)
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler$5.run(ReportControler.java:401)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: net.sf.jasperreports.engine.JRRuntimeException: java.lang.NullPointerException: Parameter msg must not be empty
    at net.sf.jasperreports.components.barcode4j.BarcodeSVGImageProducer.createImage(BarcodeSVGImageProducer.java:81)
    at net.sf.jasperreports.components.barcode4j.AbstractBarcodeEvaluator.evaluateBarcodeRenderable(AbstractBarcodeEvaluator.java:98)
    at net.sf.jasperreports.components.barcode4j.AbstractBarcodeEvaluator.visitCode39(AbstractBarcodeEvaluator.java:273)
    at net.sf.jasperreports.components.barcode4j.Code39Component.receive(Code39Component.java:148)
    at net.sf.jasperreports.components.barcode4j.AbstractBarcodeEvaluator.evaluateBarcode(AbstractBarcodeEvaluator.java:85)
    at net.sf.jasperreports.components.barcode4j.BarcodeFillComponent.evaluateBarcode(BarcodeFillComponent.java:83)
    at net.sf.jasperreports.components.barcode4j.BarcodeFillComponent.evaluate(BarcodeFillComponent.java:70)
    at net.sf.jasperreports.engine.fill.JRFillComponentElement.evaluate(JRFillComponentElement.java:110)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)
    at net.sf.jasperreports.engine.fill.JRFillFrame.evaluate(JRFillFrame.java:159)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)
    at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:500)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2022)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:748)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:255)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:115)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:582)
    at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:123)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException: Parameter msg must not be empty
    at org.krysalis.barcode4j.impl.code39.Code39Bean.generateBarcode(Code39Bean.java:184)
    at net.sf.jasperreports.components.barcode4j.BarcodeSVGImageProducer.createImage(BarcodeSVGImageProducer.java:67)
    ... 18 more
 

Link to comment
Share on other sites

Just tested with Jaspersoft Studo 6.4.0 final and was able to display barcode4j Code39 without any problem.

The error message is statting there's no message text specified. Check if there is null or empty field in the message text that's being passed to be printed.

Link to comment
Share on other sites

@Friendly User By changing barcode type to barbecue, I am also able to get report output without exception. But I dont want to change barcode4j as in previous version 5.6.1 it was working fine. I can also have workaround for this on report side but reports count is more and checking if anything is done maybe at Barcode4j jar level.

Link to comment
Share on other sites

  • 2 years later...

I had the same issue and for what I could see, many have the same issue. I am no good in Jasper but here is my solution to it. 

Cause: The issue comes due to absence of value in the barcode property in appearance under print when section for the option: Print When Expression. 

Solution: Caste a boolean return for the barcode value, with something like this: $F{BARCODE}.contains( $F{BARCODE} )

Short explanation: This value is passed, in my understanding as MSG parameter to the barcode generator barcode4j. When null, it throws exception as expected. So we need to set a value. The value expected is of type boolean. I had a field that was named BARCODE. so I just put a code as above which says check if Barcode string has Barcode string value. WHich is like saying when 1=1. This returns a boolean value. Hence all conditions are met. When the field has a value, you will see the barcode in the output. 

 

Why I broke my head on this solution and not just replaced it with barbecue: When i changed the barcode type, the format changed and the guys using the output were just not happy as visually it looked different. So I had to use barcode4j and I had to fix the issue. Hope it helps. Cheers. 

I am going to paste this solution to all thread possible to ensure that people find this solution. I spent weeks trying to find a solution but not one place had it in jaspersoft community for what I searched. Hope it helps the guys searching for it. 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...