We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

License file fails to set running inside Tomcat 8.0.41 on Fedora 26

It works when running in a stand-alone java class, but when running in Apache Tomcat/8.0.41 (from an exploded WAR file), either from an embedded uuencoded license file or using a license file from the filesystem, I get the following exception:
[07-03 11:43:53] ERROR PdfUtil [documentTaskExecutor-1]: Failed to load Aspose license: Failed to set license. Details:
class com.aspose.note.system.exceptions.InvalidOperationException: Failed to set license. Details:
com.aspose.note.License.setLicenseInternal(Unknown Source)
com.aspose.note.License.setLicense(Unknown Source)

My usage is pretty simple:

static boolean licenseAdded;
private static String ASPOSE_LICENSE_FROM_FILE;
private static String ASPOSE_LICENSE = “SNIP”;

private static void license() {
if(!licenseAdded) {
License l = new License();
File licenseFile = new File("/license/Aspose.Note.lic");
if(licenseFile.exists())
ASPOSE_LICENSE_FROM_FILE = FileUtil.readFile(licenseFile).toString();
boolean fromFile = ASPOSE_LICENSE_FROM_FILE != null;
try (ByteArrayInputStream baos = new ByteArrayInputStream(fromFile ? ASPOSE_LICENSE_FROM_FILE.getBytes() : Base64.decodeBase64(ASPOSE_LICENSE))) {
log.error("Loading Aspose license from " + (fromFile ? “file(data length=” + ASPOSE_LICENSE_FROM_FILE.length() + “)” : “classFile”));
l.setLicense(baos);
licenseAdded = true;
log.error(“Aspose license loaded”);
} catch (Throwable t) {
log.error("Failed to load Aspose license: " + t.getMessage(), t);
}
}
}

public static File fromOneNote(File oneNoteFile, File target) throws IOException {
license();
oneNoteFile = oneNoteFile.getCanonicalFile();
log.debug(“fromOneNote: " + oneNoteFile + " to " + target);
log.debug(” target: " + target);
new Document(oneNoteFile.getCanonicalPath()).save(target.getCanonicalPath(), new PdfSaveOptions());
log.debug("target size: " + (target==null? “null” : (!target.exists() ? “does not exist” : target.length())));
return target;
}

I have created a simple Tomcat web project in Eclipse that demonstrates the issue. Upon startup, it watches /one_note for new files, and converts the file to a PDF and puts it in /one_note/output. The class used for conversion also has a main() method, so I included a “go.bat” file. Extract the file, open a command prompt and navigate to that folder. Type “go internal” to have it generate a PDF from an internally encoded .one file. It does NOT have the watermark. Now type “go extract” to extract the file used in the test. Run the build/libs/aspose.test-1.0.war in Apache Tomcat 8.0.41 (I didn’t try any other versions). Drop the extracted .one file into /one_note and then look in /one_note/output for the PDF, which now has the watermark. Both methods use the same class for conversion, which uses the same method of loading the license file. If you look at the log, it says it couldn’t find a license file in a particular location. If you then copy the extracted license file to that location and restart Tomcat, and drop another .one file into the one_note folder, you will see that it loads the license from the file now, but throws the same exception.
Once someone response to this, I will mail them a ZIP file with the project in it.
There is another user that may be having the same issue: https://forum.aspose.com/t/aspose-note-license-failure/398

@JCORMIER_SCI,

We are sorry for a delayed response. Please share your sample application with us for further investigation at our end.