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

Free Support Forum - aspose.com

Install license version of aspose imaging api

Hi Team,

We want to use aspose api in our java utility tool which is scheduled to run every 1 min.
As per license guide it says,every time the code is called we have use license.setLicense .
Please guide us to install it one time.We dont want to set License everytime java utility tool is called.

Hi, @Priya05!
Thank you for using Aspose.Imaging.
But let me know what is the problem with setting a license every start your utility. setLicense works fast.
As a solution, you can run your utility only once as a service that performs some actions every minute. In this case, you need to set a license only once when your service is starting.

Hi @evgsidenko,

We tried setting license every start as shown in the below code snippet but since the utility is running every 1 min, its not running completely and it would start newly.
Code snippet:
public void execute() throws DfException {
LOGGER.info(“Starting DMSBatchImportMethod”);
loadPropertiesFile();
License lic = new License();
lic.setLicense(“Aspose.Imaging.Java.lic”);
IDfSession session = null;
try {
tiffUtil = new TiffUtil();
dmsUtils = new DmsUtils();
setPaths();
deleteTempDirectoryAndFiles(new File(sharedSplitPath));
LOGGER.info(“Establishing Docbase Session”);
session = DmsUtils.getSessionMgr(m_userName, m_password, m_docbase);
if(session != null) {
LOGGER.info("Connected to Docbase : "+session.getDocbaseName());
importDoc(session);
}
} catch (Exception e) {
LOGGER.error("Exception : ",e);
} finally {
if(session != null)
session.disconnect();
deleteTempDirectoryAndFiles(new File(sharedSplitPath));
}
LOGGER.info(“End DMSBatchImportMethod”);
}

logs:
2022-11-29 20:09:32,080 INFO c.b.j.d.DMSBatchImportMethod [main] Starting DMSBatchImportMethod
2022-11-29 20:10:32,152 INFO c.b.j.d.DMSBatchImportMethod [main] Starting DMSBatchImportMethod
2022-11-29 20:11:32,172 INFO c.b.j.d.DMSBatchImportMethod [main] Starting DMSBatchImportMethod
2022-11-29 20:13:31,840 INFO c.b.j.d.DMSBatchImportMethod [main] Starting DMSBatchImportMethod
2022-11-29 20:14:32,201 INFO c.b.j.d.DMSBatchImportMethod [main] Starting DMSBatchImportMethod
2022-11-29 20:15:32,215 INFO c.b.j.d.DMSBatchImportMethod [main] Starting DMSBatchImportMethod
2022-11-29 20:16:32,081 INFO c.b.j.d.DMSBatchImportMethod [main] Starting DMSBatchImportMethod
2022-11-29 20:17:32,141 INFO c.b.j.d.DMSBatchImportMethod [main] Starting DMSBatchImportMethod
2022-11-29 20:18:32,096 INFO c.b.j.d.DMSBatchImportMethod [main] Starting DMSBatchImportMethod

Please let us know if there is any other way we can set it up.

@Priya05, if you want to call SetLicense method only once in your application you can create service and process it for example each minute etc.

Hi @samer.el-khatib4aspose,
Is there a way to move license from one to another because my code is in one server so while coding I attached it in that server but now I want to move my code in Production server. I think while moving the license is not getting moved and hence I am facing this issue.

@Priya05
I am not sure I understood your situation completely. But you can place the license as a resource inside your Java utility (inside jar). In this case, your license will be always along the code. But you should take into account that in case of stealing your utility the license is stolen too.
The second option is to place the license in the shared folder within your local network and load it right from there.

@evgsidenko,
While exporting the jar file, we are not exporting the license but we keeping the license inside config folder on the same server where the jar file is being called.It same as second option you have given.But still the license is not getting called or is taking long time to load that I am not sure because it never shows next logger line to be printed in the logs and method is never getting ended.
Please help us resolve this issue as it would impact production environment to stop processing documents.
Thanks and Regards,
Priya

@Priya05 Please clarify what do you mean by “the license is not getting called”? Do you mean that the lic.setLicense(“Aspose.Imaging.Java.lic”); method processing time is too long and the process is aborted? Or setLicense is not even called? Or is it something else? Which method is never getting ended?

@Priya05 Also please extend the try-catch scope by moving the try right after the LOGGER.info(“Starting DMSBatchImportMethod”); line to see if there is any exceptions on loading properties file or setting license step.