4

I'm trying to install the elastic search plugin (elasticsearch:0.0.4.4) on my Grails project (grails version 2.4.4) and after adding the plugin dependency and running the app (grails run-app) I get some rather severe errors.

Stacktrace:

Apr 02, 2015 9:44:08 AM org.springsource.loaded.agent.SpringLoadedPreProcessor preProcess
SEVERE: Unexpected problem transforming call sites
java.lang.IllegalStateException: Unexpected problem processing bytes for class
    at org.springsource.loaded.ConstantPoolChecker2.readConstantPool(ConstantPoolChecker2.java:196)
    at org.springsource.loaded.ConstantPoolChecker2.<init>(ConstantPoolChecker2.java:128)
    at org.springsource.loaded.ConstantPoolChecker2.getReferences(ConstantPoolChecker2.java:102)
    at org.springsource.loaded.MethodInvokerRewriter.rewrite(MethodInvokerRewriter.java:300)
    at org.springsource.loaded.MethodInvokerRewriter.rewriteUsingCache(MethodInvokerRewriter.java:156)
    at org.springsource.loaded.TypeRegistry.methodCallRewriteUseCacheIfAvailable(TypeRegistry.java:828)
    at org.springsource.loaded.agent.SpringLoadedPreProcessor.preProcess(SpringLoadedPreProcessor.java:321)
    at org.springsource.loaded.agent.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:102)
    at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
    at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:655)
    at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:765)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at org.codehaus.groovy.runtime.m12n.MetaInfExtensionModule.newModule(MetaInfExtensionModule.java:72)
    at org.codehaus.groovy.runtime.m12n.StandardPropertiesModuleFactory.newModule(StandardPropertiesModuleFactory.java:48)
    at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromProperties(ExtensionModuleScanner.java:76)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerExtensionModuleFromProperties(MetaClassRegistryImpl.java:152)
    at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.initialiseGroovyExtensionModules(DefaultGrailsApplication.java:710)
    at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.initialise(DefaultGrailsApplication.java:684)
    at org.codehaus.groovy.grails.project.plugins.GrailsProjectPluginLoader$_loadPlugins_closure2.doCall(GrailsProjectPluginLoader.groovy:132)
    at org.codehaus.groovy.grails.project.plugins.GrailsProjectPluginLoader$_loadPlugins_closure2.call(GrailsProjectPluginLoader.groovy)
    at org.codehaus.groovy.grails.cli.api.BaseSettingsApi.profile(BaseSettingsApi.java:342)
    at org.codehaus.groovy.grails.project.plugins.GrailsProjectPluginLoader.loadPlugins(GrailsProjectPluginLoader.groovy:99)
    at org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean.afterPropertiesSet(GrailsPluginManagerFactoryBean.java:75)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1613)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1550)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:687)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener.initWebApplicationContext(GrailsContextLoaderListener.java:71)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4992)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5490)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Entry: 39 15
    at org.springsource.loaded.ConstantPoolChecker2.processConstantPoolEntry(ConstantPoolChecker2.java:335)
    at org.springsource.loaded.ConstantPoolChecker2.readConstantPool(ConstantPoolChecker2.java:186)
    ... 58 more

this repeats many times. more interesting:

| Error 2015-04-02 09:44:29,658 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener  - Error initializing the application: No datastore implementation specified
Message: No datastore implementation specified
    Line | Method
->>  135 | doCall                    in ElasticsearchGrailsPlugin$_closure1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    754 | invokeBeanDefiningClosure in grails.spring.BeanBuilder
|    584 | beans . . . . . . . . . . in     ''
|    527 | invokeMethod              in     ''
|    262 | run . . . . . . . . . . . in java.util.concurrent.FutureTask
|   1145 | runWorker                 in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run                       in java.lang.Thread
| Error Forked Grails VM exited with error

Edit: I've tried some other things. I downloaded elasticsearch-1.5.0, created the environment variable ELASTIC_SEARCH_HOME, and added that to my path, this has removed the environment variable error that previously popped up when running grails package.

I also added the default config (found at the bottom of this page) for elastic search to the bottom of my Config.groovy file. Also I added:

elasticsearch {
  datastoreImpl = "hibernateDatastore"
}

to the default configuration in my Config.groovy file.

So after a grails run-app I get several of the first stacktrace like before, but not the second. In addition my app does run and not functionalities appear to be broken.

Edit 2:

Some extra information that might be of interests. I created a new grails app (grails 2.4.4), added the elasticsearch plugin dependency declaration (':elasticsearch:0.0.4.4') to the BuildConfig.groovy file, added the default configuration and datastoreImpl to my Config.groovy file, and did a grails run-app and I got the same stacktrace (the first one above) repeated several times, but the app still runs.

rhl
  • 55
  • 2
  • 7
  • `No datastore implementation specified`: have you followed the config doc? http://noamt.github.io/elasticsearch-grails-plugin/guide/configuration.html – cfrick Apr 02 '15 at 17:29
  • It seems there is a default config provided by the plugin: "The plugin provide a default configuration, but you may add your own settings in your Config.groovy script." I tried explicitly adding the default configuration into my Config.groovy file but that didn't do much. – rhl Apr 02 '15 at 17:48
  • those springloaded errors look odd. can you remove `target` and do a `grails package` and see how that behaves. there are no oddities in your environment (disk close to full, your code stored on nfs/cifs, ... younameit)? – cfrick Apr 02 '15 at 17:52
  • Alright I cleared the target folder of the project and ran grails package and I see this: "Installed plugin elasticsearch-0.0.4.4 The environment variable ELASTIC_SEARCH_HOME specifying the location of ElasticSearch is not set. Please make sure this variable is set so that the ElasticSearch plugin scripts function correctly." Other than that packaging completes fine, but a grails run-app returns the same errors. – rhl Apr 02 '15 at 18:29
  • then i'd say, that you have no ES running on your machine. – cfrick Apr 02 '15 at 19:04
  • Have you tried setting `elasticSearch.datastoreImpl`? [http://noamt.github.io/elasticsearch-grails-plugin/guide/configuration.html](http://noamt.github.io/elasticsearch-grails-plugin/guide/configuration.html) – sanwrit Apr 04 '15 at 11:53
  • Same thing on my end. It doesn't break elasticsearch but making changes on my classes while the JVM is running is not there anymore. There's a new version of springloaded which may interest you: [https://github.com/spring-projects/spring-loaded](https://github.com/spring-projects/spring-loaded). I'll test that one also when I get the time. – sanwrit Apr 07 '15 at 05:17

3 Answers3

2

I had a similar issue - to fix, I made sure that:

  • my domain object had 'static searchable = true' (will tweak later to fine tune)
  • Config.groovy has the 'elasticSearch.datastoreImpl' setting
  • use Grails 2.5.0 (which has the latest springloaded jar in it)

grails clean; grails run-app - no exceptions, app runs

Basically, upgrade to grails 2.5.0

Geoff H
  • 36
  • 2
0

If you replace springloaded with the latest version in the wrapper directory it fixes the probelem. Had the same problem with elasticsearch 0.4.4 running on Grails 2.3.5

0

I had a similar issue using IntelliJ, and the problem was the version of Java.

The new versions of IntelliJ use by default the Java11, but with old versions of Grails you need to use older java versions, like Java 7.

Go to File> Project Structure> Project>SDK and choose Java 1.7

After this the problems looks to be fixed.

leomeurer
  • 742
  • 1
  • 8
  • 24