License working on local windows machine but not on linux docker

Hi there,

we have an application running smooth and fine on the local machine, but when we turn it into a docker image, it gets weird:

it reads and installs the license, but when checking with Document.isLicensed(), we get a false (and thus a watermark on our resulting documents)

Can you advise on what we need to do to get this to work? The license doesn’t throw any exceptions during loading.

Thanks in advance,
Grendel

@Grendel

It sounds like you’re experiencing issues with the Aspose license not being recognized in your Docker environment, even though it works fine on your local Windows machine. Here are some steps you can take to troubleshoot and resolve this issue:

  1. Ensure License File Accessibility: Make sure that the license file is included in your Docker image and is accessible at runtime. You can verify this by checking the file path in your Docker container.

  2. Check Licensing Code Execution: The licensing code must be executed during the application startup. If you’re using a framework like ASP.NET, ensure that the licensing code is placed in the appropriate event handlers (e.g., Application_Start or Session_Start). If these events are not triggered in your Docker environment, the license may not be applied.

  3. Environment Differences: Sometimes, differences in the environment (like file permissions or paths) between your local machine and the Docker container can cause issues. Ensure that the Docker container has the necessary permissions to read the license file.

  4. Debugging: Add logging to your application to confirm that the licensing code is being executed and to check the path from which the license file is being loaded. This can help identify if the file is being found correctly.

  5. Rebuild the Docker Image: If you have made changes to the Dockerfile or the way the license file is included, make sure to rebuild the Docker image and run a fresh container.

If you continue to face issues, consider checking the Aspose documentation or forums for similar cases, as they may provide additional insights or solutions.

If you need further assistance, feel free to ask!

I tried the steps mentioned above, but to no avail.

my dockerfile is like this:

FROM docker.io/library/eclipse-temurin:17-jdk-alpine

RUN apk update
RUN apk upgrade
RUN apk add font-terminus font-inconsolata font-dejavu font-noto font-noto-cjk font-awesome font-noto-extra
RUN apk add fontconfig
RUN apk add harfbuzz

LABEL maintainer=xy
WORKDIR /app
COPY libs libs/
COPY resources resources/
COPY classes classes/
ENTRYPOINT [“java”, “-cp”, “/app/resources:/app/classes:/app/libs/*”, “de.dummy.pdfmanipulation.PdfApplication”]

on my local windows machine i get

14:14:52.638 [main] INFO PdfApplication – Loading the Pdf license.
14:14:52.982 [main] INFO PdfApplication – Attempting via ClassPathRessource the base url
14:14:52.993 [main] INFO PdfApplication – Pdf license loaded successfully.
14:14:55.391 [main] INFO PdfApplication – License is accepted!

but on the docker image

14:14:55.391 [main] WARN PdfApplication – License is loaded but not accepted!

is there anything I am missing? Tried with the version 24.8 of the aspose.pdf library.

@Grendel

We need to investigate this issue in more details. Can you please share some more information that could help us in replicating this behavior in our environment? Have you tried with some other version of the API?

Hi @asad.ali

sure. I am running this on a Windows Docker v 4.34.2 version. The docker file was in my previous post. I tried with aspose 24.6 and 24.8, both showed the same behaviour.

Maybe i am missing some vital files that need to be present for aspose.pdf to work properly under linux in the alpine image?

Do you by chance have a docker image that doesn’t show that behaviour? I’d gladly try a different container.

EDIT: I tried with version 23.7 as well, same effect. Are there any restrictions to certain licenses so they can’t run inside docker?

Thanks in advance,
Grendel

@Grendel

We have logged an investigation ticket as PDFJAVA-44345 in our issue tracking system to further analyze this scenario. We will look into its details and keep you posted with the status of its correction. Please be patient and spare us some time. We are sorry for the inconvenience.

Do you by chance have any test/example project that uses aspose.pdf in a docker container? We are curious whether this is a generic issue or just something we have with our specific docker image.

@Grendel

We are afraid that we do not have any sample project that we can share publicly related to Aspose.PDF for Java usage inside docker. However, we will consider it and try to create some examples for you. The ticket has been updated accordingly and we will inform you once it is resolved. Please spare us some time.

Are there any news on this? If you have any hints or pointers, that’ll help as well. We can’t really analyze this due to the obfuscation of the code though.

@Grendel

We are afraid that the investigation has not been completed yet. However, your concerns have been recorded and we will surely inform you as soon as we make some findings in this regard. Please spare us some time.

@Grendel

The issue investigation has been completed. There are no special features when running the Aspose.Pdf for Java library in the Docker environment.

The attached test project has been tested and the issue is not reproducible.

Commands for testing in Docker container:

  • Replace the mock file with Aspose.License.lic with your real license file
  • mvn clean install
  • docker build -t aspose-test .
  • docker run aspose-test

If you still face a problem on your side, please share a similar test project that reproduces the problem.
aspose-test.zip (3.8 KB)

2024-11-11 14.56.53.png (114.1 KB)