Problems with Aspose.Total.Java.lic


#1

Hi Tech-Support friends,

I need your help…

I have a java program which works good and generates a PDF document very nice using (Aspose.total), it prints on the document text + fields with data and also a BARCODE.
I created an executable.jar of my program and it runs ok but…

Problem: When i run the program in eclipse in my PC it runs OK and it creates a PDF document
successfully with Barcode.
But… when i copy the JAR file to the IBM AS400 folder, it runs ok but it gives an error:

java.lang.Exception: Failed to set license. Details: Cannot find license ‘Aspose.Total.Java.lic’.
at com.aspose.barcode.License.setLicense(Unknown Source)
at rr.apps.DocObj.createDoc(DocObj.java:554)
at rr.apps.DocGen.main(DocGen.java:153)

NOTE: if i remove the java code that generates the barcode the program complete suscesfully and it does generate the document on the IBM AS400 folder. but when i put the barcode it does not work.

—my code-------------------------------------------------------------------------------------------
com.aspose.pdf.License license = new com.aspose.pdf.License();
try {
license.setLicense(“Aspose.Total.Java.lic”);
msg = " Aspose.pdf.License() Loaded. . . . ";
writeJobLog(jobLogYN, msg);
} catch (Exception e) {
msg = " Exception Error: Aspose.pdf.License() : " + e;
writeJobLog(jobLogYN, msg);
e.printStackTrace();
}

          com.aspose.barcode.License license1 = new com.aspose.barcode.License();
          try {
                 license1.setLicense("Aspose.Total.Java.lic");
                 msg = "     Aspose.barcode.License()  Loaded. . . . ";
           writeJobLog(jobLogYN, msg);
          } catch (Exception e) {
                 msg = "     Exception Error: Aspose.barcode.License() ---> " + e;
           writeJobLog(jobLogYN, msg);
                 e.printStackTrace();
          }

Please help,
Thank you in advance
Marcos


#2

@mromero_rubinrothman_com,
This seems to be strange and needs further investigation. Could you please replace the barcode related code with some other product like creating a word document using Aspose.Words and set the license there? Although as shown in your code, you are setting the same license for Aspose.PDF library which is working fine, and in the same manner it should work with Aspose.Barcode but we need to perform few tests for our analysis.

Also please share a simple console application (remove all unnecessary code) which works fine in development environment but output jar file fails in the production environment. We will try to reproduce this scenario here and provide further assistance.


#3

Hi Tech-support friends.

I had created a short version of my program to demonstrate that activating the two licenses for PDF and BARCODE in the same program some how “It does Not Work” and i am getting an error which i will show below. Just remember that i am trying to create a PDF document which must contain a Bar-code at the bottom.

I am sorry if my program still is a little long but i hope you can TEST why i am getting Error when creating a barcode.

Also this is my configuration: am using Eclipse - IBM Rational Developer for i (AS400)
JRE 8, JDK 8.
I develop my Java programs on a PC with windows-7 PRO
after i compile my java programs into a JAR file, I move it to the IBM AS400 IFS which is similar to unix and I run the program there:

Symptoms: 1. when i run the program on the PC it runs GOOD, i get the PDF document and the barcode is there (all good here).

Symptoms: 2. when i run the program on the AS400 and i don’t print Barcode it runs GOOD, i get the PDF document. (all good here)

Symptoms: 3. when i run the program on the AS400 and print the Barcode, i am getting the error below: (NO-GOOD HERE)
java.lang.Exception: Failed to set license. Details: Cannot find license ‘Aspose.Total.Java.lic’.

Please Help. . . .
========= My Program =======================================================

package rr.formpdf;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.aspose.barcode.BarCodeImageFormat;
import com.aspose.barcode.generation.BarCodeGenerator;

import com.aspose.pdf.Document;
import com.aspose.pdf.Field;
import com.aspose.pdf.ImageStamp;
import com.aspose.pdf.TextBoxField;

public class FormPDFfill {

static TextBoxField textBoxField = null;
static Date sysDate = new Date();
static DateFormat dtFmt = new SimpleDateFormat("yyMMdd-HHmm");
static String pathSeparator;
static Path currentRelativePath;
static String pgmPath;
static String templatePath;
static String savePath;

public static void main(String[] args) {
	
	com.aspose.pdf.License license = new com.aspose.pdf.License();
	// Call setLicense method to set license
	try {
		license.setLicense("Aspose.Total.Java.lic");
		System.out.println("     Aspose.pdf.License()  Loaded. . . . ");
	} catch (Exception e) {
		System.out.println(e);
		e.printStackTrace();
	}
	
	com.aspose.barcode.License license1 = new com.aspose.barcode.License();
	try {
		license1.setLicense("Aspose.Total.Java.lic");
		System.out.println("     Aspose.barcode.License()  Loaded. . . . ");
	} catch (Exception e) {
		System.out.println(e);
		e.printStackTrace();
	}
	
	String strDtTm = dtFmt.format(sysDate);

    //Setup Path ------------------------------------------------------
	pathSeparator = File.separator;
    if (pathSeparator.equals("\\")) {
		System.out.println("=== Windows ENV. ===");
		currentRelativePath = Paths.get("");
		pgmPath = currentRelativePath.toAbsolutePath().toString();
		templatePath = pgmPath + "\\TEMPLATE\\";
		savePath  = pgmPath + "\\DOCHST\\";
    }else{
		System.out.println("=== AS400 UNIX ENV. ===");
		templatePath = "/qopensys/QIBM/UserData/DOCDTA/TEMPLATE/";
		savePath     = "/qopensys/QIBM/UserData/DOCDTA/DOCHST/";
    };		
	System.out.println("templatePath: " + templatePath);
	System.out.println("historyPath: " + savePath);
	
	String templateDoc = "FormA.pdf";
	String docIn  = templatePath.trim() + templateDoc;
	String docOut = savePath.trim() + "FormA_Barcode_" + strDtTm + ".pdf";;
	
	// Open a document, this is PDF fillable document
	Document pdfDocument = new Document(docIn);

	System.out.println("-------------------------------");
	System.out.println("Display Form fields before populated...");
	System.out.println("-------------------------------");
	Field[] fields = pdfDocument.getForm().getFields();
	for (int i = 0; i < fields.length; i++) {
		System.out.println("Form field: " + fields[i].getFullName() + "        " +
		                   "value: " + fields[i].getValue());
	}
	
           //Populating PDF Form Fields		
	for (int i = 0; i < fields.length; i++) {
		if (fields[i].getFullName().toString().equals("Given Name Text Box")) {
	    	fields[i].setValue("Thomas Lawrence");	
	    };
	    if (fields[i].getFullName().toString().equals("Family Name Text Box")) {
	    	fields[i].setValue("Jefferson West");	
	    };
	    if (fields[i].getFullName().toString().equals("Address 1 Text Box")) {
	    	fields[i].setValue("220 Avenue of Americas");	
	    };
	    if (fields[i].getFullName().toString().equals("Address 2 Text Box")) {
	    	fields[i].setValue("Date/Time: " + strDtTm);	
	    };

	    //	fields[i].setReadOnly(true);
	}

		System.out.println("\n       %%%%%%%% WRITE BAR CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ---BEG---");
		
		ByteArrayOutputStream imageStream2 = new ByteArrayOutputStream();
        String barcodeText = "BARCODE 12345";
		BarCodeGenerator bb = new BarCodeGenerator(com.aspose.barcode.EncodeTypes.CODE_39_STANDARD, barcodeText );
		
		bb.getBarHeight().setPoint(30.0f);
	
		try {
		    bb.save(imageStream2, BarCodeImageFormat.PNG);
		} catch (Exception ex) {
			System.out.println("       >>>  Error saving Object: ImageStream2 ");
		}
	
		byte[] bytes2 = imageStream2.toByteArray();
		ByteArrayInputStream inputStream2 = new ByteArrayInputStream(bytes2);
			
		// create image stamp
		ImageStamp imageStamp2 = new ImageStamp(inputStream2);
		imageStamp2.setBackground(true);
		
		imageStamp2.setXIndent(380);
		imageStamp2.setYIndent(120);
		
		imageStamp2.setHeight(30);
		imageStamp2.setWidth(180);
		
		// Add stamp to particular page
		pdfDocument.getPages().get_Item(1).addStamp(imageStamp2);
		System.out.println("       Bar-Code Text: " + barcodeText.trim());
		
		System.out.println("       %%%%%%%% WRITE BAR CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ---END---");
	
	// Save the updated document
	System.out.println("\nOutput Document is: " + docOut);
	pdfDocument.save(docOut.toString());
	System.out.println("END OF PROCESS. . . ");
}

}

FormA_Barcode_190823-1705.pdf (68.2 KB)


#4

Hi Tech-Support Friend:

I also found additional information on the AS400 Logs, I hope it help you to find out what is happening:

*…+…1…+…2…+…3…+…4…+…5…+…6…+…7…+…8…+.
Exception in thread “main” java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.ensureError(J9VMInternals.java:146)
at java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:135)
at com.aspose.barcode.internal.gv.c.b(Unknown Source)
at com.aspose.barcode.internal.dp.l.(Unknown Source)
at com.aspose.barcode.internal.dp.l.(Unknown Source)
at com.aspose.barcode.bb.(Unknown Source)
at com.aspose.barcode.generation.BarCodeGenerator.(Unknown Source)
at com.aspose.barcode.generation.BarCodeGenerator.(Unknown Source)
at rr.formpdf.FormPDFfill.main(FormPDFfill.java:158)
Caused by: class com.aspose.barcode.internal.df.z: Unrecognized OS: OS/400, V7R2M0,
com.aspose.barcode.internal.dh.ay.i(Unknown Source)
com.aspose.barcode.internal.gv.d.a(Unknown Source)
com.aspose.barcode.internal.dp.n.(Unknown Source)
com.aspose.barcode.internal.gv.c.b(Unknown Source)
com.aspose.barcode.internal.dp.l.(Unknown Source)
com.aspose.barcode.internal.dp.l.(Unknown Source)
com.aspose.barcode.bb.(Unknown Source)
com.aspose.barcode.generation.BarCodeGenerator.(Unknown Source)
com.aspose.barcode.generation.BarCodeGenerator.(Unknown Source)
rr.formpdf.FormPDFfill.main(FormPDFfill.java:158)
at com.aspose.barcode.internal.dh.ay.i(Unknown Source)
at com.aspose.barcode.internal.gv.d.a(Unknown Source)
at com.aspose.barcode.internal.dp.n.(Unknown Source)
… 7 more


#5

@marcsr,
We have tested the issue in Linux and observed that it works fine as you mentioned. However as we don’t have AS400 environment therefore we need to look into it more. We have logged the issue in our database for investigation and for a fix(if applicable). Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

BARCODEJAVA-757 – License loading and barcode rendering issue in AS400


#6

Hi Ahsan,

Thank you for getting back to me on this issue, I also understand that forwarded my case to investigation dept. which is great, because i really need to create a PDF document with Barcode on the IBM AS400 machine.

However, until i get an answer from investigation dept. can you please recommend another way to create Barcode in a PDF document with Java using perhaps another component from ASPOSE.

Thank you,

Marcos


#7

@marcsr,
I am afraid that if you have to create Barcode at runtime, then Aspose.Barcode is the only product to create it and then use Aspose.Pdf for rendering it to a PDF. You may please spare us little time to analyse this issue and share our feedback.


#8

Hi Ahsan,

Thank you for getting back to me very fast, your are the best!!.

I will follow your recommendation and wait for the your developers team to fix the issue of creating a PDF doc with barcode inside on the IBM AS400 IFS.
I will wait until they fix the issue.

Thank you very much,

Marcos


#9

Hi Ahsan,
Can you please provide the status for my request: BARCODEJAVA-757
I really need to print a standard BARCODE on a PDF form…and i am doing this from a java program running on the IBM AS400 which has Java 8 JVM.

Thank you


#10

@marcsr,
This issue is logged few days back and is still in queue to be analysed as there are already other tasks in progress. We will write back here as soon as this issue is analysed and some feedback is ready to share. Regarding other components to create Barcode, I am afraid that no other option is available for this.

For my clarification, you mentioned that when you print barcode, you get the issue. Please perform the following steps and provide your feedback.

  1. Just create the Barcode but DO NOT print it to PDF and check the program response.
  2. DO NOT use Aspose.BarCode to generate the barcode but use some pre-existing image and print it to PDF. Share the program response in this case as well.

#11

@marcsr,

We have a good news for you. We have resolved your issue and soon we will provide you the hotfix for your testing.


#12

@marcsr,

Please try the attached fix/version: Aspose.BarCode for Java v19.8.1

Your issue (logged earlier as “BARCODEJAVA-757”) should be fixed in it.

Let us know your feedback.
aspose-barcode-19.8.1-java.zip (10.0 MB)


#13

Hi Amjad,
i can not open or download the attached file you sent.
aspose-barcode-19.8.1-java.zip] (10.0 MB)

i am getting an error: Sorry, this file is private. Only visible to topic owner and staff members.

Also important… I am using Aspose.java not Aspose.NET, if the fix you sent is for .NET that is not going to work for me.

please help, Thanks

Marcos


#14

@marcsr,

Sorry for the inconvenience caused.

Well, since you are not the owner of the thread, so you might not download the fix from the thread. Please create a new thread in Aspose.BarCode Product family forums and ask for new fix, we will share it in your thread.

PS. yes, this is a Java fix, so you may use it for your needs.


#15

The issues you have found earlier (filed as BARCODEJAVA-757) have been fixed in Aspose.BarCode for Java v19.9. This message was posted using BugNotificationTool from Downloads module by ahsaniqbalsidiqui