AnsweredAssumed Answered

Problem executing several searches in a row with Alfresco 1.

Question asked by frandepaula on Jun 19, 2008
Hi,

The problem comes up when I execute the next callings sequence through my application:

1. I first do a search ordered by date. (called method’s partial code is showed  below)

        ResultSet resultSet = null;   
        try { 
            SearchParameters sp = new SearchParameters();
            sp.addStore(storeRef);
            sp.setLanguage(SearchService.LANGUAGE_LUCENE);
            sp.setQuery(query);
            sp.addSort("@" + QName.createQName("custom.model", "DateReg"), true);
            resultSet = searchService.query(sp);
            …
        } catch (Exception e) {        
        } finally {
            if(resultSet != null) {
                resultSet.close();
            }
        }
        …

2. Secondly, every node’s property returned from the previous search is modified. (called method’s partial code is showed 

            UserTransaction userTransaction = transactionService.getNonPropagatingUserTransaction();                
            try {        
                userTransaction.begin();        
                NodeRef nodeCuenta = nodes.get(0);             
        Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
      properties.put(QName.createQName("custom.model","Reviewed"), Boolean.TRUE);         
      nodeService.addAspect(nodeCuenta, ContentModel.ASPECT_TITLED, properties);
                userTransaction.commit();  
            } catch (Exception ex) {
                try {
                    userTransaction.rollback();             
                }catch(Exception ex1){   
                }
            }

3. Finally, I try to execute first step again and the next exception comes out:

java.lang.ArrayIndexOutOfBoundsException: 158066
    at org.apache.lucene.search.FieldSortedHitQueue$3.compare(FieldSortedHitQueue.java:288)
    at org.apache.lucene.search.FieldSortedHitQueue.lessThan(FieldSortedHitQueue.java:114)
    at org.apache.lucene.util.PriorityQueue.upHeap(PriorityQueue.java:120)
    at org.apache.lucene.util.PriorityQueue.put(PriorityQueue.java:47)
    at org.apache.lucene.util.PriorityQueue.insert(PriorityQueue.java:58)
    at org.apache.lucene.search.FieldSortedHitQueue.insert(FieldSortedHitQueue.java:90)
    at org.apache.lucene.search.FieldSortedHitQueue.insert(FieldSortedHitQueue.java:97)
    at org.apache.lucene.search.TopFieldDocCollector.collect(TopFieldDocCollector.java:47)
    at org.apache.lucene.search.BooleanScorer2.score(BooleanScorer2.java:291)
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:132)
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:110)
    at org.apache.lucene.search.Hits.getMoreDocs(Hits.java:65)
    at org.apache.lucene.search.Hits.<init>(Hits.java:52)
    at org.apache.lucene.search.Searcher.search(Searcher.java:53)
    at org.alfresco.repo.search.impl.lucene.LuceneSearcherImpl2.query(LuceneSearcherImpl2.java:263)
    at org.alfresco.repo.search.SearcherComponent.query(SearcherComponent.java:85)
    at sun.reflect.GeneratedMethodAccessor230.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:116)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
    at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
    at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
    at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:165)
    at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
    at $Proxy66.query(Unknown Source)
    at es.tcu.rendicion.plataforma.negocio.gestioncuentas.servicio.impl.ServicioGestionDocumentalImpl.obtenerRefCuentasEstadoUltima(ServicioGestionDocumentalImpl.java:6004)

If I wait a few minutes to execute the third step, there is no problem. I think it is because lucen’s index is being updating and the process has no time to end the update completely.
If the search is not ordered by anything (date in our case), there is no problem either.

Please, could anyone help me? I need to know why it’s happening and how to solve it.

Thank you very much.

Outcomes