Unable to read License file

We are developing an OSGI application to use the Group Docs viewer as part of the AEM application. We tried few options mentioned in the developer community, however, we still are unable to access the License file in the code. Every time we try to access the License file, we get an error which states License file is invalid. We don’t get an exception for the same file in Showcase examples.

Hi Chetan,


Thanks for showing interest in GroupDocs.Viewer for Java and posting your query.
Can you please tell, which version of the API you are evaluating/integrating in your project.

Thanks

Since we have bought the Enterprise package, Do we need to raise ticket for this issue or will it be only handled through forums?

Hi Chetan,


Please make sure you followed the following steps accurately:
  • Read licence file properly (license file path is defined correctly)
  • Apply license just before performing any operation (i.e. rendering documents)
You may follow this documentation.

Keen to hear from you.
Kind regards

we have tried all the steps and we haven’t been able to read the License file. Is there a way by which we can bypass the License file check? I want to have a call with the Support team and need their help in fixing the issue.

Hi Chetan,


Can you please confirm that your license file is not expired. Kindly check Subscription Expiry date of your license, it is mentioned in license file.
In order to check Subscription Expiry date open your license file in notepad and share the value mentioned in SubscriptionExpiry tag with us.

Thanks

It is not expired as the showcase examples works fine. I am trying to integrate the license file with Adobe experience manager which uses OSGI bundle. I need the license file to work with OSGI bundle.

Hi Chetan,


Can you please share the code snippet, how you are trying to apply license?
Also, we would like to apprise you that a new release of GroupDocs.Viewer for Java 3.7.0 is on-board and we would recommend you to integrate that new release in your project.
We shall appreciate your cooperation.

Best wishes
I think its not the question about the release. It is more about passing the license file or stream as input to an OSGI Bundle. If you can take a call that will be great as I can explain you what I am doing and if there is way to make it work.,

1. InputStream licenseStream=null;
try {
licenseStream= new FileInputStream(this.getClass().getResource("GroupDocs.Viewer.Java.lic").toString());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

2. License license = new License();
if (Files.isReadable(FileSystems.getDefault().getPath(Utils.getProjectProperty("license.path")))) {
license.setLicense(Utils.getProjectProperty("license.path"));
if (!License.isValidLicense()) {
throw new RuntimeException("License is not valid");
}
}

Hi Chetan,


Thanks for providing the code snippet.
We are investigating your scenario, as we get any update from the concerned team, we shall surely notify you. Please stay tuned.

Many Thanks

Do we need to raise a support ticket as well?

Hi Chetan,


Yes you can avail the priority support against this issue to increase its priority level. Furthermore, we would also like to know Java version you are using on your machine.

Have a nice weekend ahead.
Kind Regards

java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)

Hi Chetan,


Thanks for providing us the details, We are already investigating your issue, as we get any update from the concerned team, we’ll apprise you accordingly. Please stay tuned.

Have a nice weekend ahead.
Kind regards

Hi Atir,


I am able to read the license file and was even to able to print the contents of the file in the error log. However, I get the error stating that the license file is invalid.
Can you share the parameters that are being used to test the validity of the license file? Is there any specific encoding that needs to be enabled for the license file? Can we enable logging on group docs to understand the root cause for this issue?

Regards
Chetan Mahendru

Hi Chetan,


Sorry for the inconvenience you are facing.
We have reproduced this issue at our end and investigating it. As we get any update from the concerned team, we shall notify you. Please stay tuned.

Best regards

Hi Again,


Using 3.2.2 version of the API, we cannot reproduce this issue.
You already informed us that your license is not expired. In order to examine this issue more precisely, please make sure you have not committed any change in the license file as mentioned here and you are applying license properly.
Can you share the parameters that are being used to test the validity of the license file?
Let us share how we evaluated your scenario at our end using GroupDocs.Viewer for Java 3.2.2.
This is how we set license using class path:
private void setLicenseUsingClasspath() {
System.out.println(“…Loading license by classpath”);
InputStream licenseStream=null;
try {
licenseStream = this.getClass().getClassLoader().getResource(“…” + File.separator + LICENSE_NAME).openStream();
System.out.println(“…License file was loaded”);
new License().setLicense(licenseStream);
System.out.println(“…License file was successfully set”);
} catch (Exception e) {
System.out.println(“…License file can not be loaded”);
e.printStackTrace();
}
System.out.println(“================================”);
}
And this is how we set license using license file full path:
private void setLicenseUsingFullPath() {
System.out.println(“…Loading license by full path”);
String licensePath = LICENSE_PATH + LICENSE_NAME;
License license = new License();
if (Files.isReadable(FileSystems.getDefault().getPath(licensePath))) {
System.out.println(“…License file is readable”);
license.setLicense(licensePath);
if (!License.isValidLicense()) {
throw new RuntimeException(“License is not valid”);
} else {
System.out.println(“…License file was successfully set”);
}
} else {
System.out.println(“…License file is not readable”);
}
System.out.println(“================================”);
}
However, we are able to reproduce same issue using latest version of the API and we are investigating that already.

Best Regards

We tried to print the output of the license file and we were able to see the contents.

It is the group docs APIs that are failing to validate the content of the license file. We have been discussing about this issue for the past few weeks and we have already raised a ticket in the enterprise support forum. I will request you to be available for a call so that we can troubleshoot all the issues related to Groupdocs.

Hi Chetan,


We are sorry for the continuous complications you are facing in this particular issue/scenario.
The good thing is we got an updated sample OSGI project from the concerned team, that will surely help you out. Please find the following resources attached:
  • OSGI sample project (Please add GroupDocs.Viewer.jar 3.7.0 here: OSGI Sample Project\OSGI-with-fixes\OSGI\com.javaworld.sample.HelloWorld)
  • Sample Pdf document
  • HTML output
We already evaluated this sample project using 3.2.2 and 3.7.0 versions of the API and it’s working smoothly. Please explore this project and also observe the project configurations (meta.mf file).

Have a nice weekend ahead.
Best regards


Can you tell us what needs to be done to read the License file at server level? Since we won’t have the local shared folders, I am not sure if the License file can be read using the below technique.


The below source code works fine for AEM setup at local instance. This uses the local shared folders:

private static final String LICENSE_NAME = “GroupDocs.Viewer.Java.lic”;
private static final String LICENSE_PATH = “E:/”;
private static final Logger LOG = LoggerFactory.getLogger(ViewerUtils.class);
static {
String licensePath = LICENSE_PATH + LICENSE_NAME;
License license = new License();
license.setLicense(licensePath);
if (!License.isValidLicense()) {
LOG.error(“License is not valid”);
throw new RuntimeException(“License is not valid”);
}
else
{
LOG.error("…License file was successfully set");
}
/if (LICENSE_PATH != null && Files.exists(LICENSE_PATH)) {
l.setLicense(LICENSE_PATH.toString());
if (!License.isValidLicense()) {
throw new RuntimeException(“License is not valid”);// - path::"+temp.toAbsolutePath().toString());
}
}/
}