Forums de discussion

Issue with bundling Transitive dependencies in Liferay DXP

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

Issue with bundling Transitive dependencies in Liferay DXP

Junior Member Publications: 68 Date d'inscription: 08/09/12 Publications récentes
Hi I configure few dependencies in my build.gradle. The project is building fine. When I deploy the same project , the dependencies are not bundled in the generated jar. So I kept the following configuration in my modules and.bnd file . Some of them are transitive dependencies.

 -includeresource:\
META-INF/lib/activation-1.1.jar=activation-1.1.jar,\
META-INF/lib/axis-1.4.jar=axis-1.4.jar,\
META-INF/lib/biz.aQute.bndlib-3.1.0.jar=biz.aQute.bndlib-3.1.0.jar,\
META-INF/lib/com.liferay.osgi.util-3.0.0.jar=com.liferay.osgi.util-3.0.0.jar,\
META-INF/lib/com.liferay.portal.dao.orm.custom.sql-1.0.3.jar=com.liferay.portal.dao.orm.custom.sql-1.0.3.jar,\
META-INF/lib/com.liferay.portal.kernel-2.0.0.jar=com.liferay.portal.kernel-2.0.0.jar,\
META-INF/lib/commons-codec-1.9.jar=commons-codec-1.9.jar,\
META-INF/lib/commons-io-2.4.jar=commons-io-2.4.jar,\
META-INF/lib/commons-lang3-3.1.jar=commons-lang3-3.1.jar,\
META-INF/lib/commons-logging-1.2.jar=commons-logging-1.2.jar,\
META-INF/lib/cxf-core-3.1.4.jar=cxf-core-3.1.4.jar,\
META-INF/lib/cxf-rt-frontend-jaxrs-3.1.4.jar=cxf-rt-frontend-jaxrs-3.1.4.jar,\
META-INF/lib/cxf-rt-rs-client-3.1.4.jar=cxf-rt-rs-client-3.1.4.jar,\
META-INF/lib/cxf-rt-transports-http-3.1.4.jar=cxf-rt-transports-http-3.1.4.jar,\
META-INF/lib/gson-1.5.jar=gson-1.5.jar,\
META-INF/lib/httpclient-4.4.jar=httpclient-4.4.jar,\
META-INF/lib/httpcore-4.4.jar=httpcore-4.4.jar,\
META-INF/lib/itextpdf-5.5.9.jar=itextpdf-5.5.9.jar,\
META-INF/lib/javax.annotation-api-1.2.jar=javax.annotation-api-1.2.jar,\
META-INF/lib/javax.ws.rs-api-2.0.1.jar=javax.ws.rs-api-2.0.1.jar,\
META-INF/lib/jaxrpc-api-1.1.jar=jaxrpc-api-1.1.jar,\
META-INF/lib/jsoup-1.8.3.jar=jsoup-1.8.3.jar,\
META-INF/lib/mail-1.4.1.jar=mail-1.4.1.jar,\
META-INF/lib/org.osgi.core-6.0.0.jar=org.osgi.core-6.0.0.jar,\
META-INF/lib/poi-3.11.jar=poi-3.11.jar,\
META-INF/lib/poi-ooxml-3.11.jar=poi-ooxml-3.11.jar,\
META-INF/lib/poi-ooxml-schemas-3.11.jar=poi-ooxml-schemas-3.11.jar,\
META-INF/lib/stax-api-1.0.1.jar=stax-api-1.0.1.jar,\
META-INF/lib/stax2-api-3.1.4.jar=stax2-api-3.1.4.jar,\
META-INF/lib/super-csv-2.4.0.jar=super-csv-2.4.0.jar,\
META-INF/lib/woodstox-core-asl-4.4.1.jar=woodstox-core-asl-4.4.1.jar,\
META-INF/lib/xmlbeans-2.6.0.jar=xmlbeans-2.6.0.jar,\
META-INF/lib/xmlschema-core-2.2.1.jar=xmlschema-core-2.2.1.jar,\
META-INF/lib/xmlworker-5.5.9.jar=xmlworker-5.5.9.jar


When I deploy the bundle I am getting the below error :
[Input file does not exist: activation-1.1.jar, Input file does not exist: commons-codec-1.9.jar, Input file does not exist: commons-logging-1.2.jar, Input file does not exist: httpcore-4.4.jar, Input file does not exist: javax.annotation-api-1.2.jar, Input file does not exist: jaxrpc-api-1.1.jar, Input file does not exist: poi-3.11.jar, Input file does not exist: poi-ooxml-schemas-3.11.jar, Input file does not exist: stax-api-1.0.1.jar, Input file does not exist: stax2-api-3.1.4.jar, Input file does not exist: woodstox-core-asl-4.4.1.jar, Input file does not exist: xmlbeans-2.6.0.jar, Input file does not exist: xmlschema-core-2.2.1.jar]


It is not able to include the transitive dependencies in to bundle. How can I resolve this issue.
thumbnail
Joye Luo, modifié il y a 6 années.

RE: Issue withbundling Transitive dependencies in Liferay DXP

Regular Member Publications: 144 Date d'inscription: 03/05/16 Publications récentes
Hey Krishna,

You may need to define the Bundle-ClassPath attribute.
See this blog https://web.liferay.com/web/user.26526/blog/-/blogs/osgi-module-dependencies
Option 4 - Include the Jars in the Module
thumbnail
krishna mohan mathakala, modifié il y a 6 années.

RE: Issue withbundling Transitive dependencies in Liferay DXP

Junior Member Publications: 68 Date d'inscription: 08/09/12 Publications récentes
Hi I have defined the Bundle-ClassPath.


Bundle-ClassPath:\
  .,\
META-INF/lib/activation-1.1.jar,\
META-INF/lib/axis-1.4.jar,\
META-INF/lib/biz.aQute.bndlib-3.1.0.jar,\
META-INF/lib/com.liferay.osgi.util-3.0.0.jar,\
META-INF/lib/com.liferay.portal.dao.orm.custom.sql-1.0.3.jar,\
META-INF/lib/com.liferay.portal.kernel-2.0.0.jar,\
META-INF/lib/commons-codec-1.9.jar,\
META-INF/lib/commons-io-2.4.jar,\
META-INF/lib/commons-lang3-3.1.jar,\
META-INF/lib/commons-logging-1.2.jar,\
META-INF/lib/cxf-core-3.1.4.jar,\
META-INF/lib/cxf-rt-frontend-jaxrs-3.1.4.jar,\
META-INF/lib/cxf-rt-rs-client-3.1.4.jar,\
META-INF/lib/cxf-rt-transports-http-3.1.4.jar,\
META-INF/lib/gson-1.5.jar,\
META-INF/lib/httpclient-4.4.jar,\
META-INF/lib/httpcore-4.4.jar,\
META-INF/lib/itextpdf-5.5.9.jar,\
META-INF/lib/javax.annotation-api-1.2.jar,\
META-INF/lib/javax.ws.rs-api-2.0.1.jar,\
META-INF/lib/jaxrpc-api-1.1.jar,\
META-INF/lib/jsoup-1.8.3.jar,\
META-INF/lib/mail-1.4.1.jar,\
META-INF/lib/org.osgi.core-6.0.0.jar,\
META-INF/lib/poi-ooxml-3.11.jar,\
META-INF/lib/poi-ooxml-schemas-3.11.jar,\
META-INF/lib/stax-api-1.0.1.jar,\
META-INF/lib/stax2-api-3.1.4.jar,\
META-INF/lib/super-csv-2.4.0.jar,\
META-INF/lib/woodstox-core-asl-4.4.1.jar,\
META-INF/lib/xmlbeans-2.6.0.jar,\
META-INF/lib/xmlschema-core-2.2.1.jar,\
META-INF/lib/xmlworker-5.5.9.jar,\
META-INF/lib/wsdl4j-1.6.2.jar,\
META-INF/lib/poi-3.11-beta2.jar
  
  -includeresource:\
META-INF/lib/activation-1.1.jar=activation-1.1.jar,\
META-INF/lib/axis-1.4.jar=axis-1.4.jar,\
META-INF/lib/biz.aQute.bndlib-3.1.0.jar=biz.aQute.bndlib-3.1.0.jar,\
META-INF/lib/com.liferay.osgi.util-3.0.0.jar=com.liferay.osgi.util-3.0.0.jar,\
META-INF/lib/com.liferay.portal.dao.orm.custom.sql-1.0.3.jar=com.liferay.portal.dao.orm.custom.sql-1.0.3.jar,\
META-INF/lib/com.liferay.portal.kernel-2.0.0.jar=com.liferay.portal.kernel-2.0.0.jar,\
META-INF/lib/commons-codec-1.9.jar=commons-codec-1.9.jar,\
META-INF/lib/commons-io-2.4.jar=commons-io-2.4.jar,\
META-INF/lib/commons-lang3-3.1.jar=commons-lang3-3.1.jar,\
META-INF/lib/commons-logging-1.2.jar=commons-logging-1.2.jar,\
META-INF/lib/cxf-core-3.1.4.jar=cxf-core-3.1.4.jar,\
META-INF/lib/cxf-rt-frontend-jaxrs-3.1.4.jar=cxf-rt-frontend-jaxrs-3.1.4.jar,\
META-INF/lib/cxf-rt-rs-client-3.1.4.jar=cxf-rt-rs-client-3.1.4.jar,\
META-INF/lib/cxf-rt-transports-http-3.1.4.jar=cxf-rt-transports-http-3.1.4.jar,\
META-INF/lib/gson-1.5.jar=gson-1.5.jar,\
META-INF/lib/httpclient-4.4.jar=httpclient-4.4.jar,\
META-INF/lib/httpcore-4.4.jar=httpcore-4.4.jar,\
META-INF/lib/itextpdf-5.5.9.jar=itextpdf-5.5.9.jar,\
META-INF/lib/javax.annotation-api-1.2.jar=javax.annotation-api-1.2.jar,\
META-INF/lib/javax.ws.rs-api-2.0.1.jar=javax.ws.rs-api-2.0.1.jar,\
META-INF/lib/jaxrpc-api-1.1.jar=jaxrpc-api-1.1.jar,\
META-INF/lib/jsoup-1.8.3.jar=jsoup-1.8.3.jar,\
META-INF/lib/mail-1.4.1.jar=mail-1.4.1.jar,\
META-INF/lib/org.osgi.core-6.0.0.jar=org.osgi.core-6.0.0.jar,\
META-INF/lib/poi-ooxml-3.11.jar=poi-ooxml-3.11.jar,\
META-INF/lib/poi-ooxml-schemas-3.11.jar=poi-ooxml-schemas-3.11.jar,\
META-INF/lib/stax-api-1.0.1.jar=stax-api-1.0.1.jar,\
META-INF/lib/stax2-api-3.1.4.jar=stax2-api-3.1.4.jar,\
META-INF/lib/super-csv-2.4.0.jar=super-csv-2.4.0.jar,\
META-INF/lib/woodstox-core-asl-4.4.1.jar=woodstox-core-asl-4.4.1.jar,\
META-INF/lib/xmlbeans-2.6.0.jar=xmlbeans-2.6.0.jar,\
META-INF/lib/xmlschema-core-2.2.1.jar=xmlschema-core-2.2.1.jar,\
META-INF/lib/xmlworker-5.5.9.jar=xmlworker-5.5.9.jar,\
META-INF/lib/wsdl4j-1.6.2.jar=wsdl4j-1.6.2.jar,\
META-INF/lib/poi-3.11-beta2.jar=poi-3.11-beta2.jar


Now I am getting
Unresolved requirement: Import-Package: com.sun.javadoc


how to resolve this.
thumbnail
Joye Luo, modifié il y a 6 années.

RE: Issue withbundling Transitive dependencies in Liferay DXP

Regular Member Publications: 144 Date d'inscription: 03/05/16 Publications récentes
Hey Krishna,

I am struggled in the same problem. How to add all the transitive dependencies and the dependencies of transitive dependencies in OSGi container?
If u solve it please let me know.
Thanks in advance.
thumbnail
krishna mohan mathakala, modifié il y a 6 années.

RE: Issue withbundling Transitive dependencies in Liferay DXP

Junior Member Publications: 68 Date d'inscription: 08/09/12 Publications récentes
Joye Luo:
Hey Krishna,

I am struggled in the same problem. How to add all the transitive dependencies and the dependencies of transitive dependencies in OSGi container?
If u solve it please let me know.
Thanks in advance.


Hi Joye,

Now I am able to start my bundle.

When we configure the dependencies in the build.gradle file and do a gradle refresh, gradle downloads all the dependencies ( including transitive dependencies ). The problem is with these transitive dependencies. Gradle is not downloading all transitive dependencies. It is missing few jars, We have to configure missing jars again in build.gradle and do a gradle refresh.


Work around to find the missing jars :

Configure the dependencies in build.gradle, do a gradle refresh and the deploy.
Go to the gogo shell and check for the bundle.
Now the bundle will get deployed and will be in installed state.
try to start the bundle from gogo shell.
Now you will get error similar to
 Unresolved requirement:Import-Package: com.poi.extractor

google the package and try to find out the respective jar in maven repository.
Configure the new jar in build.gradle.
Continue the same process till the bundle gets activated.
thumbnail
David H Nebinger, modifié il y a 6 années.

RE: Issue withbundling Transitive dependencies in Liferay DXP

Liferay Legend Publications: 14914 Date d'inscription: 02/09/06 Publications récentes
krishna mohan mathakala:
Gradle is not downloading all transitive dependencies. It is missing few jars, We have to configure missing jars again in build.gradle and do a gradle refresh.


Gradle is working perfectly, it is a lack of understanding that makes it look like it has problems.

Gradle is a build tool. As such, it knows what is necessary to satisfy compile dependencies. All of the various transitive dependencies are not necessary to complete a build.

The steps you're taking to manually include the jar is simply a way to turn the transitive dependency a compile dependency, therefore it can be included.

Gradle is not broken, it is doing the right thing.

You cannot, however, assume that any tool is going to properly handle dependencies for you, either direct or indirect.

As the developer, it is your responsibility to understand your real dependencies, understand your true transitive dependencies, and most of all it is up to you to correctly include or exclude all of these dependencies correctly.

If you think you can just slap stuff together and it will just work, you're kind of just fooling yourself.

Trust me. Take the time to research every dependency you want to pull in. Decide whether it is the right dependency or check if there are alternatives that might be easier to fit. Understand each transitive dependency and their transitive dependencies.

Gaining an understanding of the dependencies will make you a better software developer and you will deliver better code.

Trying to take shortcuts or creating sloppy projects that include every possible dependency might allow you to get the project "done", but the sloppiness of the solution you deliver will not serve you or your clients well at all.










Come meet me at Devcon 2017 or 2017 LSNA!