Multi project build exception java.lang.NoClassDefFoundError while deploy via eclipse


(crazyhavoc.80) #1

Hi All, I am new to gradle and I am trying to configure simple spring mcv project containing 3 projects: project-api, project-web, and project-test. This is my main build.grade:

sourceCompatibility = 1.7
   subprojects {
    apply plugin: 'java'
 }

this is my settings.gradle

rootProject.name = 'project'
include 'project-test'
include 'project-web'
include 'project-api'

This is my build.gradle from api

apply plugin: 'java'
apply plugin: 'eclipse'
  repositories {
    mavenCentral()
}
  dependencies {
}

And this is part of my build.gradlew from web.

dependencies {
 compile project(':project-api')

And issue is then when I try to deploy my app from eclipse I get following exception:

nested exception is java.lang.NoClassDefFoundError: project/api/ImportantClass

In eclipse iteself everything looks ok I don’t have any errors. However if I buiild war using gradle and then deploy it manually to tomact I have no issues and jar project-api.jar is added to war and I am able to use my application. I guess this is related to gradle and eclipse perhaps I am missing something in my build.gradle? This is my OS info:

------------------------------------------------------------
Gradle 1.10
------------------------------------------------------------
  Build time:
 2013-12-17 09:28:15 UTC
Build number: none
Revision:
   36ced393628875ff15575fa03d16c1349ffe8bb6
  Groovy:
     1.8.6
Ant:
        Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:
        2.2.0
JVM:
        1.7.0_51 (Oracle Corporation 24.51-b03)
OS:
         Linux 3.11.0-13-generic amd64

Thanks in advance for any help.


(Peter Niederwieser) #2

Make sure to apply the ‘eclipse’ plugin to ‘allprojects’.


(crazyhavoc.80) #3

I added to my main build.gradle

allprojects {
    apply plugin: 'eclipse'
}

Then run clean cleanEclipse eclipse and reimport project and still the same.


(Peter Niederwieser) #4

When you work in Eclipse, build/deploy happens entirely on the Eclipse side, so you’ll have to start looking there. First thing I’d check is whether the Eclipse projects have the correct class path with the correct (Eclipse) project dependencies.


(crazyhavoc.80) #5

Ok thaks for help. Now when I am sure that this is not gradle issue I will try to look for solution on eclipse site. Best Regards