Difficulties getting license to work

Hi there,

i hope you guys can help me. We have just purchased a new Site OEM

which i was hoping to include in our application.

private static void initializeAsposeLicense() {
        LOG.info("Aspose Cells License will be read.");
        try (final InputStream resourceAsStreamCell = App.class.getClassLoader()
                .getResourceAsStream(ASPOSE_LICENSE_FILE)) {
            if(resourceAsStreamCell != null) {
                String text = new BufferedReader(
                        new InputStreamReader(resourceAsStreamCell, StandardCharsets.UTF_8))
                        .lines()
                        .collect(Collectors.joining("\n"));
                 // for testing purposes, we check what if anything we have read
                LOG.info(text);
                byte[] bytes = text.getBytes(StandardCharsets.UTF_8);
                InputStream targetStream = new ByteArrayInputStream(bytes);
                ASPOSE_LICENSE_CELLS.setLicense(targetStream);


            if (!License.isLicenseSet()) {
                LOG.warn("Invalid aspose license");
                return;
            }
            LOG.info("Aspose Cells License activated."); }
            else {
                LOG.warn("Aspose-License stream not available!");
            }
        } catch (final Exception e) {
            LOG.warn("Unknown license problem", e);
        }
    }

We upgraded to the most recent Aspose Cellls version (22.3 at this moment) and our license will be expiring 20230407.

But the license doesn’t seem to get accepted, since we’ll end up in the LOG.warn(“Invalid aspose license”); part.

Any clues you might provide us?

Thanks in advance

@Grendel,

Which version of Aspose.Cells for Java API you are using with new license. If you are using older version of Aspose.Cells for Java, then please use your older license and not newer license, this will work for ever (your license will not be expired in this case). If you are using newer version(s) of Aspose.Cells for Java API, then you may use new license. If you still find the issue, please zip and share your license for Aspose.Cells for Java. Please post the new license file via private message. In order to send a private message with attachment, please click on my name and find “Message” button. Now, please attach the zipped archive containing the license and send us. We will investigate the issue with your provided license and assist you accordingly.

Another possible reason of your issue is that your logic changes the binary data of the license file. Please note, the content of the license file should not be changed(binary data including any characters such as white spaces), otherwise the verification may fail and then fail to set the license. For your case, we think you may just set license with the input stream got from resource. If you need the text content for other purpose, you may cache the binary data of the input stream firstly. Then with the cached binary data you can build input stream for setting license, and build text for your other purpose.

Thanks a lot, i managed to fix it with the hints you gave. I checked with the version 20.3 of cells … with 22.3, it works like a charm.

@Grendel,

Good to know that your issue is sorted out now. In the event of further queries or issue, feel free to write us back.