Page 1 of 1

Error when using doc2pdf

PostPosted:Tue Oct 27, 2020 10:39 am
by DanielK
Hi, i am developing a java application which uses openkm as DMS.
I installed openkm version: 6.3.9 (build: e57b626) and use the maven dependency sdk4j version 1.2.
When i call doc2pdf with an word Inputstream I get the error (starting openkm as root):
Code: Select all
2020-10-27 11:35:05,925 [http-nio-0.0.0.0-8080-exec-2] [] WARN  o.a.c.j.i.WebApplicationExceptionMapper - com.openkm.rest.GenericException: HTTP 500 Internal Server Error
        at com.openkm.rest.endpoint.ConversionService.doc2pdf(ConversionService.java:104)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:192)
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:103)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:220)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:201)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
		at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)
Caused by: com.openkm.core.ConversionException: Error in application/msword to PDF conversion
        at com.openkm.util.DocConverter.doc2pdf(DocConverter.java:293)
        at com.openkm.rest.endpoint.ConversionService.doc2pdf(ConversionService.java:86)
        ... 66 more
Caused by: com.openkm.core.ConversionException: Error converting document: could not load document: okm2810923152894687696.dot
        at com.openkm.util.DocConverter.convert(DocConverter.java:242)
        at com.openkm.util.DocConverter.doc2pdf(DocConverter.java:290)
        ... 67 more
The DocConverter Service is running
Code: Select all
2020-10-27 11:22:29,071 [localhost-startStop-1] [] INFO  com.openkm.util.DocConverter - *** Build Office Manager ***
2020-10-27 11:22:29,071 [localhost-startStop-1] [] INFO  com.openkm.util.DocConverter - system.openoffice.path=/usr/lib/libreoffice
2020-10-27 11:22:29,071 [localhost-startStop-1] [] INFO  com.openkm.util.DocConverter - system.openoffice.tasks=200
2020-10-27 11:22:29,071 [localhost-startStop-1] [] INFO  com.openkm.util.DocConverter - system.openoffice.port=2002
My config:
Code: Select all
system.openoffice.path=/usr/lib/libreoffice
system.openoffice.port=2002
system.openoffice.server=
system.openoffice.tasks200 
I have no idea what is missing. If I try it with the openkm ui it´s failed also and then it usese the frontend conversion, that works then.
Please help me :-)

This example throws same error (local JVM on Windows machine, OpenKM on remote Ubuntu):
https://docs.openkm.com/kcenter/view/sd ... ml#doc2pdf

I debugged OpenKM remote and in the class DocConverter on line 236 throws the error. The Files OpenKM created (okm2810923152894687696.dot and okm4299546002404390213.pdf exists)
// Document conversion managed by local OO instance
OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
converter.convert(inputFile, outputFile);

Re: Error when using doc2pdf

PostPosted:Sun Nov 01, 2020 6:13 pm
by jllort
Can you share the code sample, to take an idea about how are you using the SDK?
Did the files in the OpenKM repository successfully converted to PDF?

Re: Error when using doc2pdf

PostPosted:Mon Nov 02, 2020 8:26 am
by DanielK
I tested it in an standalone Java Class
Code: Select all
package com.openkm;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.io.IOUtils;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;

public class Main {

	public static void main(String[] args) {
		InputStream is = null;
		FileOutputStream fos = null;
		InputStream pdf = null;
		try {
			String host = "http://10.23.16.115:8080/OpenKM";
			String username = "okmAdmin";
			String password = "admin";
			OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);

			is = new FileInputStream("C:\\tmp\\test.doc");
			fos = new FileOutputStream("C:\\tmp\\test.pdf");
			pdf = ws.doc2pdf(is, "test.doc");
			IOUtils.copy(pdf, fos);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				IOUtils.close(is);
				IOUtils.close(fos);
				IOUtils.close(pdf);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
I can convert a word file in the ui and download or save the pdf file.

The same file as .docx is working!

Re: Error when using doc2pdf

PostPosted:Fri Nov 06, 2020 6:06 pm
by jllort
Can you share a doc file sample? I would like to test in similar conditions you are testing.
The doc file from UI is working but not from REST API, is that?

Re: Error when using doc2pdf

PostPosted:Tue Nov 10, 2020 7:42 am
by DanielK
Yes, your right. In the UI it works, from my Java Class I got the "com.openkm.sdk4j.exception.ConversionException: Error in application/msword to PDF conversion"

Re: Error when using doc2pdf

PostPosted:Fri Nov 13, 2020 3:15 pm
by jllort
We have just checked with the latest OpenKM community code ( GitHub master branch ) and what will be SDK 1.3 and seems it is working fine. If you are not in a hurry I suggest wait until we release version 6.3.10 ( will be before the end of the year ). If you are in a hurry then should compile the master branch and upgrade your application as is explained here https://docs.openkm.com/kcenter/view/ok ... -6310.html and test with SDK 1.2

The code tested is:
Code: Select all
InputStream is = new FileInputStream("/home/user/Downloads/test.doc");
InputStream newIS = ws.doc2pdf(is,"test.doc");

Re: Error when using doc2pdf

PostPosted:Tue Nov 17, 2020 5:26 am
by DanielK
OK, then I will wait until the next release. Thanks for your help!