java.lang.ClassCastException: org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager$ContextSourceAndDataSourceTransactionObject

Spring JIRA | Jacqueline Stark | 8 years ago
  1. 0

    Our project is using Spring-2.0.7 and spring-ldap-1.2.1. When the ContextSourceAndDataSourceTransactionManager is used within another transaction manager, and they use the same data source, an exception occurs when the inner transaction is rolled back. The stack trace is: java.lang.ClassCastException: org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager$ContextSourceAndDataSourceTransactionObject at org.springframework.jdbc.datasource.DataSourceTransactionManager.doSetRollbackOnly(DataSourceTransactionManager.java:284) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:761) at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:730) This seems to be because ContextSourceAndDataSourceTransactionManager does not override doSetRollbackOnly(). So when this is called, it uses the DataSourceTransactionManager's implementation, which doesn't know how to handle the ContextSourceAndDataSourceTransactionObject provided in status.getTransaction(). The following test case, using EasyMock, demonstrates the exception: public void testNestedTransaction() throws Exception { DataSource mockDataSource = createMock(DataSource.class); expect(mockDataSource.getConnection()).andReturn(createMock(Connection.class)); replay(mockDataSource); PlatformTransactionManager outerTxnManager = new DataSourceTransactionManager(mockDataSource); outerTxnManager.getTransaction(new DefaultTransactionDefinition()); ContextSourceAndDataSourceTransactionManager innerTxnManager = new ContextSourceAndDataSourceTransactionManager(); innerTxnManager.setContextSource(createMock(ContextSource.class)); innerTxnManager.setDataSource(mockDataSource); TransactionStatus innerTxnStatus = innerTxnManager.getTransaction(new DefaultTransactionDefinition()); innerTxnManager.rollback(innerTxnStatus); }

    Spring JIRA | 8 years ago | Jacqueline Stark
    java.lang.ClassCastException: org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager$ContextSourceAndDataSourceTransactionObject
  2. 0

    LDAP-123: java.lang.ClassCastException: org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager$ContextSourceAndDataSourceTransactionObject thrown on inner transaction rollback

    GitHub | 8 years ago | spring-issuemaster
    java.lang.ClassCastException: org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager$ContextSourceAndDataSourceTransactionObject
  3. 0

    Our project is using Spring-2.0.7 and spring-ldap-1.2.1. When the ContextSourceAndDataSourceTransactionManager is used within another transaction manager, and they use the same data source, an exception occurs when the inner transaction is rolled back. The stack trace is: java.lang.ClassCastException: org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager$ContextSourceAndDataSourceTransactionObject at org.springframework.jdbc.datasource.DataSourceTransactionManager.doSetRollbackOnly(DataSourceTransactionManager.java:284) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:761) at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:730) This seems to be because ContextSourceAndDataSourceTransactionManager does not override doSetRollbackOnly(). So when this is called, it uses the DataSourceTransactionManager's implementation, which doesn't know how to handle the ContextSourceAndDataSourceTransactionObject provided in status.getTransaction(). The following test case, using EasyMock, demonstrates the exception: public void testNestedTransaction() throws Exception { DataSource mockDataSource = createMock(DataSource.class); expect(mockDataSource.getConnection()).andReturn(createMock(Connection.class)); replay(mockDataSource); PlatformTransactionManager outerTxnManager = new DataSourceTransactionManager(mockDataSource); outerTxnManager.getTransaction(new DefaultTransactionDefinition()); ContextSourceAndDataSourceTransactionManager innerTxnManager = new ContextSourceAndDataSourceTransactionManager(); innerTxnManager.setContextSource(createMock(ContextSource.class)); innerTxnManager.setDataSource(mockDataSource); TransactionStatus innerTxnStatus = innerTxnManager.getTransaction(new DefaultTransactionDefinition()); innerTxnManager.rollback(innerTxnStatus); }

    Spring JIRA | 8 years ago | Jacqueline Stark
    java.lang.ClassCastException: org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager$ContextSourceAndDataSourceTransactionObject
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    JaxB cannot be cast to java.lang.Integer

    Stack Overflow | 4 years ago | Rodrigo
    java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to java.lang.Integer
  6. 0

    app crashes when i change the order of my XML RelativeLayout android

    Stack Overflow | 4 years ago | Aaron Russell
    java.lang.ClassCastException: android.widget.ImageView

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.ClassCastException

      org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager$ContextSourceAndDataSourceTransactionObject

      at org.springframework.jdbc.datasource.DataSourceTransactionManager.doSetRollbackOnly()
    2. Spring Framework
      DataSourceTransactionManager.doSetRollbackOnly
      1. org.springframework.jdbc.datasource.DataSourceTransactionManager.doSetRollbackOnly(DataSourceTransactionManager.java:284)
      1 frame
    3. Spring Tx
      AbstractPlatformTransactionManager.rollback
      1. org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:761)
      2. org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:730)
      2 frames