Fórum

POI and OSGi not happy

thumbnail
Clint Wilde, modificado 7 Anos atrás.

POI and OSGi not happy

Junior Member Postagens: 39 Data de Entrada: 05/03/13 Postagens Recentes
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
David H Nebinger, modificado 7 Anos atrás.

RE: POI and OSGi not happy

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
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
Clint Wilde, modificado 7 Anos atrás.

RE: POI and OSGi not happy

Junior Member Postagens: 39 Data de Entrada: 05/03/13 Postagens Recentes
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
David H Nebinger, modificado 7 Anos atrás.

RE: POI and OSGi not happy

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
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
Kushagra Khanna, modificado 6 Anos atrás.

RE: POI and OSGi not happy

Junior Member Postagens: 45 Data de Entrada: 28/12/14 Postagens Recentes
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
Manish Kumar Jaiswal, modificado 6 Anos atrás.

RE: POI and OSGi not happy

Regular Member Postagens: 153 Data de Entrada: 25/11/08 Postagens Recentes
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
Chennamma Rathode, modificado 6 Anos atrás.

RE: POI and OSGi not happy

Junior Member Postagens: 45 Data de Entrada: 05/08/15 Postagens Recentes
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
Bhagwan khichar, modificado 6 Anos atrás.

RE: POI and OSGi not happy

New Member Postagens: 10 Data de Entrada: 21/10/14 Postagens Recentes
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
saleem khan, modificado 5 Anos atrás.

RE: POI and OSGi not happy

Junior Member Postagens: 71 Data de Entrada: 16/11/13 Postagens Recentes

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

 

parth kadia, modificado 4 Anos atrás.

RE: POI and OSGi not happy

New Member Postagens: 4 Data de Entrada: 13/02/20 Postagens Recentes