Grails hibernate/Searchable 通过给出以下异常来停止服务器启动

Posted

技术标签:

【中文标题】Grails hibernate/Searchable 通过给出以下异常来停止服务器启动【英文标题】:Grails hibernate/Searchable stops server to start by giving the exception below 【发布时间】:2013-03-04 09:02:33 【问题描述】:

我们在我们的 Grails 应用程序中使用 Grails 2.1.1 和 Searchable 插件 0.6.4,并在一些域上实现了可搜索,如下所示,所有映射。

class User 
      .....
      static hasMany = [userEducations : UserEducations , userWorkings : UserWorkings ]
      ......
      static searchable = 
        content: spellCheck 'include'
        all termVector: "yes"
        userEducations  component: true
        userWorkings component: true
      
      ......


class UserEducations 
    .....
    Schools schools 
    .....
    static belongsTo = [user : User ]
    ......
    static searchable = 
        content: spellCheck 'include'
        all termVector: "yes"
        schools  component: true
    
      ......


class UserWorkings 
      .....
      Organizations organizations 
      .....
     static belongsTo = [user : User ]
     ....
     static searchable = 
        content: spellCheck 'include'
        all termVector: "yes"
        organizations  component: true
     
     ......


class Schools 
      ......
      static searchable = true
      ......


class Organizations 
      ......
       static searchable = true
      ......

使用正确的映射和约束成功保存数据。

当我们在具有关系的表用户中出现下面的 drows 时,问题就开始了

用户 a1 -> UserEducations b1 -> 学校 d1

用户 a2 -> UserEducations b2 -> 学校 d1

用户 a1 -> UserWorkings c1 -> 组织 e1

用户 a2 -> UserWorkings c2 -> 组织 e1

(我们不确定上述事实可能是由于大量数据而发生的问题。)

然后当我们尝试启动服务器时,我们收到以下异常并且服务器无法启动

我们已尝试删除可搜索索引并重新启动,但它也无法启动。

只有当我们截断以上5个域对应的表时,服务器才会启动。

18:30:54,133 [Compass Gps Index [pool-5-thread-5]] ERROR indexer.ScrollableHibernateIndexEntitiesIndexer  - hibernate: Failed to index the database
org.compass.core.engine.SearchEngineException: Processor [4]: Failed to add job [Job Create [alias [Organizations] uid [Organizations#456#]] Resource [Organizations [stored/uncompressed,indexed,omitNorms<alias:Organizations>],[stored/uncompressed,indexed,omitNorms,omitTf<$/Organizations/id:456>],[stored/uncompressed,indexed<active:true>],[stored/uncompressed,indexed<dateCreated:2013-02-28-14-03-05-0-PM>],[stored/uncompressed,indexed,tokenized<aaa:109122482450911>],[stored/uncompressed,indexed<lastUpdated:2013-02-28-14-03-05-0-PM>],[stored/uncompressed,indexed,tokenized<name:Asc>],[stored/uncompressed,indexed<version:0>],[stored/uncompressed,indexed,omitNorms,omitTf<$/uid:Bs#456#>]]] after [10000ms] and backlog size [100]
        at org.compass.core.lucene.engine.transaction.support.AbstractConcurrentTransactionProcessor$Processor.addJob(AbstractConcurrentTransactionProcessor.java:496)
        at org.compass.core.lucene.engine.transaction.support.AbstractConcurrentTransactionProcessor.create(AbstractConcurrentTransactionProcessor.java:158)
        at org.compass.core.lucene.engine.LuceneSearchEngine.createOrUpdate(LuceneSearchEngine.java:290)
        at org.compass.core.lucene.engine.LuceneSearchEngine.create(LuceneSearchEngine.java:268)
        at org.compass.core.impl.DefaultCompassSession.create(DefaultCompassSession.java:413)
        at org.compass.core.impl.DefaultCompassSession.create(DefaultCompassSession.java:397)
        at org.compass.core.impl.ExistingCompassSession.create(ExistingCompassSession.java:305)
        at org.compass.gps.device.hibernate.indexer.ScrollableHibernateIndexEntitiesIndexer$RowBuffer.flush(ScrollableHibernateIndexEntitiesIndexer.java:212)
        at org.compass.gps.device.hibernate.indexer.ScrollableHibernateIndexEntitiesIndexer$RowBuffer.close(ScrollableHibernateIndexEntitiesIndexer.java:206)
        at org.compass.gps.device.hibernate.indexer.ScrollableHibernateIndexEntitiesIndexer.performIndex(ScrollableHibernateIndexEntitiesIndexer.java:151)
        at org.compass.gps.device.support.parallel.ConcurrentParallelIndexExecutor$1$1.doInCompassWithoutResult(ConcurrentParallelIndexExecutor.java:104)
        at org.compass.core.CompassCallbackWithoutResult.doInCompass(CompassCallbackWithoutResult.java:29)
        at org.compass.core.CompassTemplate.execute(CompassTemplate.java:133)
        at org.compass.gps.impl.SingleCompassGps.executeForIndex(SingleCompassGps.java:147)
        at org.compass.gps.device.support.parallel.ConcurrentParallelIndexExecutor$1.call(ConcurrentParallelIndexExecutor.java:102)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:679)

我们的问题类似于下面的帖子

http://grails.1312388.n4.nabble.com/hibernate-Searchable-failing-to-index-on-program-start-td4119566.html

我们已尽力解决问题,但没有成功。 请帮助我们解决这个问题。

【问题讨论】:

您是否尝试过删除现有的索引文件? 是,但根本没用 @Shashank.gupta40,祝你好运,我也面临这个问题。你能帮帮我吗? 您找到解决方案了吗?我们现在遇到了同样的问题。 @whitenexx : 尝试使用以下链接在启动时配置批量索引grails.org/Searchable+Plugin+-+FAQ。 【参考方案1】:

转到您的控制台并输入:

grails install-searchable-config

然后打开 myproject/grails-app/conf/Searchable.groovy 并搜索以下内容并更改我指出的值。

mirrorChanges = false
bulkIndexOnStartup = false

在 Bootstrap.groovy 中:

class BootStrap 
   def searchableService

   def init =  servletContext ->
      // do any data loading you would normally do

      // Manually start the mirroring process to ensure that it comes after the automated migrations.
      println "Performing bulk index"
      searchableService.reindex()
      println "Starting mirror service"
      searchableService.startMirroring()
   

【讨论】:

但是它不会索引数据库,如果我们必须索引数据库怎么办? 我已按照您的步骤操作,但仍然存在错误。 2013 年 9 月 13 日 14:36:17:225 错误 hibernate:无法索引数据库 org.compass.core.engine.SearchEngineException:处理器 [2]:无法添加作业 [作业创建 [别名 [成员] uid [成员#586#]] 资源 [Member ..... 在 [10000ms] 和积压大小 [100] 之后有什么想法吗?

以上是关于Grails hibernate/Searchable 通过给出以下异常来停止服务器启动的主要内容,如果未能解决你的问题,请参考以下文章

如何使用 grails 命令行编译 grails 项目?

是否可以在 Grails 之外使用 Grails 验证?如何?

Grails:企业级 Grails [关闭]

Grails - grails.converters.JSON - 删除类名

Grails - 在刷新 grails 错误之前保存瞬态实例?

Grails 3 - 资源插件