UnsupportedOperationException when creating EMF in WebSphere
Description
Attachments
- 30 Mar 2017, 11:21 AM
- 30 Mar 2017, 11:16 AM
Activity
Former user May 3, 2017 at 7:57 AM
I've confirmed that changing the following setting in the attached test will work:
hibernate.transaction.jta.platform=org.hibernate.engine.transaction.jta.platform.internal.WebSphereJtaPlatform
WebSphereJtaPlatform basically does the same thing that Christian's custom JtaPlatform does.
Using the short name should also work, but I haven't tried it yet:
hibernate.transaction.jta.platform=WebSphere
Karel Suta April 12, 2017 at 10:44 AMEdited
I don't have a possibility to test this on earlier WebSphere versions. Is it possible to add this as another JtaPlatform option to master and deprecate current implementation?
This issue prevents usage of latest Hibernate on WebSphere.
Karel Suta March 31, 2017 at 10:01 AMEdited
I can test it just on WebSphere 8.5.5.
Tried on WebSphere 8.5.5.11 - works.
Christian Beikov March 31, 2017 at 9:13 AM
Are you able to test this JTA platform with older Websphere versions? I'm not using Websphere anymore so I can't but if you could confirm this works on 7, 8 and 8.5 then it shouldn't be a problem to integrate this code into the master and maybe backport.
Karel Suta March 31, 2017 at 8:20 AM
Works for me, just changed UT_NAME to "java:comp/UserTransaction".
Christian Beikov March 30, 2017 at 8:04 PM
You need a custom JtaPlatform implementation for this to work. Could you try the following maybe? This worked in WAS 8.5 for me back then. Maybe we can update the implementation shipped with Hibernate when you confirm this works.
public class WebSphereUowJtaPlatform extends AbstractJtaPlatform {
private static final long serialVersionUID = 1L;
public static final String UT_NAME = "java:comp/UserTransactionMock";
@Override
protected boolean canCacheTransactionManager() {
return true;
}
@Override
protected TransactionManager locateTransactionManager() {
try {
return (TransactionManager) Class.forName("com.ibm.ws.Transaction.TransactionManagerFactory").getMethod("getTransactionManager").invoke(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
protected UserTransaction locateUserTransaction() {
return (UserTransaction) jndiService().locate(UT_NAME);
}
@Override
public Object getTransactionIdentifier(Transaction transaction) {
// WebSphere, however, is not a sane JEE/JTA container...
return Integer.valueOf(transaction.hashCode());
}
}
I tried to create EMF in application deployed on WebSphere 9, but I get exception listed in attachment. This issue popped up when we migrated from Hibernate 5.0.9 to 5.1.4, it is reproducible with version 5.2.9 too.
Project with reproducer can be found it attachment. You may deploy built project to WebSphere manually or use Cargo plugin to do so. URL to invoke servlet reproducing the issue is "http://localhost:9080/was-hibernate/test".