Facing error TranManagerSet incompatible with TransactionManager On Websphere 8.5. Creating Hibernate Search Index

时光怂恿深爱的人放手 提交于 2020-04-17 20:29:08

问题


I am trying to perform the initial indexing on Elastic server using Hibernate Search, Lucene and using persistence.xml file. The server raises below exception when I run the index creation process on Websphere, this whole process works fine on TOMCAT & TC server. That too only with help of hibernate.cfg.xml. We also have the hibernate.cfg.xml file in the project.

I've also put an earlier question when this was not working with hibernate.cfg.xml and was throwing errors. This is the earlier thread, which later on made me introduce the persistence.xml path. The link is this.

First the Exception, once the below code lines are executed:

   fullTextEntityManager.createIndexer().startAndWait();

Exception:

00000177 SystemOut     O [org.hibernate.search.exception.impl.LogErrorHandler](ERROR): HSEARCH000058: 
HSEARCH000116: Unexpected error during MassIndexer operation
org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException: Could not obtain WebSphere TransactionManager
    at org.hibernate.engine.transaction.jta.platform.internal.WebSphereJtaPlatform.locateTransactionManager(WebSphereJtaPlatform.java:66)
    at org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform.retrieveTransactionManager(AbstractJtaPlatform.java:87)
    at org.hibernate.search.batchindexing.impl.BatchTransactionalContext.lookupTransactionManager(BatchTransactionalContext.java:54)
    at org.hibernate.search.batchindexing.impl.BatchTransactionalContext.<init>(BatchTransactionalContext.java:43)
    at org.hibernate.search.batchindexing.impl.BatchIndexingWorkspace.runWithErrorHandler(BatchIndexingWorkspace.java:120)
    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: java.lang.ClassCastException: com.ibm.ws.tx.jta.TranManagerSet incompatible with javax.transaction.TransactionManager
    at org.hibernate.engine.transaction.jta.platform.internal.WebSphereJtaPlatform.locateTransactionManager(WebSphereJtaPlatform.java:63)
    ... 10 more

Below are the configuration and code details:

Java Code used:

EntityManagerFactory emf = Persistence.createEntityManagerFactory("JPAManager");
EntityManager em = emf.createEntityManager();
String message = "";
EntityTransaction tx = em.getTransaction();
             tx.begin();

             ProgressMonitor progressMonitor = new ProgressMonitor();
             FullTextEntityManager fullTextEntityManager = org.hibernate.search.jpa.Search.getFullTextEntityManager(em);
             fullTextEntityManager.createIndexer().startAndWait();

             tx.commit();

Persistence.xml

  <persistence xmlns="http://java.sun.com/xml/ns/persistence"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
                 version="2.0">
       <persistence-unit name="JPAManager" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
     <jta-data-source>jdbc/[youtDataSourceName]</jta-data-source>
<properties>
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WebSphereExtendedJTATransactionLookup" />

<property name="hibernate.search.default.indexmanager" value="elasticsearch"></property>
        <property name="hibernate.search.default.elasticsearch.host" value="http://ip:9400"></property>
        <property name="hibernate.search.default.elasticsearch.required_index_status" value="yellow"></property>
         <property name="hibernate.search.default.indexwriter.infostream" value="true"></property>

        </properties>
    </persistence-unit>
    </persistence>

Jar Files related to Hibernate Search, Elastic Search and other dependencies we have currently:


回答1:


Found out that issue was with the below two jars which I had in my war file on WAS server and we conflicting with the websphere's internal jars.

Removing below two jars solved it:

  1. jboss-transaction-api_1.2_spec-1.0.1.Final
  2. jta.jar

Hope this may help!



来源:https://stackoverflow.com/questions/61212876/facing-error-tranmanagerset-incompatible-with-transactionmanager-on-websphere-8

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