Gradle 2.1 Full release apply plugin ear failed

I am using Gradle 2.1 and have used it for multiple builds, but I am getting the apply plugin id ‘ear’ failed exception. It works in one build, but not in an another one. I have tried using Gradle 2.0 and 2.2.1 but I still get the same error.

You will need to provide more information on your issue. Please provide your relevant build logic plus the exception you are seeing.