License Error - Java pdf cell Spring Boot app

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘asposeLicenseConfig’: Invocation of init method failed
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:222) ~[spring-beans-6.2.6.jar:6.2.6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:429) ~[spring-beans-6.2.6.jar:6.2.6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1810) ~[spring-beans-6.2.6.jar:6.2.6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:607) ~[spring-beans-6.2.6.jar:6.2.6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529) ~[spring-beans-6.2.6.jar:6.2.6]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339) ~[spring-beans-6.2.6.jar:6.2.6]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:371) ~[spring-beans-6.2.6.jar:6.2.6]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337) ~[spring-beans-6.2.6.jar:6.2.6]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-6.2.6.jar:6.2.6]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.instantiateSingleton(DefaultListableBeanFactory.java:1221) ~[spring-beans-6.2.6.jar:6.2.6]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton(DefaultListableBeanFactory.java:1187) ~[spring-beans-6.2.6.jar:6.2.6]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:1122) ~[spring-beans-6.2.6.jar:6.2.6]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:987) ~[spring-context-6.2.6.jar:6.2.6]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627) ~[spring-context-6.2.6.jar:6.2.6]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.4.5.jar:3.4.5]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:753) ~[spring-boot-3.4.5.jar:3.4.5]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) ~[spring-boot-3.4.5.jar:3.4.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:318) ~[spring-boot-3.4.5.jar:3.4.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1362) ~[spring-boot-3.4.5.jar:3.4.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1351) ~[spring-boot-3.4.5.jar:3.4.5]
at org.ece.atlas.api.AtlasApiApplication.main(AtlasApiApplication.java:12) ~[classes/:na]
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) ~[spring-boot-devtools-3.4.5.jar:3.4.5]
Caused by: java.lang.RuntimeException: Failed to set Aspose.PDF license: The license is not valid for this product. For free technical support, please post this error and the file in the Aspose.PDF Forums Aspose.PDF Product Family - Free Support Forum - aspose.com
at org.ece.atlas.api.config.AsposeLicenseConfig.setAsposePdfLicense(AsposeLicenseConfig.java:29) ~[classes/:na]
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMethod.invoke(InitDestroyAnnotationBeanPostProcessor.java:457) ~[spring-beans-6.2.6.jar:6.2.6]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:401) ~[spring-beans-6.2.6.jar:6.2.6]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:219) ~[spring-beans-6.2.6.jar:6.2.6]
… 23 common frames omitted
Caused by: java.lang.IllegalStateException: The license is not valid for this product. For free technical support, please post this error and the file in the Aspose.PDF Forums Aspose.PDF Product Family - Free Support Forum - aspose.com
at com.aspose.pdf.l4t.lI(Unknown Source) ~[aspose-pdf-25.4.jar:25.4]
at com.aspose.pdf.License.setLicense(Unknown Source) ~[aspose-pdf-25.4.jar:25.4]
at org.ece.atlas.api.config.AsposeLicenseConfig.setAsposePdfLicense(AsposeLicenseConfig.java:21) ~[classes/:na]
… 28 common frames omitted

Disconnected from the target VM, address: ‘127.0.0.1:62760’, transport: ‘socket’

@auljanec

The error you are encountering indicates that the license you are trying to set for Aspose.PDF is not valid for the product you are using. This can happen for several reasons, such as using an incorrect license file, or the license file being expired or not applicable to the version of the library you are using.

To resolve this issue, you can follow these steps:

  1. Verify License File: Ensure that the license file you are using (Aspose.Pdf.Java.lic) is the correct one for the version of Aspose.PDF you have integrated into your Spring Boot application.

  2. Set License Properly: Make sure you are setting the license correctly in your code. Here is a sample code snippet that demonstrates how to set the license from a file:

    package com.aspose.pdf.examples.AsposePdfExamples.QuickStart;
    
    public class SetLicenseFromFile {
        public static void main(String[] args) throws Exception {
            // Initialize License Instance
            com.aspose.pdf.License license = new com.aspose.pdf.License();
            // Call setLicense method to set license
            try {
                license.setLicense("Aspose.Pdf.Java.lic");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    
  3. Validate License: After setting the license, you can validate if it has been set correctly by using the following code:

    package com.aspose.pdf.examples.AsposePdfExamples.QuickStart;
    
    public class ValidateLicense {
        public static void main(String[] args) throws Exception {
            com.aspose.pdf.License license = new com.aspose.pdf.License();
            try {
                license.setLicense("Aspose.Pdf.Java.lic");
            } catch (Exception e) {
                e.printStackTrace();
            }
            // Check if license has been validated
            if (com.aspose.pdf.Document.isLicensed()) {
                System.out.println("License is Set!");
            } else {
                System.out.println("License is not valid.");
            }
        }
    }
    
  4. Check License Expiry: If you have confirmed that the license file is correct and the code is implemented properly, check if the license has expired or if it is valid for the specific product you are using.

If you continue to face issues, consider reaching out to Aspose support with the details of your license file and the specific error message for further assistance.

Sources:
[1]: SetLicenseFromFile.java
[2]: ValidateLicense.java