Uploaded image for project: 'PUBLIC - Liferay Documentation'
  1. PUBLIC - Liferay Documentation
  2. LRDOCS-4163

Dependencies must be "provided" if they're already included with Portal

    Details

      Description

      Dependencies configured in WARs should be configured as <scope>provided</scope> (Maven) or providedCompile (Gradle) if they're already provided by Liferay Portal. Otherwise, those JARs will be included in the WAR's WEB-INF/lib and there will be two versions of the exact same class on the classpath. This can cause weird errors that are often hard to debug.

      This came up recently when using Service Trackers in WARs. For example using the following dependency causes errors:

      compile group: "org.osgi", name:"org.osgi.core", version:"6.0.0"
      

      However, when changing this dependency to providedCompile, the errors are resolved:

      providedCompile group: "org.osgi", name:"org.osgi.core", version:"6.0.0"
      

      This is something that we should document and hint at in our Service Trackers tutorial, and possibly a troubleshooting tutorial too. This could be considered a non-Liferay issue, but it seems like a topic that we should address because it is commonly experienced.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              richard.sezov Rich Sezov
              Reporter:
              cody.hoag Cody Hoag
              Participants of an Issue:
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support

                    Packages

                    Version Package
                    7.0.x
                    7.1.x