Hibernate Search/JPA - Can't create initial index; program hangs AFTER apparent index creation -


i have been trying use hibernate search jpa 2 days , have compiling cleanly , running without obvious errors. however, when try create initial index, program runs , prints out each object indexing (using manual indexing), prints "indexing completed" message. no no errors thrown, main method never exits. running in eclipse kepler in maven project jre1.7 can kill processing hitting red stop button. if that, file search index files, don't find any. if run search program, java.lang.illegalargumentexception: none of specified entity types or of subclasses indexed.

i appreaciate suggestions on how work. i've tried going version 4.2 of hibernate search , same thing.

the domain class car. here indexer output:

    indexing: make infinity model g35     indexing: make honda model civic     indexing: make audi model a4     indexing: make toyota model carolla     indexing completed 

if run in debugger debug window shows following active threads when program should have exited:

com.xyzco.search.indexer @ localhost:52231      daemon thread [mysql statement cancellation timer] (running)         thread [hibernate search: index updates queue processor index com.xyzco.search.car-1] (running)      thread [hibernate search: indexwriter worker executor com.xyzco.search.car-1] (running)      thread [destroyjavavm] (running) 

here indexer code:

import javax.persistence.entitymanager; import javax.persistence.entitymanagerfactory; import javax.persistence.persistence; import org.hibernate.search.jpa.fulltextentitymanager;  public class indexer {     public static void main(string[] args) {         try {             entitymanagerfactory entitymanagerfactory = persistence                     .createentitymanagerfactory("dbschema");             entitymanager em = entitymanagerfactory.createentitymanager();              fulltextentitymanager ftem = org.hibernate.search.jpa.search                     .getfulltextentitymanager(em);             ftem.gettransaction().begin();              @suppresswarnings("unchecked")             list<car> cars = em.createquery(                     "select c car c").getresultlist();             (car car : cars) {                 ftem.index(car); // manually index item instance                 system.out.println("indexing: make " + car.getmake() + " model " + car.getmodel());             }             ftem.gettransaction().commit(); // index written @ commit time             em.close();             system.out.println("indexing completed");         } catch (exception e) {             e.printstacktrace();         }     } } 

here car class code:

import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.id;  import org.hibernate.search.annotations.analyze; import org.hibernate.search.annotations.documentid; import org.hibernate.search.annotations.field; import org.hibernate.search.annotations.index; import org.hibernate.search.annotations.indexed; import org.hibernate.search.annotations.store;  @entity @indexed  //mark indexing public class car {      @id @generatedvalue     @documentid  //mark id property shared core , search     private integer id;      @field   //mark indexing using tokenization     private string make;      @field       private string model;      @field(index=index.yes, analyze=analyze.no, store=store.no)     private string description;      @field(index=index.yes, analyze=analyze.no, store=store.no)     private string options;      // getters , setters left out...  } 

here persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://java.sun.com/xml/ns/persistence      http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"     version="1.0">     <persistence-unit name="dbschema"> <!--  transaction-type="resource_local"> -->         <provider>org.hibernate.ejb.hibernatepersistence</provider>         <class>com.xyzco.search.car</class>          <properties>             <property name="hibernate.dialect" value="org.hibernate.dialect.mysql5innodbdialect"/>             <property name="hibernate.hbm2ddl.auto" value="update"/>              <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.driver"/>             <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/referencedata"/>             <property name="javax.persistence.jdbc.user" value="root"/>             <property name="javax.persistence.jdbc.password" value=""/>              <property name="hibernate.search.default.directory_provider"                 value="filesystem" />             <property name="hibernate.search.default.indexbase" value="/usr/lucene/indexes" />         </properties>     </persistence-unit> </persistence> 

here part of pom (uses profile suggested on hibernate site)

... <profile>     <id>jboss-public-repository</id> ...          <dependencies>     <dependency>         <groupid>org.slf4j</groupid>         <artifactid>slf4j-api</artifactid>         <version>${sl4j.version}</version>     </dependency>     <dependency>         <groupid>log4j</groupid>         <artifactid>log4j</artifactid>         <version>1.2.14</version>     </dependency>     <dependency>         <groupid>mysql</groupid>         <artifactid>mysql-connector-java</artifactid>         <version>5.1.6</version>     </dependency>     <dependency>         <groupid>javax.inject</groupid>         <artifactid>javax.inject</artifactid>         <version>1</version>     </dependency>      <!-- hibernate search -->     <dependency>         <groupid>org.hibernate</groupid>         <artifactid>hibernate-entitymanager</artifactid>         <version>4.2.2.final</version>     </dependency>     <dependency>         <groupid>org.hibernate</groupid>         <artifactid>hibernate-search</artifactid>         <version>4.3.0.final</version>     </dependency>     <dependency>         <groupid>org.apache.lucene</groupid>         <artifactid>lucene-core</artifactid>         <version>3.6.2</version>     </dependency> </dependencies> 

in indexer class, after closing entity manager (em.close) must close entity manager factory (entitymanagerfactory.close();) or else program hang. explained in faq list , common problem, surprising how many examples show fragments of code , don't include line.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -