Hibernate Search's Initial MassIndexer not working with Wepshphere 8.5, but works fine on TOMCAT

人走茶凉 提交于 2020-04-18 00:55:10

问题


We are trying to create the initial elastic search indexes with hibernate search.

Below are the configuration on our system and the exception we are facing.

First the configuration: hibernate.cfg.xml: jdbc/dataSource

    <property name="dialect">com.csc.pt.hiber.MSSQLDialect2012</property>
    <!-- Session/Transaction -->

    <property name="hibernate.current_session_context_class">thread</property>
    <property name="transaction.jta.platform" >org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform</property>
    <property name="transaction.manager_lookup_class">org.hibernate.transaction.WebSphereExtendedJTATransactionLookup</property>

    <!-- Use Scrollable Result Set -->
    <property name="hibernate.jdbc.use_scrollable_resultset">true</property>
    <!--  more verbose logs -->
    <property name="hibernate.show_sql">false</property>
    <property name="hibernate.format_sql">false</property>
    <property name="hibernate.use_sql_comments">false</property>
    <property name="hibernate.generate_statistics">false</property>
    <property name="hibernate.query.startup_check">false</property>

    <!-- <property name="hibernate.connection.autocommit">true</property>  -->
    <property name="connection.isolation">1</property>

    <!-- performance factors -->
    <property name="hibernate.jdbc.batch_size">50</property>
    <property name="hibernate.default_batch_fetch_size">8</property>
    <!-- FSIT#179159 Resolution#65256 - Start -->
    <property name="hibernate.order_inserts">true</property>
    <!-- FSIT#179159 Resolution#65256 - End -->

    <!--  second level cache -->
    <property name="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</property>
    <property name="hibernate.cache.use_minimal_puts">true</property>
    <property name="hibernate.cache.use_query_cache">false</property>
    <property name="hibernate.cache.use_second_level_cache">false</property>

<property name="hibernate.search.default.indexmanager">elasticsearch</property>
        <property name="hibernate.search.default.elasticsearch.host">http://ip:9400</property>
         <property name="hibernate.search.default.elasticsearch.index_schema_management_strategy">drop-and-create</property>
         <property name="hibernate.search.default.elasticsearch.required_index_status">yellow</property>
         <property name="hibernate.search.default.indexwriter.infostream">true</property>

Versions of Hibernate and Hibernate Search we are using:

Code of the class, used to create the intial Indexes:

@SuppressWarnings("static-access")
    public static String createElasticSearchIndex(HibernateSessionFactory hsf) {
        Session session = hsf.current().getSession("");
        FullTextSession fullTextSession = Search.getFullTextSession(session.getSession());
        try {
            fullTextSession.createIndexer().startAndWait();

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

Now the Exception we are facing.

[10/14/18 15:55:56:029 EDT] 00000393 SystemOut     O [org.hibernate.search.batchindexing.impl.IdentifierConsumerDocumentProducer](ERROR): HSEARCH000065: Error while rolling back transaction after null
java.lang.UnsupportedOperationException
    at org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform$TransactionManagerAdapter.rollback(WebSphereExtendedJtaPlatform.java:116)
    at org.hibernate.search.batchindexing.impl.IdentifierConsumerDocumentProducer.rollbackTransaction(IdentifierConsumerDocumentProducer.java:201)
    at org.hibernate.search.batchindexing.impl.IdentifierConsumerDocumentProducer.loadList(IdentifierConsumerDocumentProducer.java:181)
    at org.hibernate.search.batchindexing.impl.IdentifierConsumerDocumentProducer.loadAllFromQueue(IdentifierConsumerDocumentProducer.java:140)
    at org.hibernate.search.batchindexing.impl.IdentifierConsumerDocumentProducer.run(IdentifierConsumerDocumentProducer.java:120)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:522)
    at java.util.concurrent.FutureTask.run(FutureTask.java:277)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1153)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.lang.Thread.run(Thread.java:785)
[10/14/18 15:55:56:029 EDT] 00000393 SystemOut     O [org.hibernate.search.exception.impl.LogErrorHandler](ERROR): HSEARCH000058: HSEARCH000212: An exception occurred while the MassIndexer was transforming identifiers to Lucene Documents
java.lang.UnsupportedOperationException
    at org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform$TransactionManagerAdapter.begin(WebSphereExtendedJtaPlatform.java:91)
    at org.hibernate.search.batchindexing.impl.IdentifierConsumerDocumentProducer.beginTransaction(IdentifierConsumerDocumentProducer.java:191)
    at org.hibernate.search.batchindexing.impl.IdentifierConsumerDocumentProducer.loadList(IdentifierConsumerDocumentProducer.java:164)
    at org.hibernate.search.batchindexing.impl.IdentifierConsumerDocumentProducer.loadAllFromQueue(IdentifierConsumerDocumentProducer.java:140)
    at org.hibernate.search.batchindexing.impl.IdentifierConsumerDocumentProducer.run(IdentifierConsumerDocumentProducer.java:120)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:522)
    at java.util.concurrent.FutureTask.run(FutureTask.java:277)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1153)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.lang.Thread.run(Thread.java:785)
[10/14/18 15:55:56:057 EDT] 00000380 SystemOut     O [org.hibernate.search.exception.impl.LogErrorHandler](ERROR):
 HSEARCH000058: HSEARCH000211: An exception occurred while the MassIndexer was fetching the primary identifiers list
org.hibernate.engine.jndi.JndiException: Unable to lookup JNDI name [java:comp/websphere/ExtendedJTATransaction]
    at org.hibernate.engine.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:100)
    at org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform$TransactionManagerAdapter$TransactionAdapter.<init>(WebSphereExtendedJtaPlatform.java:138)
    at org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform$TransactionManagerAdapter$TransactionAdapter.<init>(WebSphereExtendedJtaPlatform.java:134)
    at org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform$TransactionManagerAdapter.getTransaction(WebSphereExtendedJtaPlatform.java:106)
    at org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform$TransactionManagerAdapter.getStatus(WebSphereExtendedJtaPlatform.java:101)
    at org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform.getCurrentStatus(AbstractJtaPlatform.java:136)
    at org.hibernate.internal.StatelessSessionImpl.flushBeforeTransactionCompletion(StatelessSessionImpl.java:659)
    at org.hibernate.internal.StatelessSessionImpl.beforeTransactionCompletion(StatelessSessionImpl.java:641)
    at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:467)
    at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:146)
    at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38)
    at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:220)
    at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68)
    at org.hibernate.search.batchindexing.impl.IdentifierProducer.inTransactionWrapper(IdentifierProducer.java:121)
    at org.hibernate.search.batchindexing.impl.IdentifierProducer.run(IdentifierProducer.java:89)
    at org.hibernate.search.batchindexing.impl.OptionallyWrapInJTATransaction.runWithErrorHandler(OptionallyWrapInJTATransaction.java:70)
    at org.hibernate.search.batchindexing.impl.ErrorHandledRunnable.run(ErrorHandledRunnable.java:33)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:522)
    at java.util.concurrent.FutureTask.run(FutureTask.java:277)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1153)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.lang.Thread.run(Thread.java:785)
Caused by: javax.naming.ConfigurationException: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component.  This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request.  Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application.  Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names. [Root exception is javax.naming.NameNotFoundException: Name comp/websphere not found in context "java:".]
    at com.ibm.ws.naming.java.javaURLContextImpl.throwExceptionIfDefaultJavaNS(javaURLContextImpl.java:522)
    at com.ibm.ws.naming.java.javaURLContextImpl.throwConfigurationExceptionWithDefaultJavaNS(javaURLContextImpl.java:552)
    at com.ibm.ws.naming.java.javaURLContextImpl.lookupExt(javaURLContextImpl.java:481)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookupExt(javaURLContextRoot.java:485)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:396)
    at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:157)
    at javax.naming.InitialContext.lookup(InitialContext.java:432)
    at org.hibernate.engine.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:97)
    ... 21 more
Caused by: javax.naming.NameNotFoundException: Name comp/websphere not found in context "java:".
    at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1970)
    at com.ibm.ws.naming.ipbase.NameSpace.retrieveBinding(NameSpace.java:1377)
    at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1220)
    at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:1142)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.lookupExt(UrlContextImpl.java:1436)
    at com.ibm.ws.naming.java.javaURLContextImpl.lookupExt(javaURLContextImpl.java:477)

Please let me know, if you require any more information.


回答1:


Though I did not got any success through this approach, instead I followed the RESOURCE_LOCAL transaction type approach as detailed on this link. Hope this helps you.



来源:https://stackoverflow.com/questions/60951549/hibernate-searchs-initial-massindexer-not-working-with-wepshphere-8-5-but-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!