Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle giving ClassNotFoundException while building Grails project

I am trying to use the gradle-grails-plugin to build an existing (small) Grails project. Should this work? What is the relationship between the dependencies in build.gradle and the ones specified in buildConfig.groovy?

In any event, I have two projects, so the topmost build.gradle file is in the parent directory and looks like:

buildscript {
   repositories {
      jcenter()
   }
   dependencies {
      classpath "org.grails:grails-gradle-plugin:2.2.0.RC1"
   }
}

task wrapper(type: Wrapper) {
   gradleVersion = '2.3'
}

and then the build.gradle in the Grails project looks like:

apply plugin: "grails"

repositories {
   grails.central() //creates a maven repo for the Grails Central repository (Core libraries and plugins)
}

grails {
   grailsVersion = '2.4.4'
   groovyVersion = '2.3.9'
   springLoadedVersion '1.2.0.RELEASE'
}

dependencies {
   bootstrap "org.grails.plugins:tomcat:7.0.55.3" 
   compile 'org.grails.plugins:asset-pipeline:3.0.1' 

   compile 'org.grails.plugins:scaffolding:2.1.2'
   compile 'org.grails.plugins:cache:1.1.8'

   runtime 'org.grails.plugins:hibernate4:4.3.1.1'
   runtime 'org.grails.plugins:database-migration:1.3.8'
   runtime 'org.grails.plugins:jquery:1.11.0'
}

However, when I run ./gradlew war, I get back:

Caused by: java.long.ClassNotFoundException: grails.artefact.Service

Can anyone shed some light on this? There are practically no references to that via Google, it seems to be a Grails 3.x class? Also, I am using Java 1.7.

like image 432
JoeG Avatar asked Apr 25 '15 11:04

JoeG


1 Answers

Class grails.artefact.Service is indeed accessible from v3.0 of grails framework - as can be seen here.

With the following statement grailsVersion = '2.4.4' v2.4.4 is specified to be used and it all looks ok. What spoils the build is the following dependencies entry:

compile 'org.grails.plugins:asset-pipeline:3.0.1' 

In this package there is a class asset/pipeline/grails/AssetProcessorService that imports the mentioned grails.artefact.Service which isn't loaded at runtime (probably because of v2.4.4 used).

Unfortunately I can't suggest any solution apart from the trivial like excluding this dependency. I am not a grails developer nor have I set the environment up.

Hopes that helps somehow.

like image 137
Opal Avatar answered Oct 09 '22 15:10

Opal