title: UnsupportedOperationException When Using JPA/Hibernate On Websphere
body: <p><strong>The Problem</strong></p>
  
  <p>I am getting the following exception when trying to update records in my database:</p>
  
  <pre><code>java.lang.UnsupportedOperationException
  at org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform$TransactionManagerAdapter.setRollbackOnly(WebSphereExtendedJtaPlatform.java:139)....
  </code></pre>
  
  <p>This exception only happens when updating. Create, Read and Delete work fine.</p>
  
  <p>What are typical reasons for this code being thrown?</p>
  
  <p><strong>Weird Twist</strong></p>
  
  <p>We are required to use MyEclipseBlue and that Maven or ant is not used to build the project; only MyEclipseBlue's build process can be used.  The above error is throw when testing an EAR that has been generated by MyEclipseBlue.  The above exception <strong>is not thrown</strong> when I'm deploying the code as an EAR generated by Maven on the command line.</p>
  
  <p>I've taken enormous pains to verify that the generated wars are the same, but clearly, I'm missing something.</p>
  
  <p><strong>Environment</strong></p>
  
  <ul>
  <li>Websphere 8.5.5</li>
  <li>MyEclipse Blue v10.x</li>
  <li>Windows 7 x64</li>
  </ul>
  
  <p><strong>Thoughts</strong></p>
  
  <p>I don't believe this is a matter of class loading because the code that throws the exception is in of hibernate-core.jar.  I've also reviewed the classpaths report in Websphere's admin console.</p>
  
  <p>It's not a JDBC lookup issue--both versions use the same way to connect to a jndi resource.  I have them both deployed at the same time presently (prior I just had one or the other).</p>
  
  <p><strong>Source Files</strong></p>
  
  <p>The beans.xml (for CDI) and persistence.xml files are <em>exactly</em> the same in each war:</p>
  
  <p><em>WEB-INF/class/META-INF/persistenc.xml</em></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;persistence version="2.0" 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"&gt;
          &lt;persistence-unit name="boss-persistence" transaction-type="JTA"&gt;
              &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
              &lt;jta-data-source&gt;jdbc/boss&lt;/jta-data-source&gt;
              &lt;properties&gt;
                  &lt;!--&lt;property name="hibernate.hbm2ddl.auto" value="update"/&gt;--&gt;
                  &lt;property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform"/&gt;
                                      &lt;property name="hibernate.format_sql" value="true"/&gt;
                                      &lt;property name="hibernate.show_sql" value="true"/&gt;
              &lt;/properties&gt;
          &lt;/persistence-unit&gt;
      &lt;/persistence&gt;
  </code></pre>
  
  <p><strong>Stack Trace</strong></p>
  
  <pre><code>Caused by: java.lang.UnsupportedOperationException
      at org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform$TransactionManagerAdapter.setRollbackOnly(WebSphereExtendedJtaPlatform.java:139)
      at org.hibernate.engine.transaction.internal.jta.CMTTransaction.markRollbackOnly(CMTTransaction.java:131)
      at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.setRollbackOnly(TransactionCoordinatorImpl.java:306)
      at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.setRollbackOnly(SynchronizationCallbackCoordinatorImpl.java:127)
      at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:117)
      at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:53)
      at org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform$TransactionManagerAdapter$TransactionAdapter$1.invoke(WebSphereExtendedJtaPlatform.java:176)
      at com.sun.proxy.$Proxy127.beforeCompletion(Unknown Source)
      at com.ibm.ws.jtaextensions.SynchronizationCallbackWrapper.beforeCompletion(SynchronizationCallbackWrapper.java:66)
      at com.ibm.tx.jta.impl.RegisteredSyncs.coreDistributeBefore(RegisteredSyncs.java:291)
      at com.ibm.ws.tx.jta.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:153)
      at com.ibm.ws.tx.jta.TransactionImpl.prePrepare(TransactionImpl.java:2369)
      at com.ibm.ws.tx.jta.TransactionImpl.stage1CommitProcessing(TransactionImpl.java:577)
      at com.ibm.tx.jta.impl.TransactionImpl.processCommit(TransactionImpl.java:1015)
      ... 77 more
  </code></pre>
  
  <p><strong>Final Thoughts</strong></p>
  
  <p>What would be different about these two ears that would make different code be called?  </p>
  
  <p>Thank you for any help you can provide!</p>