Hey everyone,
We have been developing with Lucee for a year now and in general it works very nice. I’ve to say that sometimes it’s difficult to find some documentation related to software in Lucee. But now for the problem we are having.
We try to convert Docx to PDF. We didn’t find any tags inside coldfusion/lucee that could do this. So the next solution is to have a JAR file that can be called inside Lucee. In the past we have used Docx4j within Coldfusion. This worked good, but also a lot of trouble to get it working. And newer versions didn’t work.
Now we use Lucee and I get problem after problem. For now I will talk about the first thing I tried and really want to get working inside Lucee.
I’ve found a library here:
This is a simple library that combines other librarys to get a good conversion to PDF. It can also work as a standalone version through windows console. THIS WORKS. I can fire a windows console command and it automatically converts a Docx to PDF.
So the next step is to get it to work inside Lucee. I’ve add the jar file inside: “WEB-INF\lucee\lib”. If I go to the Lucee admin I can see that the jar file is “Active” (green). So it all looks OK. But when I try to call the function with the following code inside a cfscript tag:
temp_File = createObject("java","java.io.File");
temp_FileInputStream = createObject("java","java.io.FileInputStream");
temp_FileOutputStream = createObject("java","java.io.FileOutputStream");
temp_Converter = createObject("java","com.yeokhengmeng.docstopdfconverter.DocxToPDFConverter");
input_stream = javacast("java.io.InputStream", temp_FileInputStream.init(temp_File.init("C:\conversie_diva_part2.docx")));
output_stream = javacast("java.io.OutputStream", temp_FileOutputStream.init(temp_File.init("C:\conversie_diva_part2.pdf")));
temp_Converter.init();
The last line gives an error. A “NoClassDefFoundError” error. I think this comes from a import inside a indirect class. But I’ve tried so many libraries / codes and everytime it gives an error like this. I’ve add so many dependencies (different versions etc) but always this error. Also something I find weird is that the jar file works on itself (all dependencies are inside) but not through Lucee.
So I think something is wrong with our Lucee / Java environment. But how can I know this? I would be very grateful if somebody can take a look at this and send me in a direction to do some tests. I’ve also tried jars/code from a working coldfusion page, but that doesn’t work either. And with the errors I get I cannot do much. I want to know what is failing because we want to continue working with Lucee.
I’ve upgrade Lucee to latest version. Test many jar versions. Read a lot of posts of other users. But nothing works for us. Please help if you have any idea.
Thank you in advance,
Roland
This is btw the full stack trace of the error we got
lucee.runtime.exp.NativeException: org/apache/poi/xwpf/converter/core/Options at
java.lang.Class.getDeclaredConstructors0(Native Method) at
java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) at
java.lang.Class.getConstructors(Class.java:1651) at
lucee.runtime.reflection.storage.WeakConstructorStorage.store(WeakConstructorStorage.java:60) at
lucee.runtime.reflection.storage.WeakConstructorStorage.getConstructors(WeakConstructorStorage.java:45) at lucee.runtime.reflection.Reflector.getConstructorInstance(Reflector.java:425) at lucee.runtime.reflection.Reflector.getConstructorInstance(Reflector.java:418) at lucee.runtime.reflection.Reflector.callConstructor(Reflector.java:807) at lucee.runtime.java.JavaObject.init(JavaObject.java:296) at lucee.runtime.java.JavaObject.call(JavaObject.java:222) at lucee.runtime.java.JavaObject.call(JavaObject.java:259) at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:756) at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1698) at views.instellingen.default_cfm$cf.call(/views/instellingen/default.cfm:44) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:908) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:833) at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:817) at framework.one_cfc$cf.udfCallb(/framework/one.cfc:1877) at framework.one_cfc$cf.udfCall(/framework/one.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:107) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:357) at lucee.runtime.type.UDFImpl.call(UDFImpl.java:226) at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:771) at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:756) at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1698) at framework.one_cfc$cf.udfCall5(/framework/one.cfc:870) at framework.one_cfc$cf.udfCall(/framework/one.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:107) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:357) at lucee.runtime.type.UDFImpl.call(UDFImpl.java:226) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:668) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:586) at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1972) at lucee.runtime.listener.ModernAppListener.call(ModernAppListener.java:419) at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:221) at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:43) at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2405) at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2395) at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2363) at lucee.runtime.engine.Request.exe(Request.java:44) at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1091) at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1039) at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:102) at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) at org.apache.coyote.ajp.AbstractAjpProcessor.process(AbstractAjpProcessor.java:844) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.NoClassDefFoundError: org/apache/poi/xwpf/converter/core/Options ... 65 more Caused by: java.lang.ClassNotFoundException: org.apache.poi.xwpf.converter.core.Options not found by docs.to.pdf.converter.1.8 [79] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1550) at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:79) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1958) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 65 more