Apache POI and XMLBeans

I am trying to use Apache POI and have successfully made a module. When I tried using some of the classes I received a java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException error message. I then made a module for Apache’s XMLBeans, but now when I try launching the designer I receive a message about a duplicate class. Can someone please help me with how to get either POI to work without XMLBeans or how to get XMLBeans in the gateway without conflicting with the existing classes?

Thank you,

I’m guessing it’s something about your build process. Are you combining multiple jars into one by any chance?

yes, this is what my xml file looks like

[code]<?xml version="1.0" encoding="UTF-8"?>

xmlbeans XMLBeans Apache XMLBeans 2.6.0 7.6.2 5 true xbean.jar xmlbeans-qname.jar resolver.jar xbean_xpath.jar xmlbeans-qname.jar xmlpublic.jar fpmi [/code]

You’ve got xmlbeans-qname in there twice…

thanks. I removed the duplicate line, created a new modl file and installed it on the gateway, but it still gives the same error when launching the designer. it looks weird when it first starts up because it says “Package 1/1, download retry#2” right before the error.

I actually think this is a problem in the build of apache. Try simply extracting the jars and re-zipping them and changing the name to *.jar.

Zip files can contain multiple entries at the same path. File systems cannot, so by extracting to a filesystem and re-zipping you can remove duplicate entries.

I do not think the issue is that it is conflicting with a class that is already in Ignition as might seem intuitive.

There we go. you got it. now that you say that when i have extracted the jar i would get a message that some of the files already exist. I would just click yes to all, but now that you said something i looked at the filenames and the first file name was the location.class just like in the picture of the error message. looks like all the files that conflicted had the same modify date and size. so there should be any problem doing this?

Nope - just use your fixed jars and you should be all set. I’m surprised Apache is distributing jars like that!

I have follow up question now that I have it all working. To get POI working it took three java APIs POI, XMLBeans, and dom4j. would it be best practices to put all the jars in one module or create three separate modules?

Definitely one module. Each module is loaded under its own ClassLoader; one module can’t see/use JAR files loaded by another module, unless it depends on that module, but you only get one module dependency.

Since I am only including the jars to make the libraries available to me for scripting and I am not doing anything in the module that is dependent on one of the jars is your response still true?

This is purely what if, but what if I make my POI module with all the jars which includes XMLBeans and then another module is made that does something other than POI, but it also include the XMLBeans jar? would there be a conflict? would one the XMLBean jars override the other? what if one of the XMLBean jars is a different version than the other?

I am just trying to get a good understanding of this works. thanks for the help.

That should work without conflict.

This actually could cause a conflict in the Designer and the Client, where the classloading is shared, but not in the Gateway, where the classloading is more segregated.

1 Like

We have had a module with POI for a few years now. Using the latest POI version, this is what our module XML looks like

	<jar scope="G">dom4j-1.6.1.jar</jar>
	<jar scope="G">stax-api-1.0.1.jar</jar>
        <jar scope="G">xmlbeans-2.3.0.jar</jar>
	<jar scope="G">poi-3.9-20121203.jar</jar>
	<jar scope="G">poi-ooxml-3.9-20121203.jar</jar>
	<jar scope="G">poi-ooxml-schemas-3.9-20121203.jar</jar>
	<jar scope="G">poi-scratchpad-3.9-20121203.jar</jar>

	<jar scope="CD">dom4j-1.6.1.jar.pack.gz</jar>
	<jar scope="CD">stax-api-1.0.1.jar.pack.gz</jar>
        <jar scope="CD">xmlbeans-2.3.0.jar.pack.gz</jar>
	<jar scope="CD">poi-3.9-20121203.jar.pack.gz</jar>
	<jar scope="CD">poi-ooxml-3.9-20121203.jar.pack.gz</jar>
	<jar scope="CD">poi-ooxml-schemas-3.9-20121203.jar.pack.gz</jar>
	<jar scope="CD">poi-scratchpad-3.9-20121203.jar.pack.gz</jar>