Grails plugin dependency issues

Ran into a few problems with Grails plugin dependencies here are some solutions.

Applies to Stack

Grails 2.3.0, cache:1.1.1, asset-pipeline:1.0.4, mongodb:1.3.0, shiro:1.2.0, hibernate:, database-migration:1.3.5

Problem 1:

Conditions: Using cache:1.1.1

grails compile fails with error:

| Error Compilation error: startup failed:
Compile error during compilation with javac.
C:\Grails\MyProject\target\work\plugins\cache-1.1.1\src\java\grails\plugin\cache\web\filter\ error: package net.sf.ehcache.constructs.blocking does not exist
import net.sf.ehcache.constructs.blocking.LockTimeoutException;

Solution 1:

Add the following in the BuildConfig dependencies section (if mongodb is used by a plugin, this should go into plugin’s BuildConfig dependencies)

dependencies {
 compile "net.sf.ehcache:ehcache-core:2.4.6"

Verification 1:

Delete target/* from any plugin and project sources
grails compile

Problem 2:

Conditions: You are using shiro:1.2.0 + Servlet API v3.0. Shiro includes servelt-api 2.5 by default and is causing a conflict.

grails compile fails with error:

C:\Grails\MyProject\target\work\plugins\cache-1.1.1\src\java\grails\plugin\cache\web\ error: method does not override or implement a method from a supertype
C:\Grails\MyProject\target\work\plugins\cache-1.1.1\src\java\grails\plugin\cache\web\filter\ error: cannot find symbol
contentType = response.getContentType();

Solution 2:

To eliminate this problem, exclude servlet-api from Shiro for shiro-cas:

dependencies {
compile("org.apache.shiro:shiro-cas:1.2.2") {
excludes "servlet-api"

Verification 2:

Delete target/*
grails compile

Problem 3:

Conditions: You are using shiro:1.2.0 + mongodb:1.0.3 – hibernate: – database-migration:1.3.5 (ie hibernate and database-migration are not included)

grails compile fails with error:

| Error Fatal error during compilation org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
C:\Grails\MyProject\target\work\plugins\hibernate-2.2.4\.\HibernateGrailsPlugin.groovy: 18: unable to resolve class org.codehaus.groovy.grails.plugins.orm.hibernate.HibernatePluginSupport
@ line 18, column 1.
import org.codehaus.groovy.grails.plugins.orm.hibernate.HibernatePluginSupport

IntelliJ IDEA 13 may also throw a “IDEA hook: Grails not found!” error.

This is due to a dependency of shiro on hibernate-2.2.4 api.

Soution 3:

runtime (":shiro:1.2.0") {
excludes "hibernate"

Verification 3:

Delete target/*
grails compile

One way to sort out such errors is to run the grails dependency-report and look for the jar file which causes the problem. Trace back from jar file to the actual included plugin or dependency and add the excludes in either dependencies section or plugins section appropriately.


One Response to Grails plugin dependency issues

  1. Thank you so much, your explanation helped me to resolve the issue for having grails shiro and cache plugin..I had to make a small change, in problem 2, instead of shiro-cas in buildconfig.groovy.. I did
    plugins { …
    compile(“:shiro:1.2.0”) {
    excludes “servlet-api”

    delete the target folder as well as the .grails/2.3.3/projects/yourproject folder..


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: