-->
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.  [ 10 posts ] 
Author Message
 Post subject: Spring with Hibernate Search doesn't perform indexing
PostPosted: Thu Jun 24, 2010 4:30 am 
Beginner
Beginner

Joined: Thu Jun 24, 2010 2:30 am
Posts: 23
I have working application using Spring and Hibernate for data access. Lately, I needed to add Hibernate Search. I've wrote service interface, class and bean for search. It always returns empty result. The empty result is normal, since there is not index yet, so I wrote simple utility, that should build initial index. There are just three indexed tables, with less then 20 records in it, but the utility starts to work and doesn't finish, even if it works 20 hours.
I suspect, that there is deadlock because of misconfiguration. I use Spring 3.0.1, hibernate 3.5 and hibernate search 3.2.0.
Can somebody help me with this issue?
Code:
public static void main(String[] args) {
   ApplicationContext ctx =
      new ClassPathXmlApplicationContext( "applicationContext.xml" );
      SessionFactory sessions =
         (SessionFactory)ctx.getBean( "sessionFactory" );
      Session session = sessions.openSession();
      FullTextSession fullTextSession = Search.getFullTextSession( session );
      boolean result = false;
      System.out.println( "Starting to build Lucene index for Hibernate Search" );
      try {
         fullTextSession.createIndexer( Company.class
            ).batchSizeToLoadObjects( 20
               ).threadsForSubsequentFetching( 8
                  ).threadsToLoadObjects( 4
                        ).cacheMode( CacheMode.NORMAL
                           ).startAndWait();
      } catch( Exception e) {         
         result = false;
      }
      System.out.println(
            result ? "Success" : "Error" +
            " building Lucene index for Hibernate Search."
            );
      //session.close();
      //fullTextSession.close();
      fullTextSession.getSessionFactory().close();      
   }   


Java code:
Code:
@Entity
@Table(name = "groups", catalog = "onboard")
@Indexed
public class Groups extends HashCodeValidator implements BaseEntity {

   /** Serial Version UID. */
   private static final long serialVersionUID = -559024055L;
   
   /** Field mapping. */
   private Company company;   
   private String name;
   private Set<Role> roles = new HashSet<Role>();

   public Groups() {}

   public Groups(Long id) { setId( id ); }
   
   public Groups(Long id, String name) { setId( id ); this.name = name; }   

   @Transient
   public Class<?> getClassType() { return Groups.class; }

        @Id @GeneratedValue(strategy = GenerationType.AUTO)
   @Column( name = "id", nullable = false  )
   public Long getId() { return super.getId(); }   
 
   public void setId(final Long id) { super.setId(id); }

   @Column( nullable = false, length = 50  )
   @Field(index=Index.TOKENIZED, store=Store.NO)
   public String getName() { return this.name; }

   public void setName(final String name) {   this.name = name; }

   @ManyToOne( cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.EAGER)
   @org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
   @JoinColumn(name = "company_id", nullable = true  )
   @IndexedEmbedded
   public Company getCompany() { return this.company;    }

   public void setCompany(final Company company) { this.company = company;   }
   
   @ManyToMany(fetch = FetchType.EAGER, cascade = { CascadeType.ALL })
   @JoinTable(name = "group_role", joinColumns = @JoinColumn(name = "group_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
   @IndexedEmbedded
   public Set<Role> getRoles() { return this.roles; }
   
   public void setRoles(final Set<Role> roles) {
      this.roles = roles;
   }   
}

@Entity
@Table(name = "role", catalog = "onboard")
@Indexed
public class Role
      extends HashCodeValidator implements BaseEntity, Comparable<Role> {

   /** Serial Version UID. */
   private static final long serialVersionUID = -559024050L;

   /** Field mapping. */   
   private String name;
   private Set<View> views = new HashSet<View>();
   private Set<ObjectPermission> objectPermissions;
   private Set<ObjectEntryPermission> objectEntryPermissions;

   public Role() {}

   public Role(Long id) { setId(id); }

   @Transient
   public Class<?> getClassType() { return Role.class; }

   @Id   @GeneratedValue(strategy = GenerationType.AUTO)
   @Column(name = "id", nullable = false)
   public Long getId() { return super.getId(); }

   public void setId(final Long id) { super.setId(id); }

   @Column(length = 45)
   @Field(index=Index.TOKENIZED, store=Store.NO)
   public String getName() { return this.name; }

   public void setName(final String name) { this.name = name;   }

   @ManyToMany(fetch = FetchType.EAGER, cascade = { CascadeType.ALL })
   @JoinTable(name = "view_role", joinColumns = @JoinColumn(name = "role_id"), inverseJoinColumns = @JoinColumn(name = "view_id"))
   public Set<View> getViews() { return views; };

   public void setViews(Set<View> views) { this.views = views; }

   @Override
   public int compareTo(Role other) {   return name.compareTo(other.getName()); }
   
        ...
}

@Entity
@Table(name = "company", catalog = "onboard")
//@Cache(usage =  CacheConcurrencyStrategy.READ_WRITE)
@Indexed
public class Company extends HashCodeValidator implements BaseEntity, AuditLog {

   /** Serial Version UID. */
   private static final long serialVersionUID   = -559024059L;

   /** Field mapping. */
   private String      name;
   private String      displayedName;
   private Set<User>   users            = new HashSet<User>();
   private Set<Groups>   groupss            = new HashSet<Groups>();
   private CompanyType   type;
   private PrefixTimezone   timeZone;

   public Company() {}

   public Company(Long id) { setId( id ); }

   @Transient
   public Class<?> getClassType() { return Company.class; }

   @Id @GeneratedValue(strategy = GenerationType.AUTO)
   @Column(name = "id", nullable = false)
   public Long getId() { return super.getId(); }

   public void setId(final Long id) { super.setId(id); }

   @Column(length = 45)
   @Field(index=Index.TOKENIZED, store=Store.NO)
   public String getName() { return this.name; }

   public void setName(String name) { this.name = name; }

   @ManyToOne(fetch = FetchType.EAGER)
   @JoinColumn(name = "type_id")
   public CompanyType getType() { return type; };

   public void setType(CompanyType companyType) { this.type = companyType; };

   @ManyToOne(fetch = FetchType.EAGER)
   @JoinColumn(name = "time_zone_id")
   public PrefixTimezone getTimeZone() { return timeZone; }

   public void setTimeZone(PrefixTimezone timeZone) {   this.timeZone = timeZone; }

   /**
    * Return the value associated with the column: user.
    * @return A Set&lt;User&gt; object (this.user)
    */
   @OneToMany(fetch = FetchType.EAGER, cascade = { CascadeType.ALL }, mappedBy = "company")
   @org.hibernate.annotations.Cascade( { org.hibernate.annotations.CascadeType.SAVE_UPDATE })
   @Column(nullable = false)
   public Set<User> getUsers() { return this.users; }

   public void addUser(User user) {
      user.setCompany(this);
      this.users.add(user);
   }

   public void setUsers(final Set<User> user) { this.users = user; }

   public void setDisplayedName(String displayedName) {
      this.displayedName = displayedName;
   }

   @Column(name = "displayed_name")
   @Field(index=Index.TOKENIZED, store=Store.NO)
   public String getDisplayedName() {
      return displayedName;
   }

   @OneToMany(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE }, mappedBy = "company")
   @org.hibernate.annotations.Cascade( { org.hibernate.annotations.CascadeType.SAVE_UPDATE })
   @Column(nullable = false)
   public Set<Groups> getGroupss() { return this.groupss; }

   public void addGroups(Groups groups) {
      groups.setCompany(this);
      this.groupss.add(groups);
   }

   public void setGroupss(final Set<Groups> groups) {
      this.groupss = groups;
   }
}


applicationContext.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"      
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:tx="http://www.springframework.org/schema/tx"             
       xsi:schemaLocation="
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

   <!--
      You may need to change jdbc.properties properties to adjust parameters
      to appropriate values for your application.
   -->
    <bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="classpath:/jdbc.properties" />
    </bean> 
   
    <bean id="dataSource"
        class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/onboard?autoReconnect=true" />
        <property name="username" value="root" />
        <property name="password" value="root" />
    </bean>   
   <tx:annotation-driven transaction-manager="transactionManager" />
   
   <!-- Hibernate SessionFactory -->
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">       
        <property name="dataSource" ref="dataSource" />         
        <property name="schemaUpdate" value="false"/>               
   <property name="namingStrategy" ref="namingStrategy"/>      
        <property name="hibernateProperties">
           <props>
                <prop key="hbm2ddl.auto">validate</prop>
                <prop key="show_sql">false</prop>
                <prop key="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>
               <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
               <prop key="hibernate.max_fetch_depth">1</prop>
      <prop key="hibernate.default_batch_fetch_size">4</prop>
      <prop key="hibernate.jdbc.fetch_size">5</prop>
      <prop key="hibernate.jdbc.batch_size">5</prop>
      <prop key="hibernate.cache.use_query_cache">true</prop>
      <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
      <prop key="hibernate.cache.use_second_level_cache">true</prop>
      <prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>
      <prop key="hibernate.search.default.indexBase">C:\\Lucene</prop>
      <prop key="hibernate.search.default.exclusive_index_use">true</prop>             
           </props>
        </property> 
        <property name="configurationClass">
         <value>org.hibernate.cfg.AnnotationConfiguration</value>
      </property>
      <property name="configLocation">
         <value>classpath:hibernate.cfg.xml</value>
      </property>
    </bean>
   
   <bean id="namingStrategy" class="org.hibernate.cfg.ImprovedNamingStrategy"/>

    <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

    ....   
</beans>


mappings(hibernate.cfg.xml):
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
   <session-factory>
           <mapping class="com.sintecmedia.model.AuditTrail" />   
      <mapping class="com.sintecmedia.model.PrefixTimezone" />
      <mapping class="com.sintecmedia.model.Company" />
      <mapping class="com.sintecmedia.model.CompanyType" />
      <mapping class="com.sintecmedia.model.Role" />
      <mapping class="com.sintecmedia.model.User" />
      <mapping class="com.sintecmedia.model.Groups" />
      <mapping class="com.sintecmedia.model.View" />
      <mapping class="com.sintecmedia.model.Object" />
      <mapping class="com.sintecmedia.model.ObjectEntry" />
      <mapping class="com.sintecmedia.model.ObjectPermission" />
      <mapping class="com.sintecmedia.model.ObjectEntryPermission" />
      
      <listener type="pre-delete"
         class="com.sintecmedia.daoimpl.HibernateAuditLogListener" />
      <listener type="pre-update"
         class="com.sintecmedia.daoimpl.HibernateAuditLogListener" />
      <listener type="pre-insert"
         class="com.sintecmedia.daoimpl.HibernateAuditLogListener" />
      <listener type="pre-load"
         class="com.sintecmedia.daoimpl.HibernateAuditLogListener" />
      
   </session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject: Re: Spring with Hibernate Search doesn't perform indexing
PostPosted: Thu Jun 24, 2010 5:17 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Is there anything getting indexed? Have you looked at the index with Luke to see whether Documents are getting added? And what about the log file? Have you enabled debug/trace level logging for your application. Looking at the log file might give an indication about what is going on.

--Hardy


Top
 Profile  
 
 Post subject: Re: Spring with Hibernate Search doesn't perform indexing
PostPosted: Sun Jun 27, 2010 7:05 am 
Beginner
Beginner

Joined: Thu Jun 24, 2010 2:30 am
Posts: 23
My debug level is "debug" and I don't see message. I've not checked index with Luke I'll do it soon. Another piece of puzzle: I've created test project that builds index of same DB, but with pure Hibernate without Spring and its works. I'll ask in Spring forum about it.


Top
 Profile  
 
 Post subject: Re: Spring with Hibernate Search doesn't perform indexing
PostPosted: Mon Jun 28, 2010 3:40 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
I don't see a @DocumentId defined. Is this on the base entity class?


Top
 Profile  
 
 Post subject: Re: Spring with Hibernate Search doesn't perform indexing
PostPosted: Mon Jun 28, 2010 3:53 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
In this case Hibernate Annotations and @Id is used. @DocumentId is optional.
Regarding the logging. If the org.hibernate.search logging category is set to debug something should come out the log file. Where and how do you configure logging? Do you use log4j.properties or log4j.xml? With a properties file enabling debug logging looks like this:

Code:
log4j.logger.org.hibernate.search=debug


--Hardy


Top
 Profile  
 
 Post subject: Re: Spring with Hibernate Search doesn't perform indexing
PostPosted: Tue Jun 29, 2010 1:26 am 
Beginner
Beginner

Joined: Thu Jun 24, 2010 2:30 am
Posts: 23
The issue is solved, but the solution create another one. I wrote utilty class that uses hibernate only without Spring, to prevent possible misconfiguration. It reports that column types of some columns are int, while bigint expected. The utility start to works when I changes hbm2ddl property to create, run it one time, and changed it back to 'validate'. I wrote in start of the thread that indexing without Spring is works. At Thursday, I've removed 'hbm2ddl' property from Spring configuration and now there is no endless loop as was. However indexing using Spring and Hibernate still doesn't works. It fails with 'Terminating batch work! Index might end up in inconsistent state.' error, that doesn't hekps to understand the problem and to fix it. Hardy, can you explain why it happens.
Here is the log using 'log4j.logger.org.hibernate.search=debug' in log4j.xml.
Quote:
2010-06-29 08:11:22,245 INFO ( Version.java:40) - Hibernate Search 3.2.0.Final
2010-06-29 08:11:22,245 INFO ( Version.java:40) - Hibernate Search 3.2.0.Final
2010-06-29 08:11:22,261 DEBUG ( InitContext.java:133) - Using default similarity implementation: org.apache.lucene.search.DefaultSimilarity
2010-06-29 08:11:22,261 DEBUG ( InitContext.java:133) - Using default similarity implementation: org.apache.lucene.search.DefaultSimilarity
2010-06-29 08:11:22,324 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:22,324 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:22,324 DEBUG (DocumentBuilderIndexedEntity.java:171) - Field selection in projections is set to true for entity com.sintecmedia.model.AuditTrail.
2010-06-29 08:11:22,324 DEBUG (DocumentBuilderIndexedEntity.java:171) - Field selection in projections is set to true for entity com.sintecmedia.model.AuditTrail.
2010-06-29 08:11:22,339 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:22,339 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:22,339 DEBUG (DocumentBuilderIndexedEntity.java:171) - Field selection in projections is set to true for entity com.sintecmedia.model.Company.
2010-06-29 08:11:22,339 DEBUG (DocumentBuilderIndexedEntity.java:171) - Field selection in projections is set to true for entity com.sintecmedia.model.Company.
2010-06-29 08:11:22,355 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:22,355 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:22,355 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:22,355 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:22,355 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:22,355 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:22,355 DEBUG (DocumentBuilderIndexedEntity.java:171) - Field selection in projections is set to true for entity com.sintecmedia.model.Groups.
2010-06-29 08:11:22,355 DEBUG (DocumentBuilderIndexedEntity.java:171) - Field selection in projections is set to true for entity com.sintecmedia.model.Groups.
2010-06-29 08:11:22,433 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:22,433 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:22,433 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:22,433 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:22,433 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:22,433 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:22,433 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:22,433 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:22,433 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:22,433 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:22,433 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:22,433 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:22,433 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:22,433 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:23,120 DEBUG ( InitContext.java:133) - Using default similarity implementation: org.apache.lucene.search.DefaultSimilarity
2010-06-29 08:11:23,120 DEBUG ( InitContext.java:133) - Using default similarity implementation: org.apache.lucene.search.DefaultSimilarity
2010-06-29 08:11:23,136 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:23,136 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:23,136 DEBUG (DocumentBuilderIndexedEntity.java:171) - Field selection in projections is set to true for entity com.sintecmedia.model.AuditTrail.
2010-06-29 08:11:23,136 DEBUG (DocumentBuilderIndexedEntity.java:171) - Field selection in projections is set to true for entity com.sintecmedia.model.AuditTrail.
2010-06-29 08:11:23,152 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:23,152 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:23,152 DEBUG (DocumentBuilderIndexedEntity.java:171) - Field selection in projections is set to true for entity com.sintecmedia.model.Company.
2010-06-29 08:11:23,152 DEBUG (DocumentBuilderIndexedEntity.java:171) - Field selection in projections is set to true for entity com.sintecmedia.model.Company.
2010-06-29 08:11:23,167 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:23,167 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:23,167 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:23,167 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:23,167 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:23,167 DEBUG (DocumentBuilderIndexedEntity.java:263) - Found JPA id and using it as document id
2010-06-29 08:11:23,167 DEBUG (DocumentBuilderIndexedEntity.java:171) - Field selection in projections is set to true for entity com.sintecmedia.model.Groups.
2010-06-29 08:11:23,167 DEBUG (DocumentBuilderIndexedEntity.java:171) - Field selection in projections is set to true for entity com.sintecmedia.model.Groups.
2010-06-29 08:11:23,183 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:23,183 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:23,183 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:23,183 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:23,183 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:23,183 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:23,183 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:23,183 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:23,183 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:23,183 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:23,183 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:23,183 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:23,183 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
2010-06-29 08:11:23,183 DEBUG (FullTextIndexEventListener.java:136) - Hibernate Search event listeners activated
Starting to build Lucene index for Hibernate Search
2010-06-29 08:11:23,620 DEBUG ( MassIndexerImpl.java:113) - Targets for indexing job: [class com.sintecmedia.model.Company]
2010-06-29 08:11:23,620 DEBUG ( MassIndexerImpl.java:113) - Targets for indexing job: [class com.sintecmedia.model.Company]
2010-06-29 08:11:24,667 ERROR (DirectoryProviderWorkspace.java:112) - Terminating batch work! Index might end up in inconsistent state.
2010-06-29 08:11:24,667 ERROR (DirectoryProviderWorkspace.java:112) - Terminating batch work! Index might end up in inconsistent state.
2010-06-29 08:11:24,667 ERROR (DirectoryProviderWorkspace.java:112) - Terminating batch work! Index might end up in inconsistent state.
2010-06-29 08:11:24,667 ERROR (DirectoryProviderWorkspace.java:112) - Terminating batch work! Index might end up in inconsistent state.
2010-06-29 08:11:24,667 ERROR (DirectoryProviderWorkspace.java:112) - Terminating batch work! Index might end up in inconsistent state.
2010-06-29 08:11:24,667 ERROR (DirectoryProviderWorkspace.java:112) - Terminating batch work! Index might end up in inconsistent state.
Error building Lucene index for Hibernate Search.


Top
 Profile  
 
 Post subject: Re: Spring with Hibernate Search doesn't perform indexing
PostPosted: Tue Jun 29, 2010 4:49 am 
Hibernate Team
Hibernate Team

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

is this the log directly from your log file or why are there so many duplicates? That just doesn't seem right? Are there several indexing processes? This could cause locking problems.

Looking at your Spring configuration again I am also wondering why you use

Code:
      <property name="configLocation">
         <value>classpath:hibernate.cfg.xml</value>
      </property>


you have all configuration in Spring, why using hibernate.cfg.xml? You are also using Annotations so you don't have to explicitly configure the even listeners. You can find a slightly different, but in my opinion better configuration here.

--Hardy


Top
 Profile  
 
 Post subject: Re: Spring with Hibernate Search doesn't perform indexing
PostPosted: Tue Jun 29, 2010 5:42 am 
Beginner
Beginner

Joined: Thu Jun 24, 2010 2:30 am
Posts: 23
Thank you for fast reply, Hardy.
1. The source of log is 'Console View' of eclipse. Part of log duplicates is that my log4j configuration defines two loggers stdout(console) and hibernate(file). This causes log4j to print each message twice into console, in each class the other logger besides stdout defined for. Can you tell me whether it explains all duplicates?
2. The reason for using hibernate.cfg.xml is not rational. I just want to separate list of objects mapped from other configuration settings.
3. I don't define any search listeners in hibernate.cfg.xml. HibernateAuditLogListener you can see in hibernate.cfg.xml is interceptor for other part of project. It doesn't build index or do anything else related to Hibernate Search.
4. I've already seen the configuration you write abot, but can't take it as is, since I don't use entityManager, JPATransactionManager or JMX. I can't change it just for search, because I add search to existing and working application.
5. I see that in this configuration SingletoneEhCacheProvider used and I use org.hibernate.cache.EhCacheProvider. Is it changes something?
6. I don't know why, but in configuration that I sent to you search don't see hibernate.search.default.indexBase property, if I put it in applicationContext.xml. Only if I copy it to hibernate.cfg.xml it make sence and search doesn't build new index in root directory. Do you know the reason of it?


Top
 Profile  
 
 Post subject: Re: Spring with Hibernate Search doesn't perform indexing
PostPosted: Thu Jul 01, 2010 3:59 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Quote:
1. The source of log is 'Console View' of eclipse. Part of log duplicates is that my log4j configuration defines two loggers stdout(console) and hibernate(file). This causes log4j to print each message twice into console, in each class the other logger besides stdout defined for. Can you tell me whether it explains all duplicates?

Probably

Quote:
2. The reason for using hibernate.cfg.xml is not rational. I just want to separate list of objects mapped from other configuration settings.
6. I don't know why, but in configuration that I sent to you search don't see hibernate.search.default.indexBase property, if I put it in applicationContext.xml. Only if I copy it to hibernate.cfg.xml it make sence and search doesn't build new index in root directory. Do you know the reason of it?

[/quote]
Not sure, but there could be a problem regarding which configuration form "wins". I am not sure at the moment how these different configuration options gets combines. Personally I would stick to one configuration form. Have you tried to use only hibernate.cfg.xml or applicationContext.xml? You are saying that your utility works when you are not using Spring. That seems to indicate a configuration problem.

Quote:
5. I see that in this configuration SingletoneEhCacheProvider used and I use org.hibernate.cache.EhCacheProvider. Is it changes something?

I don't think so.


Top
 Profile  
 
 Post subject: Re: Spring with Hibernate Search doesn't perform indexing
PostPosted: Sun Jul 04, 2010 2:51 am 
Beginner
Beginner

Joined: Thu Jun 24, 2010 2:30 am
Posts: 23
Thank you for clarifications, Hardy. I've wrote in the start of the topic that I suspect misconfiguration, the propblem that I don't know where it is. I've already tried to remove hibernate.cfg.xml and to use only applicationContext.xml. It doesn't help. by the way here is another evidence of misconfiguration; if I set hibernate.search.default.indexBase property in applicationContext, Hibernate Search doesn't find it and builds new index in project root. If I set it in hibernate.cfg.xml Hibernate Search use location specified. For now I escape the issue using utility class working with hibernate only to build initial index and other class that use Spring for search operation. However I don't want this to be permanent solution, since I nee to maintain two files that configure same properties and it is error-prone. I'll be very glad, if you point how to change the configuratiomn, to solve the problem.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 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.