• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Internal Server Error when generating DOCX from DOCX

New Here ,
Feb 08, 2024 Feb 08, 2024

Copy link to clipboard


Hello, I'm trying to generate a filled DOCX document with also a DOCX document as template file in Spring Boot. Everytime I try to build that file it stucks at the line: 

StreamAsset streamAsset = pdfServices.getContent(resultAsset);

I already tried multiple changes in the code but it just wouldn't work. The exact error code is:

com.adobe.pdfservices.operation.exception.ServiceApiException: description ='Fatal error, Please check logs for details.'; requestTrackingId='b2a02fcd-a057-463e-9ec6-ff3a977d3190'; statusCode=500; errorCode=INTERNAL_SERVER_ERROR

and also my whole Java class "GenerateDoc.java":

    public String generateDoc(@RequestBody String request) throws IOException, ServiceApiException, SDKException, ServiceUsageException {

        try {
            JSONObject jsonObject = new JSONObject(request);
            System.out.println("Request: " + request);
            JSONArray jsonArray = jsonObject.getJSONArray("dataList");
            JSONObject jsonDataForMerge = new JSONObject();

            jsonDataForMerge.put("Kunde", jsonArray.getString(12));
            // There are other values but I have to hide them
            InputStream inputStream = Files.newInputStream(new File("src/main/resources/RV-Deutsch.docx").toPath());

            Credentials credentials = new ServicePrincipalCredentials(clientId, clientSecret);

            PDFServices pdfServices = new PDFServices(credentials);

            Asset asset= pdfServices.upload(inputStream, PDFServicesMediaType.DOCX.getMediaType());

            DocumentMergeParams documentMergeParams = DocumentMergeParams.documentMergeParamsBuilder()

            DocumentMergeJob documentMergeJob = new DocumentMergeJob(asset, documentMergeParams);

            String location = pdfServices.submit(documentMergeJob);
            PDFServicesResponse<DocumentMergeResult> pdfServicesResponse = pdfServices.getJobResult(location, DocumentMergeResult.class);

            Asset resultAsset = pdfServicesResponse.getResult().getAsset();
            StreamAsset streamAsset = pdfServices.getContent(resultAsset);

            String resultPath = "src/main/resources/output.docx";

            OutputStream outputStream = Files.newOutputStream(new File(resultPath).toPath());
            IOUtils.copy(streamAsset.getInputStream(), outputStream);

            return resultPath;
        } catch (ServiceApiException | IOException | SDKException | ServiceUsageException e) {
            throw new RuntimeException(e);


For now the DOCX template has only the following content:


Bug , Document Generation API , Java SDK






Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation