Jakub Bochenski
Jakub Bochenski

Reputation: 3265

Grails 2.0.4/2.1.1 test-app throws ClassNotFoundException (GrailsSpecTestType)

I have a legacy grails appliction that I recentyl upgraded 1.3.7 -> 2.0.4 The same thing happens after I upgrade it to 2.1.1

When I try to run test-app from GGTS I get:

| Error Error executing script TestApp: java.lang.ClassNotFoundException: grails.plugin.spock.test.GrailsSpecTestType (Use --stacktrace to see the full trace)

There is a similiar report from April on SS site.

I also see there are a lot of questions about similiar exceptions for grails 1.3.7 -- this however is a problem affecting 2.0.4.

EDIT: OK, it actually happens in command line too, but at least I can get it to work. Unfortunately after a restart it breaks again.

Here is what I do to fix it in console, basically I upgrade to 0.7 and the downgrade to 0.5-groovy-1.7

grails> clean
| Application cleaned.
grails> refresh-dependencies
| Dependencies refreshed.
grails> test-app
| Compiling 73 source files
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
| Compiling 119 source files

| Compiling 119 source files.
| Error Error running script test-app : java.lang.ClassNotFoundException: grails.plugin.spock.test.GrailsSpecTestType (U
se --stacktrace to see the full trace)
grails> install-plugin spock
| Resolving plugin spock. Please wait...
> You currently already have a version of the plugin installed [spock-0.5-groovy-1.7]. Do you want to update to [spock-0
.7]? [y,n] y
| Plugin installed.
grails> clean
| Application cleaned.
grails> refresh-dependencies
| Application cleaned.....
> You currently already have a version of the plugin installed [spock-0.7]. Do you want to update to [spock-0.5-groovy-1
.7]? [y,n] n
| Dependencies refreshed.
grails> test-app
> You currently already have a version of the plugin installed [spock-0.7]. Do you want to update to [spock-0.5-groovy-1
.7]? [y,n] n
| Compiling 73 source files
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
| Compiling 119 source files

| Compiling 119 source files.
| Error Error running script test-app : java.lang.ClassNotFoundException: grails.plugin.spock.test.GrailsSpecTestType (U
se --stacktrace to see the full trace)
grails> install-plugin spock
| Plugin 'spock' with version '0.7' is already installed
| Plugin not installed.
grails> uninstall-plugin spock
| Uninstalled plugin [spock]
grails> clean
| Application cleaned.
grails> refresh-dependencies
| Dependencies refreshed.
grails> test-app
| Compiling 73 source files
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
| Compiling 119 source files    
| Running 8 unit tests... 5 of 8

Upvotes: 2

Views: 1630

Answers (1)

Jakub Bochenski
Jakub Bochenski

Reputation: 3265

So this is apparently caused by some misbehaving plugin exporting it's spock dependency. Sample workaround if your troublemaker is GWT:

compile(':gwt:0.8') {
exclude 'spock'
}

Thanks to Nathan Dunn

Upvotes: 1

Related Questions