繁体   English   中英

索引对象时休眠搜索java.nio.channels.OverlappingFileLockException

Hibernate Search java.nio.channels.OverlappingFileLockException when index object

提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供   中文繁体   英文版本   中英对照 版本,有任何建议请联系yoyou2525@163.com。

我在VPS实例上的Tomcat 9中运行了一个Web服务。 它使用Hibernate 5.4.12和Hibernate Search 5.11.0。 当我在本地调试时,我的代码可以正常工作 但是,在部署到服务器后,尝试索引时会收到OverlappingFileLockException 我认为问题出在VPS端,权限或窗口的文件管理上。

这是我的休眠配置:

<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
        <property name="hibernate.dialect">org.hibernate.dialect.SQLServer2012Dialect</property>
        <property name="hibernate.connection.url">jdbc:sqlserver://[IP Server];databaseName=hellojob_db</property>
        <property name="hibernate.connection.username">sa</property>
        <property name="hibernate.connection.password">[password]</property>
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
        <property name="show_sql">true</property>
        <property name="hibernate.current_session_context_class">thread</property>
        <property name="hibernate.globally_quoted_identifiers">true</property>
        <property name="hibernate.show_sql">true</property>
        <!--<property name="hibernate.search.autoregister_listeners">false</property>-->
        <property name="hibernate.search.indexing_strategy">manual</property>
        <property name="hibernate.search.default.directory_provider">filesystem</property>
        <property name="hibernate.search.default.indexBase">C:/tvc/indexes</property>
        <property name="hibernate.id.new_generator_mappings">true</property>
        <property name="hibernate.transaction.flush_before_completion">true</property>
        <mapping package="com.hellojob.entities" />
        <mapping class="com.hellojob.entities.Users" />
        <mapping class="com.hellojob.entities.Customer" />
        <mapping class="com.hellojob.entities.RecruitmentInfo" />
        <mapping class="com.hellojob.entities.ERP_Admin" />
        <mapping class="com.hellojob.entities.ERP_AdminRole" />
        <mapping class="com.hellojob.entities.PositionAdmin" />
        <mapping class="com.hellojob.entities.WebsiteOrderContract" />
        <mapping class="com.hellojob.entities.WebsiteModule" />
        <mapping class="com.hellojob.entities.OrderContract" />
        <mapping class="com.hellojob.entities.PartnerCompany" />
        <mapping class="com.hellojob.entities.FormStructure" />
        <mapping class="com.hellojob.entities.Vocabulary" />
        <mapping class="com.hellojob.entities.VocabularyUsing" />
        <mapping class="com.hellojob.entities.VocabularyUsingType" />
        <mapping class="com.hellojob.entities.VocabularyAnswer" />
        <mapping class="com.hellojob.entities.VocabularyAnswerMapping" />
        <mapping class="com.hellojob.entities.Tvc_HistoryAcceptAuth" />
        <mapping class="com.hellojob.entities.Tvc_HistoryCustomer" />
        <mapping class="com.hellojob.entities.Tvc_HistoryCustomerObj" />
        <mapping class="com.hellojob.entities.WebsiteLanguage" />
        <mapping class="com.hellojob.entities.FavouriteOrderContract" />
        <mapping class="com.hellojob.entities.CustomerWish" />
        <mapping class="com.hellojob.entities.WebsiteLanguage" />
        <mapping class="com.hellojob.entities.FavouriteRecruitment" />
        <mapping class="com.hellojob.entities.EvaluatePartnerCompany" />
        <mapping class="com.hellojob.entities.Website_OrderBackground" />
        <mapping class="com.hellojob.entities.VocabularyShared" />
        <mapping class="com.hellojob.entities.Website_OrderContractGallery" />
        <mapping class="com.hellojob.entities.SaleNews" />
        <mapping class="com.hellojob.entities.Customer_Gallery" />
        <mapping class="com.hellojob.entities.UserReport" />
        <mapping class="com.hellojob.entities.UserReportReason" />
        <mapping class="com.hellojob.entities.NotificationType" />
        <mapping class="com.hellojob.entities.UserNotification" />
        <mapping class="com.hellojob.entities.JobProvince" />
        <mapping class="com.hellojob.entities.SaleNewsTransactionDetail" />
        <mapping class="com.hellojob.entities.SaleNewsTransaction" />        
        <mapping class="com.hellojob.entities.HistoryAffiliate" />
    </session-factory>
</hibernate-configuration>

这是索引一个对象的代码:

     public static void indexOne(int id) throws Exception {
        Session session = null;
        FullTextSession fullTextSession = null;
        Transaction tx = null;
        try {
            if (session != null) {
                session = HibernateConfiguration.getInstance().openSession();
                fullTextSession = Search.getFullTextSession(session);
                tx = fullTextSession.beginTransaction();
                Object order = fullTextSession.load(WebsiteOrderContract.class, id);
                fullTextSession.index(order);
                tx.commit();
            }
        } catch (Exception e) {
            HibernateConfiguration.getInstance().rollbackTransaction(tx);
            throw e;
        } finally {
            HibernateConfiguration.getInstance().closeSession(session);
            try {
                if (fullTextSession != null && fullTextSession.isOpen()) {
                    fullTextSession.close();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

这是我的代码来重新索引所有对象

    public static void indexAll() throws Exception {
        Session session = null;
        FullTextSession fullTextSession = null;
        try {
            session = HibernateConfiguration.getInstance().openSession();
            if (session != null) {
                fullTextSession = Search.getFullTextSession(session);
                fullTextSession.createIndexer().startAndWait();
            }
        } catch (Exception e) {
            throw e;
        } finally {
            HibernateConfiguration.getInstance().closeSession(session);
            try {
                if (fullTextSession != null && fullTextSession.isOpen()) {
                    fullTextSession.close();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
问题暂未有回复.您可以查看右边的相关问题.
5 如何避免java.nio.channels.OverlappingFileLockException

我有一个Java Web应用程序,正在尝试使用Neo4j 2.0。 我编写了一个Servlet,使我可以观察数据库中的某些操作。 它使用与应用程序中其他servlet相同的单例数据库连接,但是当我尝试访问调试servlet时,出现“ OverlappingFileLockException” ...

8 在全新的Eclipse安装中为本地Maven Repo重新编制索引失败,并出现java.nio.channels.OverlappingFileLockException

每当我尝试通过首选项对话框为它重新编制索引时,在Win10上完全重新安装Eclipse for EE版本:2020-12(4.18.0)时,会出现以下错误: 我已经尝试过: 将Maven仓库移至新的和/或空的位置 从全新的Eclipse安装和全新的工作区文件夹开始 重新启动系统并安 ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2022 STACKOOM.COM