Hello,
I am trying to reproduce the first example from Hibernate Search reference, but I stumbled on the org.hibernate.HibernateException: Unable to initialize: index.books.Book
My example looks like the following:
Code:
AnnotationConfiguration cfg = (AnnotationConfiguration) new AnnotationConfiguration()
.configure();
sessionFactory = cfg.addPackage("index.books").addAnnotatedClass(
Book.class).buildSessionFactory(); // fails here
session = sessionFactory.openSession();
FullTextSession fulltextSession = Search
.createFullTextSession(session);
Transaction tx = fulltextSession.beginTransaction();
List<Book> result = session.createCriteria("from Book as book")
.list();
for (Book book : result) {
fulltextSession.index(book);
}
tx.commit();
The Book entity is copied and pasted from the tutotial. The debugging does not helped me to realize the problem.
What do I miss here?
Thank you in advance.
Larysa
Exception trace:
Code:
Exception in thread "main" org.hibernate.HibernateException: Unable to initialize: index.books.Book
at org.hibernate.search.store.DirectoryProviderFactory.createDirectoryProvider(DirectoryProviderFactory.java:147)
at org.hibernate.search.store.DirectoryProviderFactory.createDirectoryProviders(DirectoryProviderFactory.java:75)
at org.hibernate.search.impl.SearchFactoryImpl.initDocumentBuilders(SearchFactoryImpl.java:260)
at org.hibernate.search.impl.SearchFactoryImpl.<init>(SearchFactoryImpl.java:94)
at org.hibernate.search.impl.SearchFactoryImpl.getSearchFactory(SearchFactoryImpl.java:172)
at org.hibernate.search.event.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:44)
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:356)
at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1304)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at index.books.TestHibSearch.main(TestHibSearch.java:24)
Caused by: org.hibernate.search.SearchException: Cannot write into index directory: /var/lucene/indexes
at org.hibernate.search.util.DirectoryProviderHelper.determineIndexDir(DirectoryProviderHelper.java:86)
at org.hibernate.search.store.FSDirectoryProvider.initialize(FSDirectoryProvider.java:28)
at org.hibernate.search.store.DirectoryProviderFactory.createDirectoryProvider(DirectoryProviderFactory.java:144)
... 10 more