DB2 + Websphere : Feature is not implemented: PreparedStatement.setBinaryStream

By | January 31, 2016

From a very strange reason after updating the hibernate4 from version 4.1.4 to 4.2.5 there was suddenly a weird behaviour of the EJB3.1 enterprise application I am working on.
A piece of code that commits to the database an object (ProcessingStatus) containing a BLOB was throwing the following:


[1/31/16 23:37:15:922 EET] 000000eb AbstractBatch Z org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl release HHH000010: On release of batch it still contained JDBC statements
[1/31/16 23:37:15:923 EET] 000000eb SqlExceptionH Z org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions SQL Error: 0, SQLState: null
[1/31/16 23:37:15:924 EET] 000000eb SqlExceptionH Z org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions DSRA1300E: Feature is not implemented: PreparedStatement.setBinaryStream
[1/31/16 23:37:15:925 EET] 000000eb BusinessExcep E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "execute" on bean "BeanId( ******, null)".
Exception data: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not insert: [********.ProcessingStatus]

According to IBM this is a known issue see thread: Troubleshooting enterprise applications on WebSphere Application Server which simultaneously use JDBC providers from JDBC 3.0 and 4.0 specification levels.

This is very weird because according to IBM this occurs when:

Enterprise applications may reference multiple Java Database Connectivity (JDBC) providers through data source instances. In doing so, care must be taken to avoid references to both a JDBC 3.0 and a JDBC 4.0 driver class from the same vendor in an application. Doing so may result in the inability of the application to access JDBC 4.0 API methods on the datasource interfaces.

I know that I do not have this case so this was very strange. My data sources are one XA data source and one non XA data source and they were defined long ago in my environment and both of them are supposed to be JDBC 4.0 . It seems that somehow my data sources are no longer using JDBC 4 any-more by default but JDBC 3 instead, so that hibernate complains about a not implemented feature. I blame Hibernate or an WebSphere Application Server update for this.

ws1

To fix this, I forced the JDBC providers to use JDBC 4. Go to JDBC DataProvider in WebSphere Resources > JDBC > JDBC Data Providers and edit the providers and update the Class Path entries from:

/opt/ibm/db2/V10.1/java/db2jcc.jar
/opt/ibm/db2/V10.1/java/db2jcc_license_cu.jar

ws2

to:

/opt/ibm/db2/V10.1/java/db2jcc4.jar
/opt/ibm/db2/V10.1/java/db2jcc_license_cu.jar

ws3

Advertisements