Installing POI and iText as modules on WildFly
If you plan to use POI and iText across several applications of yours, then why not installing them as a module with WildFly ?
Create the following structures under the modules folder:
+---org
+---apache
+-----poi
+-----main
module.xml
poi-3.17.jar
Then, define Apache POI module.xml:
<module xmlns="urn:jboss:module:1.1" name="org.apache.poi">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="poi-3.17.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="org.apache.commons.logging"/>
</dependencies>
</module>
Create the iText module path as well:
+---com
+----lowagie
+----itext
+-----main
module.xml
itext-2.1.7.jar
And the corresponding module.xml
<module xmlns="urn:jboss:module:1.1" name="com.lowagie.itext">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="itext-2.1.7.jar"/>
</resources>
<dependencies>
</dependencies>
</module>
Fine, now the last thing to do is setting the application dependencies into the META-INF/MANIFEST.MF file:
Manifest-Version: 1.0
Dependencies: org.apache.poi com.lowagie.itext export
Great. Now your WildFly is able to use iText and POI libraries as a module.
Last thing to note: the current release of Primefaces libraries refers to an older release of iText. If you try to install the latest iText distribution you will end up to the following error: java.lang.NoClassDefFoundError: com/lowagie/text/
This is due to the fact that in the recent iText release the package com/lowagie/text has been renamed as com/itextpdf/text. So until this is fixed use the suggested iText release (2.1.7) or at least verify the package structure.
You can find the code from this PrimeFaces Exporter Demo here. Enjoy it !
- << Prev
- Next