We need to generate a barcode in code 128-B format (codeset set as ‘B’). I have googled and found that setCodeset method for Code128Bean has been added as part of barcode4j-2.1.jar.
I have made changes in my code to set codeset to ‘B’ and use barcode4j-2.1.jar instead of barcode4j.jar. When I execute it gives me the below error:-
$ Exception in thread "invoiceTaskExecutor-1" java.lang.NoClassDefFoundError: org/krysalis/barcode4j/output/CanvasProvider
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.dhl.ibps.barcodegenerator.barcodegenerator.BacodeFactory.getBarcodegenerator(BacodeFactory.java:50)
at com.dhl.ibps.invoicegenerator.us.USPdfGenerator.generateBarcodes(USPdfGenerator.java:276)
at com.dhl.ibps.invoicegenerator.us.USPdfGenerator.generatePDFFile(USPdfGenerator.java:135)
at com.dhl.ibps.invoicegenerator.PdfManager.generatePDF(PdfManager.java:102)
at com.dhl.ibps.invoicegenerator.InvoiceGenerationThread.run(InvoiceGenerationThread.java:455)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
When I have googled regarding this error it has been speicified in a website that this is a bug in barcode4j-2.1.jar and that it has not yet been fixed.
I apologize if this is not a bug, but if it is a bug can you please let us know when can we expect a release of new jar with a fix?
Can you provide a unit test allowing to reproduce it?
Hi Marc,
I do not have a unit test for this as of now, I will create one and post as soon as possible. So I am describing how the code is written and what is happening when the barcode4j.jar is replaced barcode4j-2.1.jar.
While a barcode needs to be generated, based on the settings (type of format for that particular requirement is saved in database) we fetch the details and pass the parameter to a java class which fetches the class name of the format from the configuration file (an xml file). Below is the code which gets the class name of the format in which the barcode needs to be generated.
public static IXXXBarcodeGeneralizer getBarcodegenerator(String type) throws Exception
{
IXXXBarcodeGeneralizer iXXXBarcodeGeneralizer = null;
if (applicationContext == null)
{
applicationContext = new ClassPathXmlApplicationContext("/resources/Barodefactory.xml");
}
}
iXXXBarcodeGeneralizer = (IXXXBarcodeGeneralizer) ((Class .forName(className)).newInstance());
is the piece of code is the code which throws the error when barcode4j.jar is replaced barcode4j-2.1.jar. It works absolutely fine with barcode4j.jar.
Thanks,
Lavanya
Hi Marc,
Please find attached the unit test file.
Thanks
Lavanya
Sorry..missed attachment