0

I imported a Dropwizard project into Intellij IDEA (using Gradle Wrapper from the project itself). Its working for others, but I end up in issue like this:

Here is the gist of gradle dependency.
https://gist.github.com/vineelya/d882bbd0885fafba785ca58f106dfc8b Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z

dependencies {
    compile (
            'io.dropwizard:dropwizard-core:' + dropwizardVersion,
            'io.dropwizard:dropwizard-hibernate:' + dropwizardVersion,
            'io.dropwizard:dropwizard-migrations:' + dropwizardVersion,
            'io.dropwizard:dropwizard-auth:' + dropwizardVersion,
            'io.dropwizard:dropwizard-assets:' + dropwizardVersion,
            'io.dropwizard:dropwizard-forms:'+ dropwizardVersion,
Vineel
  • 1,630
  • 5
  • 26
  • 47
  • 1
    `requiresPropertyOrdering` is available since version `2.3`. So, you have classes which were build with `Jackson` in version at least `2.3` and need this method. What is you version of `Jackson`? See also: [How do I fix a NoSuchMethodError?](https://stackoverflow.com/questions/35186/how-do-i-fix-a-nosuchmethoderror) – Michał Ziober Mar 05 '19 at 21:08
  • Other remote team mates have exactly the same code base and they are able to build and run. Its kind of confusing to me. – Vineel Mar 05 '19 at 21:15
  • 1
    OK, but do you do exactly same steps? You must have some difference between your env and your team mate's envs. – Michał Ziober Mar 05 '19 at 21:23
  • They use Eclipse and I use Intellij, thats the only difference. – Vineel Mar 05 '19 at 21:25
  • 1
    Have you tried to build project using `gradle` but not in `IntelliJ IDEA`, for example in console? – Michał Ziober Mar 05 '19 at 21:53
  • I tried but I have Java 11 installed and its trying to pick that up from outside IDE. I should try it by removing Java 11. Let me get that stack trace regardless. – Vineel Mar 05 '19 at 22:01
  • 1
    @Vineel if you ask Gradle for the dependencies tree, what's the output? – LppEdd Mar 06 '19 at 00:15
  • Is ./gradlew dependencies the right command to use if I want to use standard gradle as that of the code base , irrespective of what version of Gradle is installed on my machine?Let me try, run and update here. I 'm working with an older Dropwizard project. – Vineel Mar 06 '19 at 00:17
  • 1
    If you're using Gradle Wrapper then yes, it's the right command. – LppEdd Mar 06 '19 at 00:19
  • @LppEdd here the gist of Gradle dependency. https://gist.github.com/vineelya/d882bbd0885fafba785ca58f106dfc8b – Vineel Mar 06 '19 at 03:44

1 Answers1

1

You have two dependencies which are importing older versions of Jackson Core.

com.amazon.alexa:alexa-skills-kit:1.2
com.google.api-client:google-api-client:1.19.1

While Gradle should always pick up the latest version, this might be causing your error.
Therefore, exclude them using

implementation('com.amazon.alexa:alexa-skills-kit:1.2') {
   exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
}

implementation('com.google.api-client:google-api-client:1.19.1') {
   exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
}

Or, update them to a compatible, maybe the latest, version (e.g. see MavenCentral).

To force the resolution of a specific version, you can use

configurations.all {
    resolutionStrategy {
        force 'com.fasterxml.jackson.core:jackson-core:2.8.8'
    }
}
LppEdd
  • 20,274
  • 11
  • 84
  • 139
  • Thanks. Please correct me if I m wrong. From the gist (https://gist.github.com/vineelya/d882bbd0885fafba785ca58f106dfc8b) , 2.8.8 is the net effective version picked up by Gradle. Google api client is providing 2.1.3 . So is it necessary to exclude jackson from Google API client, because it looks like, 2.8.8 is picked up by Gradle regardless of Google API providing 2.1.3. – Vineel Mar 06 '19 at 14:38
  • 1
    @Vineel that is what I would like to believe. **However**, it seems the older version is picked up before the newer. I think the best approach is to force a single `Jackson Core` version, so to avoid confusion – LppEdd Mar 06 '19 at 15:10
  • How can it pick up the older version before. Am I missing something. It is showing in the gist that 2.8.8 is the picked version (at the top, its shows conflict resolution etc). – Vineel Mar 06 '19 at 15:12
  • com.fasterxml.jackson.core:jackson-core:2.8.8 (conflict resolution) is what I see in the Gist. – Vineel Mar 06 '19 at 15:13
  • @Vineel I don't know how to answer that question. However since the `requiresPropertyOrdering` method has been added in version `2.3+`, it seems this is really happening – LppEdd Mar 06 '19 at 15:13
  • @Vineel I edited the question to add how to force a specific version globally. I would also do a `./gradlew build --refresh-dependencies` – LppEdd Mar 06 '19 at 15:14