How to use Apache POI in OSGi

Philipp

I want to use Apache POI in OSGi to write an Excel workbook with the streaming, OOXML API (SXSSF). The streaming API is available since POI 3.9.

As the latest Apache POI 3.11 jars are not bundles: What's the best way to get POI working in OSGi?

I tried two approaches:

  1. embed the jars directly in the only bundle which will be using them
  2. use POI jars prewrapped as bundles

I am despairing in getting all dependencies together.

First about embedding the POI jar in my bundle: my bndtools file contains

-buildpath:  \
...
libs/dom4j-1.6.1.jar;version=file,\
libs/poi-3.11.jar;version=file,\
libs/poi-ooxml-3.11.jar;version=file,\
libs/poi-ooxml-schemas-3.11.jar;version=file

Private-Package:  \
...
org.openxmlformats.schemas.*,\
org.apache.poi.*,\
org.dom4j.*,\
com.microsoft.schemas.office.x2006.*,\
schemaorg_apache_xmlbeans.*,\
schemasMicrosoftComOfficeExcel.*,\
schemasMicrosoftComOfficeOffice.*,\
schemasMicrosoftComVml.*

This results in a bundle which imports many, many things like for example org.bouncycastle.asn1.x509 and org.junit. I don't plan to encrypt or test in my application - so these two are probably somehow "optional". How can I specify this? Is there a good way of collecting all these dependencies?

Note: at least org.apache.commons.codec and com.sun.msv.datatype.xsd.lib are additionally required, but they are already bundles.


Using prewrapped jars, I tried using org.apache.servicemix.bundles.poi 3.9_2. This also requires dom4j so I used the prewrapped org.apache.servicemix.bundles.dom4j but that requires at least version 1.0 of javax.xml.stream which my JVM/Felix OSGi advertises as "only" version 0.0.0.1_007_JavaSE. I fixed this by hand (ugly), but then got stuck on another dependency.

What's the good way?

stempler

We use Gradle with bnd-platform to build OSGi bundles for our applications based on Maven dependencies. No sure if this is "the good way", but this is how we build the target platform for our OSGi based applications, Apache POI being part of that. It's especially useful in cases where you have to do adaptions to bundles (e.g. make JUnit optional) or merge JARs (e.g. due to classloading issues in OSGi) to make them work.

I set up an example build with an Apache POI bundle (and implicitly, its POM-defined dependencies) on GitHub. You can clone it (sample-poi branch) and try it running ./gradlew clean bundles. Created bundles will be in build/plugins.

Please note that any optional Maven dependencies will not be included by default and have to be added manually to the build, if you need them (due to limitations in Gradle).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

how to use and get working org.apache.servicemix.bundles.poi osgi bundle

Apache POI: How to use addIgnoredErrors(...) functionality in SXSSFSheet

How to use excel text function "NUMBERVALUE" from Apache POI formula

How to properly use style format in apache-poi?

How to use colors not in IndexedColors for Apache POI XSSF Excel?

How can Apache POI use formulas in streaming mode?

how to set a different slide transition effect for the slide by use apache poi

How to use Apache POI Workbook to sprarate different data in different excel?

How to reuse Fonts in Apache POI?

How to add comment by apache poi

How to use JACOB in an OSGi application?

Use of Workbook and Sheet classes in Apache POI?

Can we use apache poi jars in soapui?

How to delete, not clear row in Sheet ? Apache POI

how to change the tab color of a worksheet with Apache Poi

How to format the text in a XWPFTable in Apache POI

How to format cell in XWPFTable in Apache POI

How to get Function expression Apache POI

Apache POI docx - how to set page size?

Apache POI Excel - how to configure columns to be expanded?

How to Add negative value for DataBar in apache poi?

How to install apache-poi on ubuntu

How to set fixed column width in Apache POI

How to get the drawings from the apache POI XWPFDocument?

How to save excel with formula in Apache Poi?

How to cache the formula cell by using Apache POI

How to save an xslm file as xslx in Apache POI

Apache POI - How to protect sheet with options?

How to speed up autosizing columns in apache POI?

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  3. 3

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  4. 4

    pump.io port in URL

  5. 5

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    Do Idle Snowflake Connections Use Cloud Services Credits?

  9. 9

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  12. 12

    Generate random UUIDv4 with Elm

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    Is it possible to Redo commits removed by GitHub Desktop's Undo on a Mac?

  15. 15

    flutter: dropdown item programmatically unselect problem

  16. 16

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  17. 17

    EXCEL: Find sum of values in one column with criteria from other column

  18. 18

    Pandas - check if dataframe has negative value in any column

  19. 19

    How to use merge windows unallocated space into Ubuntu using GParted?

  20. 20

    Make a B+ Tree concurrent thread safe

  21. 21

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

HotTag

Archive