Reputation: 355
Background
Docx4j is a Java library which can be used to work with Microsoft Word documents as XML in Java. Our older application, which is written in Coldfusion, already uses this library correctly. Then we moved to the newer software Lucee. This already gave problems implementing the Docx4j library. It eventually worked by putting the Docx4j jar with all the dependencies into the folder "wwwroot/WEB-INF/lucee/lib". After restarting the Lucee services it loaded the jar correctly. There where some other problems, but the important part is that the jar is loaded into the environment.
So what's the problem now?
Now we have a new project which is installed on the new Lucee 5.0. Everything went correctly only the docx4j gave problems. When using the docx4j in the code it gives an error stating that the Docx4j loggerfactory is not loaded. This is a dependency that Docx4j uses. I found some information that Lucee 5.0 works differently with external jar libraries and that it needs to be an OSGi framework bundle. But again this is getting pretty hard to understand what Lucee needs to get this working
What am I trying to implement
What every time worked with Coldfusion/Lucee is the jar file Docx4j and with it all the dependency jar files. So I put all these jar files in a folder which Coldfusion reads, and then it works. So what I am trying to say is that there's no settings file or something similar (maybe in the jar file itself?)
What have I tried?
So of course I tried a couple of things:
First I tried putting it in "inetpub/wwwroot/WEB-INF/lucee/lib". The first time you load the function on the front-end it states that the loggerfactory cannot be loaded. After calling the function after this, it states it cannot load the docx4j at all. Still in the admin it writes that Docx4j is still active.
Tried uploading it as zip file through Lucee admin, it stated that it was to big to upload
Tried putting it in "lucee/tomcat/lucee-server/context/lib". Exact same problem as point 1. I can also rename the Docx4j jar while the service is still running. This is something with the working examples that isn't possible. It's also weird that after the second time the error changes. This could be that Lucee has done something to the jar files.
What do I think maybe the solution?
I found some information that Lucee 5.0 does something different with jar libraries. Now it expects to be an OSGi bundle. You can make a bundle by giving a manifest.xml file that makes the jar files a bundle. But I have no idea how I should do this. And because it always worked with the previous versions, I think the solution maybe something very easy. I.e. adding a line that states the dependencies. So maybe a cfadmin tag that loads these dependencies for Docx4j to use.
What is some useful information?
An update from version 4.5 to 5 should not have this as result. We need the library so otherwise we must go back to an older version, which our customers do not agree upon. I really think the last link has the solution in it, but it's pretty difficult information to process.
Upvotes: 4
Views: 508
Reputation: 23463
With Lucee 5 you have three options:
1) If the library is an OSGi bundle, simply place it in {lucee-server}/bundles
2) If the library is not an OSGi bundle, as seems to be the case with Docx4j, drop the jar (and its dependencies, if needed) into the classpath of the servlet container, e.g. Tomcat or Jetty (or whichever you use).
The "easiest" thing is to drop the jar in the same directory as the Lucee jar.
Another option is to update the classpath of the container, e.g. adding it to common.loader
in {catalina-base}/conf/catalina.properties
in the case of Tomcat.
3) Specify a custom path for your jars, either as an argument to createObject(java...)
, or in Application.cfc
via this.javaSettings
As for missing dependencies, be sure to use the jar that includes all of the dependencies, i.e. docx4j-community-3.3.1.zip
as opposed to docx4j-3.3.1.jar
if downloading from http://www.docx4java.org/downloads.html
Upvotes: 4