eclipselink and weblogic12g CLOB ClassCastException - oracle

I have an application deployed in a Weblogic 12g, and a datasource configured against an oracle RAC.
It uses as JPA provider; EclipseLink 2.4.1.
The problem is this exception;
Caused by: Exception [EclipseLink-3001] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.ConversionException
Exception Description: The object [weblogic.jdbc.wrapper.Clob_oracle_sql_CLOB#87a98a], of class [class weblogic.jdbc.wrapper.Clob_oracle_sql_CLOB], could not be converted to [class java.lang.String].
Internal Exception: java.lang.ClassCastException: oracle.sql.CLOB
....
Caused by: java.lang.ClassCastException: oracle.sql.CLOB
at weblogic.jdbc.wrapper.Clob_oracle_sql_CLOB.length(Unknown Source)
at org.eclipse.persistence.internal.helper.ConversionManager.convertObjectToString(ConversionManager.java:679)
at org.eclipse.persistence.internal.helper.ConversionManager.convertObject(ConversionManager.java:100)
....
Well, I understand what is the problem but I can't understand why only occurs when some Oracle instance in the Oracle RAC was reset. When this occurs, the only thing to do is restart the WLS instance. ah! While I have this error, the rest of the datatypes work well!.
Maybe there are some kind of direct relaction between LOB types and instances of Oracle servers inside a RAC? It's possible some kind of scenario that restarting an Oracle instance inside a RAC the CLOB datatypes don't works?
Thanks in advance!
Best regards

Related

Cannot execute update in a read only transaction

As a database we use PostgreSQL. Application uses spring libraries, and transaction is managed by spring. Transactional annotation is used correctly, where it is needed as read-only, and where it is used with write abilities. But in logs we occasinally see exception
2020-12-30 11:39:13.513 [jmsContainer-8] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - ERROR: cannot execute nextval() in a read-only transaction
2020-12-30 11:39:13.515 [jmsContainer-8] ERROR o.s.t.s.TransactionSynchronizationUtils - TransactionSynchronization.afterCompletion threw exception
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not extract ResultSet
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:162)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:780)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:758)
at jdk.internal.reflect.GeneratedMethodAccessor2794.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:301)
at com.sun.proxy.$Proxy226.persist(Unknown Source)
Connections to PostgreSQL is provided through pg_bouncer, and pool_mode=sesssion, the server_reset_query=DISCARD ALL.
We tried restarting the pg_bouncer, though maybe some connection by default set read-only and being kept alive, but it did not help.
Any thoughts?

JDBC DatabaseMetaData method not implemented by JDBC(T4SQLMX) driver

I am setting up a Spring-boot application to connect to HP NonStop Tandem's SQL/MX. First I achieved this connection by hard-coding the jdbc parameters like dataSource, URL, etc in the service section of the application and it worked (I was able to access tables by executing query).
Now I am trying to remove the hard coded part and have my database related info in application.properties file, but now I am getting the following error
org.springframework.jdbc.support.MetaDataAccessException: JDBC DatabaseMetaData method not implemented by JDBC driver - upgrade your driver; nested exception is java.lang.AbstractMethodError: Method com/tandem/t4jdbc/SQLMXConnection.isValid(I)Z is abstract
Can someone help me understand the root cause? The same driver jar is being used when hard-coding the datasource details and it worked but not working when having the data source properties in application.properties and needs an upgrade to the jar.
I encountered the same exception when using Spring Data JPA in a Spring Boot application, the JTDS driver and the Hikari connection pool. In my case I discovered that the following fixed the problem:
Examining the class com.zaxxer.hikari.pool.PoolBase, the following can be observed:
this.isUseJdbc4Validation = config.getConnectionTestQuery() == null;
Thus JDBC 4 validation will not be attempted if there is a connection test query configured. In a Spring Boot application, this can be accomplished like this:
spring.datasource.hikari.connection-test-query=select 1;
Regretfully I do not have any experience with the T4SQLMX driver but nevertheless hope this can be of some use.
I recently fought through the same issue, for me I was using a JDBC type 3 driver; but my spring implementation only supported a type 4 driver, thus when the method you linked above was attempted to be called, it caused the error.
I suggest you look for a type 4 driver for your particular database and see if that resolves your issue.

WSO2 API Manager with EnterpriseDb 9.5 - Error java.lang.NullPointerException: tuples must be non-null

I am trying to configure WSO2 API Manager 2.0.0 with Enterprise-db Advance Server (postgres) 9.5.
I have configured Postgres JDBC Driver (postgresql-9.4.1212.jre7.jar) with it and configured all required data-sources required for WSO2-AM.
I am getting following error when start wso2-am server, please advise what is wrong here.
Caused by: org.wso2.carbon.user.core.UserStoreException: DB error occurred while checking is existing domain : PRIMARY & tenant id : -1234
Caused by: java.sql.SQLException: Uncaught underlying exception.
Caused by: java.lang.NullPointerException: tuples must be non-null
at org.postgresql.jdbc.PgResultSet.<init>(PgResultSet.java:147)
at org.postgresql.jdbc.PgStatement.createResultSet(PgStatement.java:161)
at org.postgresql.jdbc.PgStatement$StatementResultHandler.handleResultRows(PgStatement.java:213)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2037)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:291)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:432)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:358)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:305)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:291)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:269)
at org.postgresql.jdbc.PgConnection.execSQLUpdate(PgConnection.java:480)
at org.postgresql.jdbc.PgConnection.getTransactionIsolation(PgConnection.java:850)
Please Note: When i try to configure EDB-JDBC driver (edb-jdbc17.jar) with it gives different error. Caused by: java.lang.Exception: Unsupported database: EnterpriseDB. Database will not be created automatically by the WSO2 Registry. Please create the database using appropriate database scripts for the database.
Creating db with scripts did not help.

Spring Hibernate Connection from database not released

I am getting the following error below
Unexpected error
org.springframework.transaction.CannotCreateTransactionException:
**CannotCreateTransactionException:** Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBC
Exception: Could not open connection
Here is the scenario in which it occurs :
I have recently moved some table from mysql to mongo. The code is written in such a way that either data would be taken from mongo/mysql.
The code is written in a method block which is annotated with #Transactional provided by spring framework.
There is hibernate layer which is using transaction provided by spring. c3p0 is the connection pool.
The parameter of connection pool is
hibernate.c3p0.min_size=5
hibernate.c3p0.timeout=1200
hibernate.c3p0.max_size=35
hibernate.c3p0.max_statements=50
The problem comes when we try to pull the data from mongo.Looks like the transaction is not getting closed because of mongo operation.The database connection is not getting released .It reaches the max size defined in the pool.
Tried the query in DB to find out the connection
show status like '%onn%';
Any suggestion to resolve this would really help.
Thanks

JPA fails when retrieving an Oracle Clob into a Java String

Because of the limitations of the VARCHAR2 type in Oracle, namely, its limit of 4000 bytes in size, I want to use the CLOB type for a column in a certain entity. So, after reading the documentation, I declared the field in my JPA entity this way:
#Column
#Lob
private String log;
I don't have any problems persisting this entity, but when I try to retrieve it with a simple SELECT m FROM Meeting m, EclipseLink complains about not being able to convert the type oracle.sql.CLOB to java.lang.String:
javax.persistence.PersistenceException: Exception [EclipseLink-3001]
(Eclipse Persistence Services - 2.5.0.v20130507-3faac2b):
org.eclipse.persistence.exceptions.ConversionException Exception
Description: The object [oracle.sql.CLOB#e9fbb9], of class [class
oracle.sql.CLOB], could not be converted to [class java.lang.String].
Internal Exception: java.lang.IllegalStateException: This web
container has not yet been started
I'm using Eclipselink 2.5.1 as my implementation of JPA. The database is Oracle 10g (10.2.0.3.0) and I'm using ojdbc6.jar as driver
Did you specify the target database platform to use? See Specifying the Database for an Application and Java Persistence API (JPA) Extensions Reference for EclipseLink, Release 2.4 for information. If it is not set, try setting it to Oracle10.

Resources