繁体   English   中英

Hibernate 搜索 java.nio.channels.OverlappingFileLockException when index object

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

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

我有一个 web 服务在 VPS 实例上的 Tomcat 9 内运行。 它使用 Hibernate 5.4.12 和 Hibernate 搜索 5.11.0。 当我在本地调试时,我的代码工作正常 但是在我部署到服务器后,当我尝试使用 Index 时,我会得到一个OverlappingFileLockException 我认为问题出在VPS方面,window的权限或文件管理。

这是我的 hibernate 配置:

<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>

这是索引一个 object 的代码:

     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();
            }
        }
    }

这是我重新索引所有 object 的代码

    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 回购失败,并出现 java.nio.channels.OverlappingFileLockException

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

暂无
暂无

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

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