2

我收到以下错误:

Cannot cast org.hibernate.search.hcore.impl.HibernateSearchIntegrator to 
org.hibernate.integrator.spi.Integrator

堆栈跟踪:

   [WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'XXX threw an unexpected exception: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.search.hcore.impl.HibernateSearchIntegrator could not be instantiated: java.lang.ClassCastException: Cannot cast org.hibernate.search.hcore.impl.HibernateSearchIntegrator to org.hibernate.integrator.spi.Integrator
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:324)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
Caused by: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.search.hcore.impl.HibernateSearchIntegrator could not be instantiated: java.lang.ClassCastException: Cannot cast org.hibernate.search.hcore.impl.HibernateSearchIntegrator to org.hibernate.integrator.spi.Integrator
    at java.util.ServiceLoader.fail(ServiceLoader.java:224)
    at java.util.ServiceLoader.access$100(ServiceLoader.java:181)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:370)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:438)
    at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:251)
    at org.hibernate.integrator.internal.IntegratorServiceImpl.(IntegratorServiceImpl.java:53)
    at org.hibernate.service.internal.BootstrapServiceRegistryImpl.(BootstrapServiceRegistryImpl.java:80)
    at org.hibernate.service.internal.BootstrapServiceRegistryImpl.(BootstrapServiceRegistryImpl.java:57)
    at org.hibernate.service.ServiceRegistryBuilder.(ServiceRegistryBuilder.java:76)
    at com.orangeraft.hms.server.module.login.service.LoginServiceImpl.login(LoginServiceImpl.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
    ... 22 more
Caused by: java.lang.ClassCastException: Cannot cast org.hibernate.search.hcore.impl.HibernateSearchIntegrator to org.hibernate.integrator.spi.Integrator
    at java.lang.Class.cast(Class.java:3007)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:362)
    ... 34 more

这是我的代码:

Configuration configuration = new Configuration();
configuration.configure();
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder()
        .applySettings(configuration.getProperties())
        .buildServiceRegistry();
SessionFactory sf = configuration.buildSessionFactory(serviceRegistry);
Session hibernateSession = sf.getCurrentSession();
FullTextSession fullTextSession = Search.getFullTextSession(hibernateSession);
    fullTextSession.createIndexer().startAndWait();

我只是想在 GWT 应用程序中创建索引,如休眠搜索教程中所示。任何想法如何解决这一问题?

4

1 回答 1

4

我认为您在 WEB-INF/lib 和启动类路径中都处于休眠状态。这可能会将类加载器混淆为实现,并且接口可能不会由同一个类加载器加载,从而产生意外的 ClassCastException。

于 2012-10-22T16:22:18.603 回答