编程语言
首页 > 编程语言> > java – 在Web应用程序中启动Hibernate Search时出错

java – 在Web应用程序中启动Hibernate Search时出错

作者:互联网

有人可以提供帮助,我将hibernate搜索放入我的网络应用程序并收到以下错误:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
        <property name="hibernate.connection.url">jdbc:postgresql://localhost/postgres</property>
        <property name="hibernate.connection.username">postgres</property>
        <property name="hibernate.connection.password">noor</property>
        <property name="hibernate.connection.pool_size">10</property>
        <property name="show_sql">true</property>
        <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="hibernate.hbm2ddl.auto">update</property>
        <property name="current_session_context_class">thread</property> 

        <property name="hibernate.search.default.indexBase"> 
            /users/application/indexes 
        </property> 
        <property name="hibernate.search.default.indexBase"> 
            /users/application/indexes 
        </property>

        <mapping resource="com/BiddingSystem/Models/Users.hbm.xml"/>
        <mapping resource="com/BiddingSystem/Models/ForumTopic.hbm.xml"/>
        <mapping resource="com/BiddingSystem/Models/ForumMessage.hbm.xml"/>
        <mapping resource="com/BiddingSystem/Models/Administrator.hbm.xml"/>
        <mapping resource="com/BiddingSystem/Models/PersonalUser.hbm.xml"/>
        <mapping resource="com/BiddingSystem/Models/BusinessUser.hbm.xml"/>
        <mapping resource="com/BiddingSystem/Models/BusinessContactNumbers.hbm.xml"/>
        <mapping resource="com/BiddingSystem/Models/Attribute.hbm.xml"/>
        <mapping resource="com/BiddingSystem/Models/AttributeOption.hbm.xml"/>
        <mapping resource="com/BiddingSystem/Models/Category.hbm.xml"/>
        <mapping resource="com/BiddingSystem/Models/Item.hbm.xml"/>
        <mapping resource="com/BiddingSystem/Models/Auction.hbm.xml"/>
        <mapping resource="com/BiddingSystem/Models/Picture.hbm.xml"/>
        <mapping resource="com/BiddingSystem/Models/Bid.hbm.xml"/>


    </session-factory>
</hibernate-configuration>

堆栈跟踪:

org.hibernate.HibernateException: could not init listeners
 at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:205)
 at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1980)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842)
 at com.BiddingSystem.server.ServiceImpl.<init>(ServiceImpl.java:87)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
 at java.lang.Class.newInstance0(Class.java:355)
 at java.lang.Class.newInstance(Class.java:308)
 at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
 at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
 at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:463)
 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: org.hibernate.search.SearchException: Unable to initialize directory provider: com.BiddingSystem.Models.ForumMessage
 at org.hibernate.search.store.DirectoryProviderFactory.createDirectoryProvider(DirectoryProviderFactory.java:169)
 at org.hibernate.search.store.DirectoryProviderFactory.createDirectoryProviders(DirectoryProviderFactory.java:100)
 at org.hibernate.search.spi.SearchFactoryBuilder.initDocumentBuilders(SearchFactoryBuilder.java:375)
 at org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:262)
 at org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:144)
 at org.hibernate.search.event.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:137)
 at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
 at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
 at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
 ... 28 more
Caused by: org.hibernate.search.SearchException: Unable to create index directory: C:\users\application\indexes for index com.BiddingSystem.Models.ForumMessage
 at org.hibernate.search.store.DirectoryProviderHelper.makeSanityCheckedDirectory(DirectoryProviderHelper.java:252)
 at org.hibernate.search.store.DirectoryProviderHelper.getVerifiedIndexDir(DirectoryProviderHelper.java:234)
 at org.hibernate.search.store.FSDirectoryProvider.initialize(FSDirectoryProvider.java:62)
 at org.hibernate.search.store.DirectoryProviderFactory.createDirectoryProvider(DirectoryProviderFactory.java:166)
 ... 36 more

解决方法:

查看您正在使用Windows的错误消息:

Unable to create index directory: C:\users\application\indexes for index com.BiddingSystem.Models.ForumMessage

但是,在配置中,您可以指定索引库unix样式:/ users / application / indexes

索引基目录需要存在,并且它必须是您的操作系统的有效目录路径.

标签:java,lucene,hibernate-search
来源: https://codeday.me/bug/20190518/1128907.html