java - Hibernate Search and Play Framework, how to build the Index -
i'm trying integrate hibernate search play framework application running. have problem building index, or thats think problem.
i have user:
@indexed @entity public class user extends model { @field public string firstname; @field public string lastname; @field public string email; }
this persistence.xml:
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
<persistence-unit name="default" transaction-type="resource_local"> <provider>org.hibernate.jpa.hibernatepersistenceprovider</provider> <non-jta-data-source>defaultds</non-jta-data-source> <class>models.user</class> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.mysqldialect"/> <property name="hibernate.hbm2ddl.auto" value="update"/> <property name="hibernate.search.default.directory_provider" value="filesystem"/> <property name="hibernate.search.default.indexbase" value="/users/<user>/lucene/indexes"/> </properties> </persistence-unit>
so seams logical me building of index (for data in database) should happen in onstart
of globaladmin object. use jpa.withtransaction
call indexer:
jpa.withtransaction(new f.callback0() { @override public void invoke() throws throwable { fulltextentitymanager fulltextentitymanager = org.hibernate.search.jpa.search.getfulltextentitymanager(jpa.em()); try { fulltextentitymanager.createindexer().startandwait(); } catch (exception e) { logger.error(e.getmessage()); } } });
the problem get:
[error] o.h.e.j.s.sqlexceptionhelper - timed out waiting free available connection. [error] o.h.s.e.i.logerrorhandler - hsearch000058: hsearch000211: exception occurred while massindexer fetching primary identifiers list org.hibernate.exception.jdbcconnectionexception: not open connection @ org.hibernate.exception.internal.sqlstateconversiondelegate.convert(sqlstateconversiondelegate.java:132) ~[hibernate-core-4.3.9.final.jar:4.3.9.final] @ org.hibernate.exception.internal.standardsqlexceptionconverter.convert(standardsqlexceptionconverter.java:49) ~[hibernate-core-4.3.9.final.jar:4.3.9.final] @ org.hibernate.engine.jdbc.spi.sqlexceptionhelper.convert(sqlexceptionhelper.java:126) ~[hibernate-core-4.3.9.final.jar:4.3.9.final] @ org.hibernate.engine.jdbc.spi.sqlexceptionhelper.convert(sqlexceptionhelper.java:112) ~[hibernate-core-4.3.9.final.jar:4.3.9.final] @ org.hibernate.engine.jdbc.internal.logicalconnectionimpl.obtainconnection(logicalconnectionimpl.java:235) ~[hibernate-core-4.3.9.final.jar:4.3.9.final] caused by: java.sql.sqlexception: timed out waiting free available connection. @ com.jolbox.bonecp.defaultconnectionstrategy.getconnectioninternal(defaultconnectionstrategy.java:88) ~[bonecp-0.8.0.release.jar:na] @ com.jolbox.bonecp.abstractconnectionstrategy.getconnection(abstractconnectionstrategy.java:90) ~[bonecp-0.8.0.release.jar:na] @ com.jolbox.bonecp.bonecp.getconnection(bonecp.java:553) ~[bonecp-0.8.0.release.jar:na] @ com.jolbox.bonecp.bonecpdatasource.getconnection(bonecpdatasource.java:131) ~[bonecp-0.8.0.release.jar:na] @ org.hibernate.engine.jdbc.connections.internal.datasourceconnectionproviderimpl.getconnection(datasourceconnectionproviderimpl.java:139) ~[hibernate-core-4.3.9.final.jar:4.3.9.final]
thanks help.
edit:
my search method in controller:
as in comments suggested, uncommented indexer in 'onstart'.
@transactional public static result list(int page, string filter, string sortby, string order) { entitymanager em = jpa.em(); fulltextentitymanager fulltextentitymanager = org.hibernate.search.jpa.search.getfulltextentitymanager(em); querybuilder qb = fulltextentitymanager.getsearchfactory().buildquerybuilder().forentity(user.class).get(); query lucenequery = qb .keyword() .onfields("firstname", "lastname", "email") .matching(filter) .createquery(); // wrap lucene query in javax.persistence.query javax.persistence.query jpaquery = fulltextentitymanager.createfulltextquery(lucenequery, user.class); // execute search list result = jpaquery.getresultlist(); page<user> userpage = new page<>(result,1,1,1); //page<user> userpage = user.page(page, 30, sortby, order, filter); return ok(views.html.admin.customers.list.render(userpage, filter, sortby, order)); }
this method first attempt use hibernate search. not return anything.
your problem not seem lie search directly. looking @ stacktrace, seems running out of jdbc connections. don't know bonecp myself, seems jdbc pool library. configuration it? have tried increase connection pool size?
Comments
Post a Comment