我的目标是在 Eclipse RCP 环境中创建 Excel 2007 文档 (XLSX)(Excel 2003 很简单)。我不想将 POI jar 放在 /lib 文件夹中,而是想使用目标定义中的工作 POI OSGI 包。
到目前为止,我所有的尝试都未能创建一个 工作 OSGI 包>兴趣点3.8。到目前为止我所做的:
-
我将所有相关的 JAR 文件与 Ant zip 任务合并:
- poi-3.8-beta3-20110606.jar
- poi-ooxml-3.8-beta3-20110606.jar
- poi-ooxml-schemas-3.8-beta3-20110606.jar
- poi-scratchpad-3.8-beta3-20110606.jar
-
我使用 wrap 参数运行 bnd 工具:java -jar biz.aQute.bnd。 jar wrap ./poi-3.8-beta3-20110606-merged.jar
-
我必须捆绑这些罐子分别在 /ooxml-lib 文件夹中,使用 bnd:
- xmlbeans-2.3.0.jar
- stax-api-1.0.1.jar
- dom4j-1.6.1.jar
-
这导致org.w3c.dom.Node 的 ClassNotFoundExceptions,因为 xmlbeans-2.3.0.jar 从此包导出四个类org.w3c.dom
。通常,JavaSE-RuntimeEnvironment 会导出这些。
-
我从 xmlbeans-2.3.0.jar 中删除了 org/w3c/dom 文件夹并重新捆绑了 jar,但我得到了其他 ClassNotFoundExceptions。
这就是我到目前为止所得到的。我认为使用 bnd wrap 是不够的。也许我必须创建一个 bnd.properties 文件并具有显式的 Export-Package/Import-Package 语句,但是哪个有效?
那么,有人成功创建了一个可用的 POI 3.8 OSGI 包吗?
My goal is to create an Excel 2007 document (XLSX) in an Eclipse RCP Environment (Excel 2003 is simple). I don't want to place the POI jars inside a /lib folder, instead I want to use a working POI OSGI bundle from my target definition.
All my attempts so far have failed to create a working OSGI bundle of POI 3.8. What I did so far:
-
I merged all relevant JAR files with the Ant zip task:
- poi-3.8-beta3-20110606.jar
- poi-ooxml-3.8-beta3-20110606.jar
- poi-ooxml-schemas-3.8-beta3-20110606.jar
- poi-scratchpad-3.8-beta3-20110606.jar
-
I ran the bnd tool with the wrap parameter: java -jar biz.aQute.bnd.jar wrap ./poi-3.8-beta3-20110606-merged.jar
-
I had to bundle the jars in the /ooxml-lib folder separately, with bnd:
- xmlbeans-2.3.0.jar
- stax-api-1.0.1.jar
- dom4j-1.6.1.jar
-
This leads to ClassNotFoundExceptions for org.w3c.dom.Node
because xmlbeans-2.3.0.jar exports four classes from this package org.w3c.dom
. Normally the JavaSE-RuntimeEnvironment would export these.
-
I deleted the org/w3c/dom
folder from xmlbeans-2.3.0.jar and rebundled the jar but I got other ClassNotFoundExceptions.
This is where I got so far. I think working with bnd wrap is not enough. Probably I must create a bnd.properties file and have explicit Export-Package/Import-Package statements but which work?
So, has anyone successfully managed to create a working POI 3.8 OSGI bundle?
发布评论
评论(4)
如果您不需要该特定版本,只需使用 http://ebr. springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.apache.poi&version=3.0.2.FINAL 该页面列出了它的依赖项等(其中如果您使用 Maven/Ivy,也可以下载或参考)
可能是 http: //engroup.sourceforge.net/maven2/engroup/osgi/commons/poi-osgi/3.1/ 或 http://ebr.springsource.com/repository/app/search?query=poi 可以提供一些灵感(在第一个链接中,有一个 Maven POM,其中列出了捆绑插件部分中的 (bnd) 指令)。
你为什么要合并罐子?为什么不尝试单独包装每个呢?
要尝试的第二件事是使用现有的 OSGi'd jars xmlbeans, stax-api 和 dom4j< /a>
您还可以使用“org.osgi.framework.system.packages”配置 JRE(系统包)导出的内容 - 这样您就可以选择不导出
org.w3c.dom
If you don't need that specific version, simply use http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.apache.poi&version=3.0.2.FINAL that page lists it's dependencies etc (which you can also download or reference if you're using Maven/Ivy)
May be http://engroup.sourceforge.net/maven2/engroup/osgi/commons/poi-osgi/3.1/ or http://ebr.springsource.com/repository/app/search?query=poi can provide some inspiration (in the first link there's a maven POM that lists the (bnd) instructions in the bundle plugin section).
Why are you merging the jars? Why not try wrapping each individually?
A second thing to try is to use existing OSGi'd jars of xmlbeans, stax-api and dom4j
Also you can configure what the JRE (system bundle) exports using "org.osgi.framework.system.packages" - so you can choose not to export
org.w3c.dom
经过一番严重的头部撞击之后我才能够做到。您可以在此处查看 POM 文件:
http://servicemix.396122.n5.nabble.com/Apache-Poi-3-7-component-tc4912054.html#a5009396
我必须重新打包 XMLBeans 2.3.0 并嵌入捆绑。
干杯,
约格什
I was able to do after some serious head banging. You can see the POM file over here:
http://servicemix.396122.n5.nabble.com/Apache-Poi-3-7-component-tc4912054.html#a5009396
I had to repackage XMLBeans 2.3.0 and embed in the bundle.
Cheers,
Yogesh
我不了解 3.8,但是使用 Bnd 创建适用于 3.7 的 OSGi 捆绑包非常容易。
I don't know about 3.8, but creating working OSGi bundle for 3.7 is quite easy with Bnd.
如果您对 BND 方法的工作示例感兴趣,您可以查看这个项目,它提供了一个 pom 和一个 bnd 文件(受 Jarek 的答案启发):
https://github.com/evandor/skysail-bundled-libraries/tree/master/skysail.bundles.poi
运行“mvn install”会给你一个“OSGi-flavored”POI jar ,也可以在这里找到:
https://oss.sonatype。 org/content/groups/public/de/twentyeleven/skysail/org.apache.poi-osgi/3.8/
您可能需要稍微处理一下 bnd 文件才能创建它您需要的确切 OSGi 包(也许您不需要所有依赖项,或者您希望将它们标记为可选)。
您可以在 bnd 主页上找到所需的所有文档。如果您以前没有使用过这个出色的工具,我建议您从这个页面开始。
If you are interested in a working example of the approach with BND, you can have a look at this project, providing a pom and a bnd file (inspired by Jarek's answer):
https://github.com/evandor/skysail-bundled-libraries/tree/master/skysail.bundles.poi
Running "mvn install" gives you an "OSGi-flavored" POI jar, which can be found as well here:
https://oss.sonatype.org/content/groups/public/de/twentyeleven/skysail/org.apache.poi-osgi/3.8/
You might have to play a bit with the bnd file to make it create the exact OSGi bundle you need (maybe you don't need all the dependencies, or you want to mark them as optional).
You will find all the documentation needed on the bnd homepage. I recommend starting with this page if you haven't used this great tool before.