掲示板

POI and OSGi not happy

thumbnail
7年前 に Clint Wilde によって更新されました。

POI and OSGi not happy

Junior Member 投稿: 39 参加年月日: 13/03/05 最新の投稿
Hi,

I know this is not an apache forum, but this appearsd to be an issue specifically with the combination of OSGI and Poi.

I am using Apache poi to read an .XSLT file. It works fine locally, but when I add the code to my custom Liferay 7 portlet, it throws an error:

org.apache.poi.openxml4j.exceptions.InvalidFormatException: Can't read content types part !
at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.<init>(ContentTypeManager.java:107)
at org.apache.poi.openxml4j.opc.internal.ZipContentTypeManager.<init>(ZipContentTypeManager.java:56)
at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:167)
at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:662)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:269)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:73)

Again, this works locally in a standalone java app, using the same jars, so this has me baffled.

I am creating my workbook like this:

Workbook wb = WorkbookFactory.create(excelFileInputStream);

Thank in advance for your help!
Clint
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: POI and OSGi not happy

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Hey, Clint.

What version of POI are you using? This exception is normally thrown if there is an invalid format on the contents type file, but there should be a root cause in this exception that should have more detail pointing to where the failure is.

How are you including the POI dependencies into your plugin? Is it an uber-module or is the module including the jars internally?

My off the cuff guess is that it's actually having some problem loading the contents type file either because it is missing, in a different place or some such, but there's not a great deal of detail here to help diagnose the problem.






Come meet me at the LSNA!
thumbnail
7年前 に Clint Wilde によって更新されました。

RE: POI and OSGi not happy

Junior Member 投稿: 39 参加年月日: 13/03/05 最新の投稿
Hey Dave,

Good to see you again.

I am adding them near the end of my build.gradle file like this:

dependencies {
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.0.0"
compileOnly group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "2.0.0"
compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
compileOnly group: "jstl", name: "jstl", version: "1.2"
compileOnly group: "org.osgi", name: "org.osgi.compendium", version: "5.0.0"

compile 'biz.aQute.bnd:biz.aQu te.bndlib:3.1.0'

compile 'com.liferay.portal:com.liferay.portal.kernel:2.0.0'
compile 'com.liferay:com.liferay.portal.configuration.metatype:2.0.0'

compile 'javax.servlet:javax.servlet-api:3.0.1'

compile group: 'org.apache.poi', name: 'poi', version: '3.15-beta2'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.15-beta2'

compile 'org.osgi:org.osgi.service.component.annotations:1.3.0'
}

The thing that bugs me is I've checked the exact same file offline (via a java main method) in my same Eclipse project using the same jars and it can parse the file perfectly. This project is on hold at the moment and I'll post some more details in a few days. Thanks again Dave.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: POI and OSGi not happy

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Okay, those are the compile dependencies, but how are you including poi as a runtime dependency?

https://web.liferay.com/web/user.26526/blog/-/blogs/osgi-module-dependencies
6年前 に Kushagra Khanna によって更新されました。

RE: POI and OSGi not happy

Junior Member 投稿: 45 参加年月日: 14/12/28 最新の投稿
Hi Clint,

I am facing the same issue.
Have you resolved your issue, please share steps what you have followed in resolving the same.

Thanks,
Kushagra
thumbnail
6年前 に Manish Kumar Jaiswal によって更新されました。

RE: POI and OSGi not happy

Regular Member 投稿: 153 参加年月日: 08/11/25 最新の投稿
Hi Kushagra / Clint ,

Any Luck adding the POI dependency in the portlet . I am facing the same issue . I have added
following lines
In Gradle
compile group: "org.apache.poi", name: "poi-ooxml", version: "3.16"

in BND
-includeresource: @poi-ooxml-[0-9]*.jar

It still says
Unresolved requirement: Import-Package: com.graphbuilder.curve


Thanks
Manish
6年前 に Chennamma Rathode によって更新されました。

RE: POI and OSGi not happy

Junior Member 投稿: 45 参加年月日: 15/08/05 最新の投稿
I am facing same issue.

org.osgi.framework.BundleException: Could not resolve module: Ez.master [667]_  Unresolved requirement: Import-Package: junit.framework_ [Sanitized]
	at org.eclipse.osgi.container.Module.start(Module.java:429)
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:402)
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1252)
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1224)
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:512)
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:313)


build.gradle
dependencies {
	compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.0.0"
	compileOnly group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "2.0.0"
	compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
	compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
	compileOnly group: "jstl", name: "jstl", version: "1.2"
	compileOnly group: "org.osgi", name: "osgi.cmpn", version: "6.0.0"
     
    compile group: "commons-io", name: "commons-io", version: "1.4"
    compile group: "commons-net", name: "commons-net", version: "3.6"
    compile group: "org.apache.poi", name: "poi-ooxml", version: "3.9"
    compile group: "org.apache.poi", name: "poi", version: "3.9"
    compile group: "org.apache.poi", name: "poi-ooxml-schemas", version: "3.9"
    compile group: "org.apache.poi", name: "poi-scratchpad", version: "3.12"
    
    runtime group: "commons-io", name: "commons-io", version: "1.4"
    runtime group: "commons-net", name: "commons-net", version: "3.6"
    runtime group: "org.apache.poi", name: "poi", version: "3.9"
    runtime group: "org.apache.poi", name: "poi-ooxml", version: "3.9"
    runtime group: "org.apache.poi", name: "poi-ooxml-schemas", version: "3.9"
    runtime group: "org.apache.poi", name: "poi-scratchpad", version: "3.12"
}


bnd.bnd
Include-Resource:\
 @poi-3.9.jar,\
 @poi-ooxml-3.9.jar,\
 @poi-ooxml-schemas-3.9.jar,\
 @poi-scratchpad-3.12.jar,\
 @commons-io-1.4.jar,\
 @commons-net-3.6.jar
6年前 に Bhagwan khichar によって更新されました。

RE: POI and OSGi not happy

New Member 投稿: 10 参加年月日: 14/10/21 最新の投稿
Hi
add below dependency in gradle in liferay 7 and liferay 7 DXP

compile (group: "org.apache.poi", name: "poi", version: "3.13"){ transitive = false}
	compile (group: "org.apache.poi", name: "poi-ooxml", version: "3.13"){ transitive = false}
	compile (group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '3.13'){ transitive = false}
    compile (group: 'org.apache.xmlbeans', name: 'xmlbeans', version: '2.6.0'){ transitive = false}


Note : Use Same version and no extra dependency and also mark transitive = false
thumbnail
5年前 に saleem khan によって更新されました。

RE: POI and OSGi not happy

Junior Member 投稿: 71 参加年月日: 13/11/16 最新の投稿

Hello All,

 

Here is the working solution for this. You need to do the following

 

build.gradle you can add the below lines

compile (group: "org.apache.poi", name: "poi", version: "3.13"){ transitive = false}
compile (group: "org.apache.poi", name: "poi-ooxml", version: "3.13"){ transitive = false}
compile (group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '3.13'){ transitive = false}
compile (group: 'org.apache.xmlbeans', name: 'xmlbeans', version: '2.6.0'){ transitive = false}

 

bnd.bnd file add the below lines

Import-Package: \
  !com.sun.*,\
  !junit.*,\
  !org.apache.crimson.jaxp,\
  !org.apache.jcp.xml.dsig.internal.dom,\
  !org.apache.poi.hdgf.extractor,\
  !org.apache.poi.hpbf.extractor,\
  !org.apache.poi.hslf.extractor,\
  !org.apache.poi.hslf.*,\
  !org.apache.poi.hsmf.*,\
  !org.apache.poi.hwpf.*,\
  !org.apache.poi.hwpf.extractor,\
  !org.apache.xml.*,\
  !org.bouncycastle.*,\
  !org.junit.*,\
  !org.openxmlformats.schemas.officeDocument.x2006.math,\
  !org.openxmlformats.schemas.schemaLibrary.x2006.main,\
  !schemasMicrosoftComOfficePowerpoint,\
  !schemasMicrosoftComOfficeWord,\
  !org.etsi.uri.x01903.v14,\
  *
Include-Resource:\
 @poi-3.13.jar,\
 @poi-ooxml-3.13.jar,\
 @poi-ooxml-schemas-3.13.jar,\
 @xmlbeans-2.6.0.jar

 

module get deployed and reads/ creates the excel. I have tested both.

Hope this helps

 

Thanks & Regards

Saleem Khan

 

4年前 に parth kadia によって更新されました。

RE: POI and OSGi not happy

New Member 投稿: 4 参加年月日: 20/02/13 最新の投稿