Pregunta

I am using the Searchable Plugin 0.6.4 in a Grails 2.2.3 application, but I am encountering a strange error. The error says: GrailsContextLoader Error initializing the application: No entities listed to be indexed, have you defined your entities correctly?

I only have one class listed to be indexed. Below is that class (simplified a bit):

class Incident {

    String howReceived
    Date timeOfCall
    Date timeOfArrival

    User reportingOfficer

    static searchable = [ except: ['version', 'dateCreated', 'lastUpdated'] ]

    static embedded = [ 'witnesses' ]
    static hasMany = [ witnesses: Witness ]

    static mapping = {
        datasource 'police'
        table 'incidents'
    }
}

That's all I have, a simple mapping. Below I've also included my stack trace and debug statements I turned on.

Edit: It appears that for some reason the sessionFactory bean is not finding any class meta data in the DefaultHibernateEntitiesLocator class. So...

Map allClassMetaData = sessionFactory.getAllClassMetadata();
assert allClassMetaData == null

Not sure why or if that information helps.

Debugging

searchable.SearchableGrailsPlugin Not found: Searchable
searchable.SearchableGrailsPlugin Trying to load config from 'SearchableConfiguration.class'
searchable.SearchableGrailsPlugin Not found: SearchableConfiguration
searchable.SearchableGrailsPlugin Defining Compass and Compass::GPS beans
searchable.SearchableGrailsPlugin Done defining Compass and Compass::GPS beans
spring.DefaultSearchableCompassFactoryBean Building SearchableCompassFactoryBean with grailsApplication [org.codehaus.groovy.grails.commons.DefaultGrailsApplication@10fdea05] and compassClassMappingXmlBuilder [grails.plugin.searchable.internal.compass.mapping.DefaultSearchableCompassClassMappingXmlBuilder@e0ef6fa]
spring.SearchableCompassFactoryBean Building new Compass
config.EnvironmentSearchableCompassConfigurator Setting Compass connection to [/Users/grantmcconnaughey/.grails/projects/campus-police/searchable-index/development]
config.DefaultGrailsDomainClassMappingSearchableCompassConfigurator Mapping class [com.company.police.Incident] with strategy [searchable class property]
config.DefaultGrailsDomainClassMappingSearchableCompassConfigurator No mapping strategy found for class [com.company.police.Employee]: assuming this class is not searchable
mapping.SearchableGrailsDomainClassCompassMappingUtils Mapping [Incident.howReceived]
mapping.SearchableGrailsDomainClassCompassMappingUtils Mapping [Incident.id]
mapping.SearchableGrailsDomainClassCompassMappingUtils Mapping [Incident.timeOfArrival]
mapping.SearchableGrailsDomainClassCompassMappingUtils Mapping [Incident.timeOfCall]
mapping.DefaultSearchableCompassClassMappingXmlBuilder Building Compass mapping XML for [com.company.police.Incident] from description [CompassClassMapping: mappedClass=[class com.company.police.Incident],  mappedClassSuperClass=[null], alias=[Incident], spellCheck=[null], subIndex=[null], root=[true], poly=[false], extend=[null], propertyMappings=[[CompassClassPropertyMapping: type=[property], propertyName=[domestic], attributes=[{}], CompassClassPropertyMapping: type=[property], propertyName=[hateCrime], attributes=[{}], CompassClassPropertyMapping: type=[property], propertyName=[howReceived], attributes=[{}], CompassClassPropertyMapping: type=[id], propertyName=[id], attributes=[{}], CompassClassPropertyMapping: type=[property], propertyName=[occurredFrom], attributes=[{}], CompassClassPropertyMapping: type=[property], propertyName=[occurredTo], attributes=[{}], CompassClassPropertyMapping: type=[property], propertyName=[officerAssaulted], attributes=[{}], CompassClassPropertyMapping: type=[property], propertyName=[officerKilled], attributes=[{}], CompassClassPropertyMapping: type=[property], propertyName=[readyForSignature], attributes=[{}], CompassClassPropertyMapping: type=[property], propertyName=[reportNumber], attributes=[{}], CompassClassPropertyMapping: type=[property], propertyName=[timeOfArrival], attributes=[{}], CompassClassPropertyMapping: type=[property], propertyName=[timeOfCall], attributes=[{}]]]]
mapping.DefaultSearchableCompassClassMappingXmlBuilder Mapping Searchable Property 'com.company.police.Incident.howReceived' with property attributes [name:howReceived] and meta-data [howReceived:[:]]
mapping.DefaultSearchableCompassClassMappingXmlBuilder Mapping Searchable Property 'com.company.police.Incident.timeOfArrival' with property attributes [name:timeOfArrival] and meta-data [timeOfArrival:[:]]
mapping.DefaultSearchableCompassClassMappingXmlBuilder Mapping Searchable Property 'com.company.police.Incident.timeOfCall' with property attributes [name:timeOfCall] and meta-data [timeOfCall:[:]]
mapping.DefaultSearchableCompassClassMappingXmlBuilder com.company.police.Incident xml [<?xml version="1.0"?>
<!DOCTYPE compass-core-mapping PUBLIC 
    "-//Compass/Compass Core Mapping DTD 2.0//EN"
    "http://www.compass-project.org/dtd/compass-core-mapping-2.2.dtd">
<compass-core-mapping>
  <class name='com.company.police.Incident' alias='Incident' root='true' poly='false' support-unmarshall='true'>
    <id name='id' />
    <property name='howReceived'>
      <meta-data>howReceived</meta-data>
    </property>
    <property name='timeOfArrival'>
      <meta-data>timeOfArrival</meta-data>
    </property>
    <property name='timeOfCall'>
      <meta-data>timeOfCall</meta-data>
    </property>
  </class>
</compass-core-mapping>]
mapping.SearchableClassPropertySearchableGrailsDomainClassMappingConfigurator Adding [com.company.police.Incident] mapping to CompassConfiguration
spring.SearchableCompassFactoryBean Done building Compass
domain.DynamicDomainMethodUtils Adding searchable methods to [com.company.police.Incident]
searchable.SearchableGrailsPlugin Started Compass::GPS
compass.CompassGpsUtils Starting Searchable Plugin bulk index

Stacktrace

context.GrailsContextLoader Error initializing the application: No entities listed to be indexed, have you defined your entities correctly?
java.lang.IllegalArgumentException: No entities listed to be indexed, have you defined your entities correctly?
    at org.compass.gps.device.support.parallel.ConcurrentParallelIndexExecutor.performIndex(ConcurrentParallelIndexExecutor.java:88)
    at org.compass.gps.device.support.parallel.AbstractParallelGpsDevice.index(AbstractParallelGpsDevice.java:119)
    at org.compass.gps.impl.DefaultReplaceIndexCallback.buildIndexIfNeeded(DefaultReplaceIndexCallback.java:42)
    at org.compass.core.lucene.engine.manager.DefaultLuceneSearchEngineIndexManager$ReplaceIndexOperationCallback.firstStep(DefaultLuceneSearchEngineIndexManager.java:281)
    at org.compass.core.lucene.engine.manager.DefaultLuceneSearchEngineIndexManager.doOperate(DefaultLuceneSearchEngineIndexManager.java:218)
    at org.compass.core.lucene.engine.manager.DefaultLuceneSearchEngineIndexManager.doReplaceIndex(DefaultLuceneSearchEngineIndexManager.java:266)
    at org.compass.core.lucene.engine.manager.DefaultLuceneSearchEngineIndexManager.replaceIndex(DefaultLuceneSearchEngineIndexManager.java:261)
    at org.compass.gps.impl.SingleCompassGps.doIndex(SingleCompassGps.java:118)
    at org.compass.gps.impl.AbstractCompassGps.index(AbstractCompassGps.java:154)
    at org.compass.gps.impl.AbstractCompassGps.index(AbstractCompassGps.java:128)
    at grails.plugin.searchable.internal.compass.CompassGpsUtils.index(CompassGpsUtils.java:49)
¿Fue útil?

Solución

The issue was using a dataSource with a non-default name, in this case 'police'. I haven't seen anywhere in the doc that mentions the plugin will not work with a dataSource with a different name than simply "dataSource". I will try to update their doc soon.

I found the fix here. In case that link goes down, here's what you do. Add the following to resources.groovy:

import org.compass.gps.device.hibernate.HibernateGpsDevice
import grails.plugin.searchable.internal.compass.config.SessionFactoryLookup

beans = {
    compassGpsDevice(HibernateGpsDevice) { bean ->
        bean.destroyMethod = "stop"
        name = "hibernate"
        sessionFactory = { SessionFactoryLookup sfl ->
          sessionFactory = ref('sessionFactory_datasourceName') 
        }
        fetchCount = 5000
    }
}

To add other dataSources with indexable classes, add the following:

anotherUniquecompassGpsDevice(HibernateGpsDevice) { bean ->
    bean.destroyMethod = "stop"
    name = "unqiueHibernateName"
    sessionFactory = { SessionFactoryLookup sfl ->
        sessionFactory = ref('sessionFactory_uniquedatasource') 
    }
    fetchCount = 5000
  }

And finally add...

import org.compass.gps.impl.SingleCompassGps

compassGps(SingleCompassGps) {
    compass = ref('compass')
    gpsDevices = [compassGpsDevice, anotherUniqueCompassGpsDevice]
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top