How to Install the Searchable Plugin with Grails 2.3.x and Hibernate 4.x

If you like to use the famous searchable plugin (ver. 0.6.4) with Grails 2.3.0 and Hibernate 4.x and you follow the standard installation instruction, then you will end with the following error:

 GrailsDomainClassUtils.java:38:
 error: non-static method getMapping(Class<?>) cannot be referenced from a static context

and you are stuck.

Fortunately, this issue was fixed in the plugin’s github repo, as you can see here.
At the time of writing, there is not yet an official release available, but a snapshot ver. 0.6.5-SNAPSHOT.

If you want to install the searchable plugin with Grails 2.3.0 and Hibernate 4.x, just add the following modifications to your BuildConfig.groovy:

// BuildConfig.groovy
repositories {
      ...
      mavenRepo "http://repo.grails.org/grails/core" // needed for compass, etc.
      }

plugins {
      // plugins for the build system only
      build ":tomcat:7.0.42"
      ...
      // plugins needed at runtime but not for compilation
      runtime ":hibernate4:4.1.11.1"
      ...
      compile ":searchable:0.6.5-SNAPSHOT"
    }

 

CAVEAT: this is just an instruction how to install the searchable plugin.

If you likeI to use the plugin, you will end up with “java.lang.NoClassDefFoundError: org/hibernate/impl/SessionFactoryImpl” coming from the compass framework.

HTH Johannes
 

Update:

The plugin itself is written for Hibernate 3, so you can’t use it with Hibernate4 . Porting to Hibernate 4 might be possible, but because Compass is not actively developed anymore, therefore I will invest my time into its successor elastic search.

Update:

Meanwhile a new Searchable plugin version 0.6.5 was released.
This version works with Grails 2.3.0 and Hibernate 3. A version, which works with Hibernate 4 is still not available.

About these ads
This entry was posted in Development, Grails and tagged , , . Bookmark the permalink.

3 Responses to How to Install the Searchable Plugin with Grails 2.3.x and Hibernate 4.x

  1. Compass and the searchable use Hibernate 3. Hibernate 4 isn’t backwards compatible with Hibernate 3 – they changed packages and made other significant changes, so any plugin that works with Hibernate 3 wil need an update to use Hibernate 4. Since that won’t work with Hibernate 3, we really need two parallel versions of each unfortunately.

    • Yes, you are right Burt.
      I looked at the compass code and a port to Hibernate4 might be possible, but Compass is not longer under active development, so I will invest my time into its successor elasticsearch.
      With elasticsearch plugin it is the same, the plugin is written for Hibernate 3 and needs some modification für Hibernate 4.
      I haven’t spent much time into it, but it looks promising – at least hopefully.

      Yours Johannes

  2. Angel Alberici says:

    Hello Johannes,
    I dind’t understand how this page was going to resolve my problem:
    “In some cases during implementation with Grails 2.3, Searchable Plugin 0.6.6, i had end up with Issue unable tp locate org.compass-project:compass:2.2.1. Refer to this tutorial for the set up in case you are facing such issues with 2.3 Grails version. http://jolorenz.wordpress.com/2013/10/02/how-to-use-searchable-plugin-with-grails-2-3-0-and-hibernate-4-x/

    Like you said, I just added the:
    repositories {

    mavenRepo “http://repo.grails.org/grails/core” // needed for compass, etc.
    }

    And now it isn’t showing the compass error anymore.

    Thank you very much

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com 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