We're sorry Aspose doesn't work properply without JavaScript enabled.

# Aspose.Words (Java) on Windows Nano Server

Hello,

I have been trying to bundle my Java application as a Containerized application using Windows Nano Server (microsoft/nanoserver:sac2016) and Java 11. Interestingly when it receives a conversion job, the api fails with the below exception.

 Aspose.Words native libs cannot be loaded. C:\Users\Administrator\AppData\Local\Temp\AsposeNative\WindowsNativeCall\1618179597615\WindowsNativeCall_x64.dll: The specified procedure could not be found

However when the same application is deployed on a Server Core based image (mcr.microsoft.com/windows/servercore:ltsc2016), it works fine.

Could you please suggest any remedies for the above issue?

Regards

@yaseenm

Could you please remove old jar files from your application and try the latest verison of Aspose.Words for Java 21.4?

If you still face problem, please share complete detail of your scenario along with complete steps that you are using to reproduce the same issue at our end.

Thank you @tahir.manzoor. I tried your suggestion but the same issue again.

Here are some details on my scenario:
1.The application is a Java based application using Springboot. The output is a fat jar.
2. The jar is copied to a Docker image that is based on a Windows 2016 based Nano Server image. The docker file is below:

FROM microsoft/nanoserver:sac2016
USER Administrator

RUN mkdir C:\openjdk-11
ADD jdk-11 C:/openjdk-11

ENV JAVA_HOME C:\\openjdk-11
RUN setx /M PATH "%PATH%;%JAVA_HOME%\bin"

1. The executable jar is copied to the above Docker image that is created and then application started.
2. When it receives a conversion request for any of the formats, the exception I posted before appears.

Now if I do the same thing with using the following Docker image, which is a server core image, it all works properly.

mcr.microsoft.com/windows/servercore:ltsc2016

@yaseenm I have checked your scenario on my side and managed to reproduce the issue. The problem is logged in our defect tracking system as WORDSJAVA-2566.
However, I noticed that the conversion is completed successfully despite the errors displayed in the console. I used the following simple code for testing:

Document doc = new Document("C:\\Temp\\in.docx");
doc.save("C:\\Temp\\out.pdf");


Anyways we will investigate why the errors are displayed and inform you about our findings.

Thank you for the support. In my case I am trying to save the file in memory using code like below and unfortunately the file doesnt get rendered to PDF and I get the exception reported. But all is well when using Windows Server Core image.

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Document inputDocument = new Document(newByteArrayInputStream(attachment.getBytes()));
inputDocument.save(outputStream, SaveFormat.PDF);


@yaseenm I have tested with ByteArrayOutputStream and the document is saved fine on my side. Here is the code I used for testing:

Document doc = new Document("C:\\Temp\\in.docx");

// Save the document to ByteArrayOutputStream.
ByteArrayOutputStream bos = new ByteArrayOutputStream();
doc.save(bos, SaveFormat.PDF);

// Copy ByteArrayOutputStream to file to check the output.
FileOutputStream fos = new FileOutputStream("C:\\Temp\\out.pdf");
bos.writeTo(fos);


Probably there is something wrong with your input document. Could you please attach it here for testing? We will check it and provide you more information.

Okay. I was thinking the Windows dll issue was causing the conversion to fail, I tried again with new version and with clean build and using a very simple word document. This is what follows after the missing DLL error. But works okay with Windows Server core.

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.util.concurrent.CompletionException: java.lang.NoClassDefFoundError: Could not initialize class com.aspose.words.internal.zzPF
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1013)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:665)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:117) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:106) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:376) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.util.concurrent.CompletionException: java.lang.NoClassDefFoundError: Could not initialize class com.aspose.words.internal.zzPF at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314) at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1702)
... 1 common frames omitted
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.aspose.words.internal.zzPF
at com.aspose.words.internal.zz6Z.zzQ(Unknown Source)
at com.aspose.words.internal.zz6Z.zzt9(Unknown Source)
at com.aspose.words.internal.zz6Z.zzY(Unknown Source)
at com.aspose.words.internal.zz6Z.zzZ(Unknown Source)
at com.aspose.words.internal.zzPY.zzZ(Unknown Source)
at com.aspose.words.internal.zzPY.zz1(Unknown Source)
at com.aspose.words.internal.zzPY.zzS(Unknown Source)
at com.aspose.words.internal.zzPY.zzU(Unknown Source)
at com.aspose.words.internal.zzPY.zzZ(Unknown Source)
at com.aspose.words.internal.zzPY.zzZ(Unknown Source)
at com.aspose.words.FontInfoSubstitutionRule.zzZ(Unknown Source)
at com.aspose.words.FontSubstitutionRule.zzY(Unknown Source)
at com.aspose.words.FontSettings.zzY(Unknown Source)
at com.aspose.words.zz3T.zzK(Unknown Source)
at com.aspose.words.internal.zzP0.zzZ(Unknown Source)
at com.aspose.words.zzYS2.zzYwM(Unknown Source)
at com.aspose.words.zzYT8.zzYzv(Unknown Source)
at com.aspose.words.zzYS3.zzYx8(Unknown Source)
at com.aspose.words.zzYS3.zzYx9(Unknown Source)
at com.aspose.words.zzYS3.zzKN(Unknown Source)
at com.aspose.words.Document.zzY(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.<init>(Unknown Source)
at com.aspose.words.Document.<init>(Unknown Source)
at com.aspose.words.Document.<init>(Unknown Source)

@yaseenm I cannot reproduce the same problem on my side. Could you please create a simple application that will allow us to reproduce the issue? We will check it and provide you more information.

Hello,

My apologies for coming back late to this thread. Please find attached a sample program ( pdfconverter.zip (7.7 KB)
). It is a simple Springboot based application together with the Docker file. The Readme.md in the root folder has instructions on how to run. Essentially this is the problem I am having with my production scenario too.

@yaseenm Thank you for additional information. I managed to reproduce the problem on my side. I will further investigate the issue and provide you more information.

@yaseenm We have completed analyzing the issue WORDSJAVA-2577 and closed the issue as not-our-bug since Windows Nano Server can’t load native libs.
But we added a task to add configurable switch-off loading native libs: WORDSJAVA-2668. When implemented, you can use this option to launch Aspose.Words from Windows Nano Server.