New BarCodeBuilder() NullPointerException

Hello

Tomcat 8.5 launches a new servlet thread on our java 8 web application, and then we have : “new BarCodeBuilder()”. I tested the versions below :

  • With aspose-barcode-7.1.0.jar it works OK.
  • With aspose-barcode-17.6.jar (or 17.11 or 17.12) it produces an exception, here is the callstack :

java.lang.NullPointerException
at com.aspose.barcode.internal.is.g.a(Unknown Source)
at com.aspose.barcode.internal.is.g.e(Unknown Source)
at com.aspose.barcode.internal.is.g.d(Unknown Source)
at com.aspose.barcode.internal.is.g.a(Unknown Source)
at com.aspose.barcode.internal.eu.c.a(Unknown Source)
at com.aspose.barcode.internal.ct.h.h(Unknown Source)
at com.aspose.barcode.internal.ct.h.d(Unknown Source)
at com.aspose.barcode.internal.ct.g.a(Unknown Source)
at com.aspose.barcode.internal.ct.g.(Unknown Source)
at com.aspose.barcode.internal.ct.g.(Unknown Source)
at com.aspose.barcode.internal.ct.g.(Unknown Source)
at com.aspose.barcode.BarCodeBuilder.(Unknown Source)

But, if I execute the same line “new BarCodeBuilder()” from a simple class with a static main method via the eclipse menu Debug As / Java Application, it works OK with all versions of barcode jars.

I tried diferent ways :

  • modified the the webapp class loader during during the “new BarCodeBuilder()” with the same as the simple class execution, but I have always the exception if called by the servlet.
  • added all the jars loaded by the webapp in the class path of the simple class : Debug As / Java Application still works OK.
  • created a new thread from the servlet tread to execute the “new BarCodeBuilder()”, but I have always the exception.

I found nothing on the net about this, please did you have this problem ? What was changed after aspose-barcode-7.1.0.jar ?

I cloned your examples from github and created a maven project (and changed the version in the pom.xml) and of course it works because I execute it with eclipse Debug As / Java Application.

Thanks by advance for any advice…

@paulpre,

Thank you for details. Please try again with the latest version of Aspose.BarCode. We hope that this issue will not occur. In case the issue persists, please update us with details we will look into it and come up with appropriate solution.

Hello
Thank you for your quick response, but it is the same.
Your link pointed to version 17.8 so I tested it too, but it produce the same problem too.
In my message I reported that I have the problem also with 17.11 and 17.12.

We have a pro account, I did not use it but perhaps will it be better for you if I connect with it ?

@paulpre,

We have looked into the issue. Initial investigation shows that the issue is due to some missing item on the server while it is present on the local machine. Most probably due to some font. The issue has been logged into our system with ID BARCODEJAVA-443 for further investigation by our Product team. We will update you here once there is some information or a fix version available in this regard.

Oh very nice, thank you very much for you answer. Let me know if you need I do some tests for you.
I add that my two tests are both on the same machine and with the same eclipse :

  • call “new BarCodeBuilder” from a simple main with Debug As Application : OK
  • call “new BarCodeBuilder” from a servlet, thread initiated by tomcat connection : NullPointerException

@paulpre,

Thank you details. We have shared the information with our product team. We will update you here once there is some information or a fix version available in this regard.

@paulpre,

Further investigation shows no issue while executing the following code snippet.

CODE:

public class TestServlet extends javax.servlet.http.HttpServlet {

 protected void doPost(javax.servlet.http.HttpServletRequest request,
  javax.servlet.http.HttpServletResponse response)
  throws javax.servlet.ServletException, IOException {

 }

protected void doGet(javax.servlet.http.HttpServletRequest request,
  javax.servlet.http.HttpServletResponse response)
  throws javax.servlet.ServletException, IOException {
  BarCodeBuilder builder = new BarCodeBuilder();
  builder.setCodeText("Test BarCodeBuilder");

response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");

try (PrintWriter writer = response.getWriter()) {

  writer.println("<!DOCTYPE html><html>");
  writer.println("<head>");
  writer.println("<meta charset=\"UTF-8\" />");
  writer.println("<title>TestServlet</title>");
  writer.println("</head>");
  writer.println("<body>");

  writer.println("<h1>" + builder.getCodeText() +"</h1>");

  writer.println("</body>");
  writer.println("</html>");
  }
}
} 

Apache-Tomcat-8.5.27 and Aspose.BarCode for Java 17.12 was used to execute above code in a web-application. You are requested to please share a sample application demonstrating the issue. We will evaluate it and update you about our findings.