Hibernate搜索 - 请求的未知服务

时间:2014-01-09 19:23:48

标签: java hibernate jpa jboss hibernate-search

我正在尝试在JBoss EAP 6.1下部署的Java EE 6项目中使用Hibernate Search。但是,当我将对象保存到数据库时,我没有看到创建索引。使用必要的Hibernate Search注释正确注释数据模型。我试图手动重新创建搜索索引,但是当我这样做时,我得到以下异常:

Caused by: org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.search.spi.MassIndexerFactory]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:126) [hibernate-core-4.2.0.Final-redhat-1.jar:4.2.0.Final-redhat-1]
    at org.hibernate.search.impl.FullTextSessionImpl.requestService(FullTextSessionImpl.java:213) [hibernate-search-orm-4.3.0.Final.jar:4.3.0.Final]
    at org.hibernate.search.impl.FullTextSessionImpl.createIndexer(FullTextSessionImpl.java:208) [hibernate-search-orm-4.3.0.Final.jar:4.3.0.Final]
    at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.createIndexer(FullTextEntityManagerImpl.java:292) [hibernate-search-orm-4.3.0.Final.jar:4.3.0.Final]
    at net.odyssi.projectx.web.actions.test.TestAction.reindexData(TestAction.java:564) [classes:]
    at net.odyssi.projectx.web.actions.test.TestAction$Proxy$_$$_WeldSubclass.reindexData(TestAction$Proxy$_$$_WeldSubclass.java) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_45]
    at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_45]
    at org.jboss.weld.interceptor.proxy.SimpleInterceptionChain.invokeNextInterceptor(SimpleInterceptionChain.java:85) [weld-core-1.1.13.Final-redhat-1.jar:1.1.13.Final-redhat-1]
    at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:112) [weld-core-1.1.13.Final-redhat-1.jar:1.1.13.Final-redhat-1]
    at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:88) [weld-core-1.1.13.Final-redhat-1.jar:1.1.13.Final-redhat-1]
    at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:55) [weld-core-1.1.13.Final-redhat-1.jar:1.1.13.Final-redhat-1]
    at net.odyssi.projectx.web.actions.test.TestAction$Proxy$_$$_WeldSubclass.reindexData(TestAction$Proxy$_$$_WeldSubclass.java) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_45]
    at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_45]
    at org.apache.el.parser.AstValue.invoke(AstValue.java:258) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
    at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) [weld-core-1.1.13.Final-redhat-1.jar:1.1.13.Final-redhat-1]
    at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-1.1.13.Final-redhat-1.jar:1.1.13.Final-redhat-1]
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.19-redhat-1.jar:2.1.19-redhat-1]
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87) [jboss-jsf-api_2.1_spec-2.1.19.1.Final-redhat-1.jar:2.1.19.1.Final-redhat-1]
    ... 32 more

我的persistence.xml文件如下所示:

<persistence-unit name="ProjectX" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>java:jboss/datasources/ProjectXDatasource</jta-data-source>

        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
            <property name="hibernate.hbm2ddl.auto" value="create-drop" />
            <property name="hibernate.show_sql" value="false" />
            <property name="hibernate.format_sql" value="true" />

            <property name="jboss.entity.manager.factory.jndi.name"
                value="java:/ProjectXEntityManagerFactory" />
            <property name="hibernate.generate_statistics" value="true" />
            <property name="hibernate.connection.release_mode" value="auto" />
            <property name="hibernate.transaction.flush_before_completion"
                value="true" />

            <property name="hibernate.max_fetch_depth" value="5" />

            <!-- Caching support -->
            <property name="hibernate.cache.use_second_level_cache"
                value="true" />
            <property name="hibernate.cache.use_query_cache" value="true" />
            <property name="hibernate.cache.infinispan.statistics"
                value="true" />

            <!-- Hibernate Search properties -->
            <property name="hibernate.search.default.directory_provider"
                value="org.hibernate.search.store.impl.FSDirectoryProvider" />
            <property name="hibernate.search.default.indexBase" value="/Volumes/Untitled/workspace/pxindex" />
            <property name="hibernate.search.default.directory_provider"
                value="filesystem" />
            <property name="hibernate.search.infinispan.chunk_size"
                value="300000000" />
            <property name="hibernate.search.reader.strategy" value="shared" />
            <property name="hibernate.search.worker.execution" value="sync" />
            <property name="hibernate.search.jmx_enabled" value="true" />

        </properties>
    </persistence-unit>

Hibernate Search本身被部署为JBoss EAP 6.1模块。我下载了JBoss Modeshape发行版,其中包括Hibernate Search模块定义。我的jboss-deployment-structure.xml文件如下所示:

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
    <deployment>
        <dependencies>
            <module name="com.sun.jsf-impl" export="true" />
            <module name="javax.faces.api" export="true" />
            <module name="javax.persistence.api" export="true" />
            <module name="javax.ws.rs.api" export="true" />

            <module name="org.hibernate" export="true" />
            <module name="org.hibernate.validator" export="true" />
            <module name="org.hibernate.envers" export="true" />
            <module name="org.hibernate.commons-annotations" export="true" />
            <module name="org.hibernate.search.engine" services="import"
                export="true" slot="main" />
            <module name="org.hibernate.search.orm" services="import"
                slot="main" export="true" />

            <module name="org.apache.commons.codec" export="true" />
            <module name="org.apache.commons.configuration" export="true" />
            <module name="org.apache.commons.io" export="true" />
            <module name="org.apache.commons.lang" export="true" />

            <module name="org.apache.log4j" export="true" />

            <module name="org.dom4j" export="true" />
            <module name="org.infinispan" export="true" />

            <module name="javax.xml.bind.api" export="true" />
            <module name="org.jboss.resteasy.resteasy-jaxrs" export="true" />
            <module name="org.jboss.resteasy.resteasy-jaxb-provider"
                export="true" />
        </dependencies>
    </deployment>
</jboss-deployment-structure> 

我在部署期间没有收到任何错误,并且我的实体被保留而没有任何错误。我只是没有看到索引被创建,当我尝试手动创建它时我得到一个例外。想法?

0 个答案:

没有答案