org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6 cannot be cast to org.postgresql.PGConnection

620 views Asked by At

Within a Stateless bean I m trying to insert into a table which has an OID field. Please find the snippet below:

DataSource dataSource = (DataSource) context.lookup(JNDI_NAME);
Connection connection = dataSource.getConnection();

PreparedStatement statement = connection.prepareStatement(sql.toString());

byte[] streamOutput = responseData.getBytes();
LargeObjectManager largeObjectManager = ((org.postgresql.PGConnection)connection).getLargeObjectAPI();
long oid = largeObjectManager.createLO(LargeObjectManager.READ | LargeObjectManager.WRITE);
LargeObject largeObject = largeObjectManager.open(oid, LargeObjectManager.WRITE);
largeObject.write(streamOutput);
largeObject.close();

I m getting the below exception in LargeObjectManager largeObjectManager = ((org.postgresql.PGConnection)connection).getLargeObjectAPI();

org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6 cannot be cast to org.postgresql.PGConnection : java.lang.ClassCastException: org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6 cannot be cast to org.postgresql.PGConnection

The Stateless bean's TransactionManagementType is set to Container.

I m using Postgresql 9.1 and JBoss AS7.1

Can somebody please help me??

1

There are 1 answers

0
James R. Perkins On BEST ANSWER

Generally this means you have two different libraries on your class path. Make sure you haven't included a PostgreSQL library in your deployment.