Forums de discussion

Transitive dependencies issue in portlet Module

thumbnail
krishna mohan mathakala, modifié il y a 6 années.

Transitive dependencies issue in portlet Module

Junior Member Publications: 68 Date d'inscription: 08/09/12 Publications récentes
Hi I have created a portlet module. By default the build.gradle has the following configurations.


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"
}

I have added the below dependency to the build.gradle file.

compileInclude group: 'org.apache.poi', name: 'poi-ooxml',version: '3.11'


When I do a gradle refresh it has downloaded the poi-ooxml.jar and it's non optional dependencies


poi-ooxml-3.11.jar has non optional dependencies 1.poi-3.11.jar, 2.poi-ooxml-schemas-3.11.jar
poi-3.11.jar  has non optional dependency 1.commons-codec-1.9.jar
poi-ooxml-schemas-3.11.jar  has non optional dependency 1. xmlbeans-2.6.0.jar
xmlbeans-2.6.0.jar  has non optional dependency 1. stax-api-1.0.1.jar


The project compiles fine and when I deploy the bundle in the server it goes to installed state
When I try to start the bundle I am getting the following errors :

unresolved requirement import package : com.sun.jdk
unresolved requirement import package : junit.framework
unresolved requirement import package : org.apache.crimson.jaxp
unresolved requirement import package : org.apache.jcp.xml.dsig.internal.dom
unresolved requirement import package : org.apache.poi.hdgf.extractor
unresolved requirement import package : org.apache.poi.hpbf.extractor
unresolved requirement import package : org.apache.poi.hslf.extractor
unresolved requirement import package : org.apache.poi.hslf.extractor
unresolved requirement import package : org.apache.poi.hsmf.extractor
unresolved requirement import package : org.apache.poi.hwpf.extractor
unresolved requirement import package : org.apache.poi.hwpf.extractor
unresolved requirement import package : org.apache.xml
unresolved requirement import package : org.bouncycastle
unresolved requirement import package : org.junit
unresolved requirement import package : org.openxmlformats.schemas.officeDocument.x2006.math
unresolved requirement import package : org.openxmlformats.schemas.schemaLibrary.x2006.main
unresolved requirement import package : schemasMicrosoftComOfficePowerpoint
unresolved requirement import package : schemasMicrosoftComOfficeWord



These packages are not part of my dependencies and also not part of my dependencies dependency.

I do not find these packages in any jar of my build path.

How to resolve this ?

For the time being I added the below entrys in my bnd.bnd file
Import-Package: \
com.liferay.*,\
!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,\
*


Now my bundle is in Active state.

Please help me with the correct resolution for these kind of issues
thumbnail
David H Nebinger, modifié il y a 6 années.

RE: Transitive dependencies issue in portlet Module

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
krishna mohan mathakala:
These packages are not part of my dependencies and also not part of my dependencies dependency.


Well that's not really true. If it were, you wouldn't be getting the unresolved references exception.

The thing with OSGi is that it does not understand the manifest.mf indicator that a jar is optional; if it is listed in the manifest, it must be satisfied before the bundle will start successfully. Why this is, I'm not completely sure but I kind of guess that OSGi thought it was better for the developer to explicitly declare whether the optional guys were needed or not, avoiding runtime ClassNotFoundExceptions.

In any case, it has determined that there are missing packages that must be resolved before the bundle will actually start.

For the time being I added the below entrys in my bnd.bnd file
Import-Package: \
com.liferay.*,\
!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,\
*


This is the right way to fix it, although I wouldn't worry about the items you want to include. Simplify it down to:
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,\
  *


This includes all remaining packages using the last wildcard line.









Come meet me at Devcon 2017 or 2017 LSNA!