Hi
We are doing watermarking using Aspose Jars with Java APIs
We have implemented the following code snippets for license activation:
i)for pdf file type
com.aspose.pdf.License license = new com.aspose.pdf.License();
try
{
// Set the license for Aspose
license.setLicense("Aspose.Total.Java.lic");
}
catch (Exception e)
{
e.printStackTrace();
}
ii) for xls file type
com.aspose.cells.License license = new com.aspose.cells.License();
try
{
// Set the license for Aspose
license.setLicense("Aspose.Total.Java.lic");
}
catch (Exception e)
{
e.printStackTrace();
}
iii)for doc file type
com.aspose.words.License license = new com.aspose.words.License();
try
{
// Set the license for Aspose
license.setLicense("Aspose.Total.Java.lic");
}
catch (Exception e)
{
e.printStackTrace();
}
iv)for ppt file type
com.aspose.slides.License license = new com.aspose.slides.License();
try
{
// Set the license for Aspose
license.setLicense("Aspose.Total.Java.lic");
}
catch (Exception e)
{
e.printStackTrace();
}
v)for visio file type
com.aspose.diagram.License license = new com.aspose.diagram.License();
try
{
// Set the license for Aspose
license.setLicense("Aspose.Total.Java.lic");
}
catch (Exception e)
{
e.printStackTrace();
}
We have also copied the license file “Aspose.Total.Java.lic” to the location where the jars with above code is located.
But our customer is still getting only the Evaluation copy.
Can you help us in resolving this issue?
Thanks
Rama
@Rama_Menon
It sounds like you’re experiencing issues with license activation in your Aspose implementation. Here are a few steps to troubleshoot the problem:
-
Ensure License File is Correctly Named: Make sure that the license file is exactly named “Aspose.Total.Java.lic” and that it does not have an additional extension (like .xml
) added by your operating system. Sometimes, file extensions are hidden, leading to confusion.
-
File Path and Location: Verify that the license file is in the correct directory. It should be in the same folder as your Aspose JAR files or the directory from which your application is running. You can also try using an absolute path to the license file to ensure it’s being found.
-
Check License Application Code: Your code snippets for licensing each Aspose product look correct, but ensure that you are calling the license application method before any other Aspose API calls are made. The license should be set only once per application domain.
-
Exception Handling: Since you are catching exceptions, consider logging or printing the exception message to see if it provides more context on why the license isn’t being applied.
-
License Validity: Ensure that the license is valid and not expired. You can check with the vendor if you’re unsure about the license status.
-
Testing with Different License Methods: If you are still encountering issues, you might try loading the license from a stream or as an embedded resource. Here’s a quick example of how to load a license from an input stream:
InputStream stream = new FileInputStream("path/to/Aspose.Total.Java.lic");
license.setLicense(stream);
If these steps do not resolve the issue, you might want to reach out to Aspose support for further assistance.
Feel free to ask if you need more help!
@Rama_Menon Please check the following points:
- Make sure your call to
SetLicense
gets executed. Step through in the debugger.
- Make sure your code does not catch an exception thrown by the licensing code. For example, Aspose.Words will throw if it cannot find the license.
- Make sure the input documents do not already have the evaluation message. Aspose.Words does not delete existing evaluation messages.
- Make sure
SetLicense
is executed before you instantiate any Document
object.
@alexey.noskov
We are calling the appropriate methods in our own utility jars based on the file types.
In those methods , the first set of statements in the code are the license setting related codes.
Later only we are instantiating the Document objects etc.
Our utility jars,Aspose jars and the license file are kept in the same location.
Customer is trying to execute in their production environment,so chances of input documents already having evaluation messages are less.
@Rama_Menon Do you have the problem with all mentioned libraries? Does license setting code throw any exception?
Looks like problem is with all the libraries. There is no exception as such.
Sending the utility codes,where we have implemented the license. Can you let us know if it is the correct way?
Utility code.zip (12.4 KB)
@Rama_Menon,
I checked your code snippet files and noticed a few areas for improvement. It would be better to place the licensing code (instantiating the License object for each library and setting the license to the license file) within the class constructor, rather than distributing them across different methods. Please use different variable (object) names when instantiating License class for different JARs/libraries. This approach ensures that the licensing code is processed for each JAR at the start when the class object is instantiated/created, and only once during the application’s life cycle, which is more efficient.
Additionally, I observed that the code for setting the license is currently embedded within a try/catch block. Kindly place the set license code outside the try/catch block as suggested. This way, you can identify any exceptions thrown by the licensing code more clearly and address them accordingly on your end.
Let us know if you are able to figure out the issue on your end?
Also wanted to inform that we have a main groovy script from where we call the utility classes mentioned above.
@Rama_Menon,
Please do the needful as we provided necessary details in the previous post. Moreover, try to add some debugging/logging around the license loading/setting code to see if the lines of code are actually processed or not and when. As you’re calling your utility jars from a Groovy script, ensure that the license code in your Java utility jars is executed properly within the Groovy script and at first before using other Aspose APIs. Mind you, Aspose SDKs will throw an exception if there is any issue with Aspose.Total.Java.lic license file or it could not access the file path (either absolute or relative path). Moreover, if the license is expired to use newer API versions, it will also give error message about the license’s expiry.
We have implemented the recommended approach of instantiating the license objects within the constructors of our utility classes. However, the watermark indicating “Evaluation Copy” still appears.
Upon reviewing the license file, we noticed the following note:
1 Developer And 1 Deployment Location
We suspect that the watermark is appearing because the license may have already been used in another application deployed on a different server. As a result, it may now be considered invalid for any additional deployments.
We are planning to deploy the current application across multiple servers for load balancing. Given the observed behavior, it appears that the license is limited to a single deployment environment. Could you please confirm if this is the case? If so, we would appreciate your guidance on how to obtain a license that supports deployment to multiple servers.
Thank you for your support.
@Rama_Menon,
To minimize the issue scope, we recommend you to use stream(s) and verify if the stream contains data while configuring and setting license for different Aspose (Java) libraries.
We believe the license type is unlikely to cause this issue. Kindly note that the setLicense method only pertains to the license file, and we do not perform any checks related to license types or deployment locations.
ok.Can you give an example of how to use streams and check if the stream contains data?
@Rama_Menon,
See the documents on how to set/apply License from a stream for different JARs for your reference.
Moreover, you should also validate and check if license is actually set for the APIs.
e.g.,