-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: manual indexing ok auto indexing broken
PostPosted: Mon Feb 16, 2009 5:28 pm 
Beginner
Beginner

Joined: Tue May 03, 2005 11:45 pm
Posts: 43
Hibernate version:

hibernate 3.3.1.ga
hibernate-annotations-3.4.0.ga
hibernate-commons-annotations-3.1.0.ga
hibernate-search-3.1.0.ga
hibernate-tools-3.2.4.CR2

lucene-core-2.4.0.jar

data source #1 - using lucene indexing :

Code:
<jee:jndi-lookup id="core.dataSource" jndi name="jdbc/coreJdbcPool" />
<bean id="core.sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" >
        <property name="dataSource" ref="core.dataSource" />

        <property name="packagesToScan" value="com.chaos.core.model"/>

        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${core_serverapp.hibernate.dialect}</prop>

                <!--
                    enable 2nd level cache - ehcache
                 -->

                <prop key="hibernate.cache.use_second_level_cache">true</prop>
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
                <prop key="hibernate.cache.provider_configuration_file_resource_path">com/chaos/core/ehcache-dao.xml</prop>

                <prop key="hibernate.cache.use_query_cache">true</prop>
                <prop key="hibernate.generate_statistics">true</prop>
                <prop key="hibernate.cache.use_structured_entries">true</prop>

                <!--<prop key="hibernate.hbm2ddl.auto">update</prop>-->

                <!-- lucene -->
                <prop key="hibernate.search.default.indexBase">${core_serverapp.lucene.indexBase}</prop>
                <prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>

                <!-- To disable indexing uncomment the listeners line below.  Note that there is no performance runtime when the listeners
                       are enabled while no entity is indexable. -->
                <!-- <prop key="hibernate.search.autoregister_listeners">false</prop> -->
            </props>
        </property>

        <!-- lucene event listeners -->
        <property name="eventListeners">
            <map>
                <entry key="post-update">
                    <set>
                        <bean class="org.hibernate.search.event.FullTextIndexEventListener"/>
                        <bean class="com.chaos.core.service.notification.NotificationEventListener"/>
                    </set>
                </entry>
                <entry key="post-insert">
                    <set>
                        <bean class="org.hibernate.search.event.FullTextIndexEventListener"/>
                        <bean class="com.chaos.core.service.notification.NotificationEventListener"/>
                    </set>
                </entry>
                <entry key="post-delete">
                    <set>
                        <bean class="org.hibernate.search.event.FullTextIndexEventListener"/>
                        <bean class="com.chaos.core.service.notification.NotificationEventListener"/>
                    </set>
                </entry>
                <entry key="post-collection-recreate">
                    <set>
                        <bean class="org.hibernate.search.event.FullTextIndexEventListener"/>
                    </set>
                </entry>
                <entry key="post-collection-remove">
                    <set>
                        <bean class="org.hibernate.search.event.FullTextIndexEventListener"/>
                    </set>
                </entry>
                <entry key="post-collection-update">
                    <set>
  <set>
                        <bean class="org.hibernate.search.event.FullTextIndexEventListener"/>
                    </set>
                </entry>
            </map>
        </property>
    </bean>

   <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
      <property name="allowCustomIsolationLevels" value="true" />
   </bean>

edit 2/18 7:18am est

@Indexed
@Analyzer(impl = EnglishSnowballAnalyzer.class)
@Entity
@Table(name = "assets")
@org.hibernate.annotations.Entity(dynamicInsert=true, dynamicUpdate = true)
@Cache(usage = CacheConcurencyStrategy.READ_WRITE)
public class Asset implements java.io.Serializable {

@DocmentId
@Id
@GeneratedValue
@Column(name = "ID", nullable = false)
private long id;

@IndexedEmbedded
@OneToMany(cascade = {}, fetch = FetchType.LAZY, mappedBy = "asset")
private List<GatekeeperActivity> gatekeeperActivityList = new ArrayList<GatekeeperActivity>(0);

.
.
.

}

@Entity
@Table(name = "gatekeeper_acitvity")
@Analyzer(impl = EnglishSnowballAnalyzer.class)
@org.hibernate.annotations.Entity(dynamicInsert=true, dynamicUpdate=true)
@Cache(usage = CacheConcurrentyStratedy.READ_WRITE)
public class GetekeeperActivity implements java.io.Serializable) {

@DocumentId
@Id
@GeneratedValue
@Column(name = "id", nullable = false)
private long id;

@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
@JoinCoumn(name = "asset_id", nullable=false)
@ForeignKey(name="fk_asset_id_gk")
private Asset asset;

}




data source #2 - no indexed entities

Code:
<jee:jndi-lookup id="bserver.dataSource" jndi-name="jdbc/bJdbcPool" />

    <bean id="bserver.sessionFactory"  class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="bserver.dataSource" />
        <property name="configLocation" value="classpath:com/chaos/bmam/hibernate.cfg.xml" />

        <property name="annotatedClasses">
            <list>
                <value>com.chaos.core.model.BaseConfig</value>
                <value>com.chaos.core.model.ConfigParam</value>
                <value>com.chaos.core.model.MediaManagerConfig</value>
                <value>com.chaos.core.model.ServerConfig</value>
             </list>
        </property>

        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${bserverapp.hibernate.dialect}</prop>
               
                <!--
                    enable 2nd level cache - ehcache
                 -->

                <prop key="hibernate.cache.use_second_level_cache">true</prop>
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
                <prop key="hibernate.cache.provider_configuration_file_resource_path">com/chaos/bmam/ehcache-dao.xml</prop>

                <prop key="hibernate.cache.use_query_cache">true</prop>
                <prop key="hibernate.generate_statistics">true</prop>
                <prop key="hibernate.cache.use_structured_entries">true</prop>
            </props>
        </property>

    </bean>

    <!--
        Transaction Manager
    -->
    <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
        <property name="allowCustomIsolationLevels" value="true" />
    </bean>


Name and version of the database you are using:

mysql 5.0.45

Glassfish Sun Java System Application Server 9.1_02 (build b04-fcs)


Manual indexing works just fine without annotated classes. However when I persist something the lucene index is not being updated. I verify this with Luke. Also our web app does a manual index upon start and that works only if I blow away the lucene index directory. ie if I add 10 entities to the db, the lucene index is never updated until I stop the webapp, blow away the index and let it start back up which triggers our app to do manual indexing.

I have debugged the hibernate-search code and I can see the FullTextIndexEventListener code being called. It then calls TransactionalWorker.performWork(work, context) which determines that a transaction is in progress and calls txSync.add( work ); I have also traced this down through BatchedQueueingProcessor .add( work, queue) and it's calling workQueue.add( work ) just fine.

We are using XA transactions because we are talking to two databases as well as a jms queue. There are no exceptions in the logs when I persist an entity and it's adding to the work queue.

I also turned on trace using
Code:
log4j.logger.org.hibernate.search=TRACE
but I only see this small amount during startup:

Code:
2009-02-16 16:06:44,594 [pool-1-thread-4] TRACE (org.hibernate.search.backend.configuration.MaskedProperty#getProperty:79) - found a match for key: [hibernate.search.default.directory_provider] value: org.hibernate.search.store.FSDirectoryProvider
2009-02-16 16:06:44,596 [pool-1-thread-4] TRACE (org.hibernate.search.backend.configuration.MaskedProperty#getProperty:79) - found a match for key: [default.directory_provider] value: org.hibernate.search.store.FSDirectoryProvider
2009-02-16 16:06:44,609 [pool-1-thread-4] TRACE (org.hibernate.search.backend.configuration.MaskedProperty#getProperty:79) - found a match for key: [hibernate.search.default.indexBase] value: /bmam/lucene
2009-02-16 16:06:44,611 [pool-1-thread-4] TRACE (org.hibernate.search.backend.configuration.MaskedProperty#getProperty:79) - found a match for key: [default.indexBase] value: /bmam/lucene


edit I do however see trace when I blow away the index and let it recreate on start via manual indexing:

Code:
009-02-16 16:30:36,281 [pool-5-thread-1] TRACE (org.hibernate.search.backend.impl.lucene.works.AddWorkDelegate#performWork:53) - add to Lucene index: class com.chaos.core.model.Asset .....


Last edited by mrsnospam on Wed Feb 18, 2009 8:28 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2009 3:33 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
for spring integration you may want to read http://www.hibernate.org/441.html

From your application trace the problem looks like the Search isn't receiving the commit event, so I would try adding this:

Code:
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2009 4:18 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

maybe this thread is helpful as well - http://forum.hibernate.org/viewtopic.php?t=988828

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2009 3:20 pm 
Beginner
Beginner

Joined: Tue May 03, 2005 11:45 pm
Posts: 43
Page two of that thread appears to have fixed our indeding:

http://forum.hibernate.org/viewtopic.ph ... c&start=15

We just added this to our session factory:

Code:
<property name="jtaTransactionManager">
          <bean factory-bean="txManager" factory-method="getTransactionManager"/>
        </property>


I don't fully understand why this works and we're still grappling with some lazy init exceptions.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2009 3:37 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Good to hear that it works now. If you want to understand the why this is needed and how it works I recommend you attach the spring source code to your IDE and step through the code of underlying classes.

Let us know if there are more problems. Maybe you should post yout full spring configuration here. Or even better update the wiki page. The configuration there might be a little outdated.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2009 3:40 pm 
Beginner
Beginner

Joined: Tue May 03, 2005 11:45 pm
Posts: 43
I have posted something on the spring forums, when we work it out I'll go update the wiki.

http://forum.springframework.org/showthread.php?t=67651


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 06, 2009 2:18 pm 
Beginner
Beginner

Joined: Tue May 03, 2005 11:45 pm
Posts: 43
We also fixed our lazy init problems by turning on openSessionInView() via spring.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.