arunrathnakumar
arunrathnakumar

Reputation: 45

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

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??

Upvotes: 0

Views: 629

Answers (1)

James R. Perkins
James R. Perkins

Reputation: 17780

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

Upvotes: 1

Related Questions