Skip to main content
Participant
October 6, 2023
Question

getting ClassNotFoundException during runtime when requrest is triggered to convert docx to pdf

  • October 6, 2023
  • 1 reply
  • 478 views

Getting below excpetion when trying to convert docx to pdf 

 

java.lang.ClassNotFoundException: javax.validation.Validation
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[na:na]
at com.adobe.pdfservices.operation.auth.Credentials.validate(Credentials.java:52) ~[pdfservices-sdk-3.4.0.jar:3.4.0]
at com.adobe.pdfservices.operation.auth.ServicePrincipalCredentials.<init>(ServicePrincipalCredentials.java:31) ~[pdfservices-sdk-3.4.0.jar:3.4.0]
at com.adobe.pdfservices.operation.auth.ServicePrincipalCredentials$Builder.build(ServicePrincipalCredentials.java:90) ~[pdfservices-sdk-3.4.0.jar:3.4.0]

 

 

-----------------------------------------------------------------------------------------

 

Below is the maven dependency added - 

 

<!-- adobe pdf converter dependency -->

<dependency>

<groupId>com.adobe.documentservices</groupId>

<artifactId>pdfservices-sdk</artifactId>

<version>3.4.0</version>

</dependency>

 

<!-- slf4j logger dependency -->

<dependency>

<groupId>org.apache.logging.log4j</groupId>

<artifactId>log4j-slf4j-impl</artifactId>

<version>2.17.1</version>

</dependency>

 

 

Java code snipper which is taken from git hub shared in adobe -

 

private static final String OUTPUT_FILE_PATH = "C:/TESTING/";

private static final String INPUT_FILE_PATH_PREFIX = "C:/TESTING/";

 

public void convertDocxToPdf(String input) throws Exception {

// TODO Auto-generated method stub

 

//Create an ExecutionContext using credentials and create a new operation instance.

try

{

Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()

.withClientId(ADOBE_CLIENT_ID)

.withClientSecret(ADOBE_CLIENT_SECRET)

.build();

 

 

ExecutionContext executionContext = ExecutionContext.create(credentials);

CreatePDFOperation createPdfOperation = CreatePDFOperation.createNew();

 

// Set operation input from a source file.

FileRef source = FileRef.createFromLocalFile(INPUT_FILE_PATH_PREFIX + input);

createPdfOperation.setInput(source);

 

// Execute the operation.

FileRef result = createPdfOperation.execute(executionContext);

 

// Save the result to the specified location.

String outputFilePath = createOutputFilePath();

 

logger.info("output file path ::>>> "+outputFilePath);

 

result.saveAs(outputFilePath);

}

catch (ServiceApiException | IOException | SdkException | ServiceUsageException e) {

logger.error("Exception encountered while executing operation", e);

}

 

return "docx converted to pdf. check the output folder";

}

 

 

Note - the client_id and client secret is generated from the adobe website from developer console

 

Please help - the api published in the gitbut via adobe doesn't seems to be working

    This topic has been closed for replies.

    1 reply

    Participant
    October 9, 2023

    does this commity knows anything about the issue being reported by developers or is it just a timepass community ?