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:
However, when changing this dependency to providedCompile, the errors are resolved:
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.