I’ve run into an issue using an external resource. I’m trying to use the Apache POI Library. I’ve downloaded all the jars and added them to the Lucee-server > context > lib folder. The binaries that I downloaded are the latest version of the POI library, version 5.2.3.
The POI functionality that I need is in WEB-INF/lucee-server/context/lib/poi-ooxml-5.2.3.jar. I set up the following code to load a test.docx:
classPath = expandPath("../WEB-INF/lucee-server/context/lib/poi-ooxml-5.2.3.jar")
docPath = expandPath("./asset/test.docx")
if( ! fileExists( docPath) ) {echo("<h1>Doc doesn't exist</h1>"); abort;}
FIS = createObject("java", "java.io.FileInputStream").init( docPath )
try
{
DOC = createObject("java", "org.apache.poi.xwpf.usermodel.XWPFDocument", "# classPath #" ).init( FIS )
} catch(any err)
{
dump( err )
}
My catch statement is firing and the message is: org.apache.xmlbeans.XmlException
From what I’ve read, this is a ClassNotFoundException. . . Maybe??
I came across a post on stackoverflow. It was for a java application, but the dev was running into similar issues. One resolution mentioned was to add the xmlbeans-{{latest-version}}.jar to his /lib folder. I’ve already got that in my Lucee-server/context/lib folder as xmlbeans-5.1.1.jar.
I’m no java developer. I’m trying to understand how to get the classes I’ve loaded through createObject() to reference the correct jars. I started adding the path argument (3rd arg) to the createObject function thinking the initiated objects would be looking for the objects it needs, from the same directory.
I don’t know if I’m even asking the right questions here.
These are the files I added to the Lucee-server > context > lib folder:
commons-io-2.11.jar
poi-5.2.3.jar
poi-examples-5.2.3.jar
poi-excelant-5.2.3.jar
poi-javadoc-5.2.3.jar
poi-ooxml-5.2.3.jar
poi-ooxml-full-5.2.3.jar
poi-ooxml-lite-5.2.3.jar
poi-scratchpad-5.2.3.jar
xmlbeans-5.1.1.jar
I was running Lucee 6.1.0.243 but “upgraded” to 6.2.0.36-SNAPSHOT to see if it would make a difference.
I’m running on macOS Sonoma 14.5
Servlet Container Apache Tomcat/9.0.59
Java 19.0.1 (Oracle Corporation) 64bit