0

I am deploying project on wildfly8 which required java7. I m migrating project from jboss5 to wildfly8 so code in jboss5 is

PreparedStatement wrappedStatement = (PreparedStatement) ((org.jboss.resource.adapter.jdbc.WrappedPreparedStatement)connection.prepareStatement(sql)).getUnderlyingStatement();

so i changed it by...

PreparedStatement wrappedStatement = (PreparedStatement) ((org.jboss.jca.adapters.jdbc.jdk7.WrappedPreparedStatementJDK7)connection.prepareStatement(sql)).getUnderlyingStatement();

but now I get the error

org.jboss.jca.adapters.jdbc.jdk7.WrappedPreparedStatementJDK7 cannot be cast to org.jboss.jca.adapters.jdbc.jdk7.WrappedPreparedStatementJDK7

Jørgen R
  • 10,568
  • 7
  • 42
  • 59
Aditi
  • 119
  • 8

2 Answers2

1

You required MANIFEST.MF file in your ear project. I put MANIFEST.MF file contains

Dependencies: org.jboss.ironjacamar.jdbcadapters, com.oracle7

with one new line. save this file in METAINF of ear project.

1)Delete ironjacamar-jdbc-..final.jar and ojdbc.jar from lib directory of you project. 2)These jars are already present in modules/ folder of wildfly8 (Ofcourse ojdbc*.jar is configured by user). 3)Dependencies: name is same as in module.xml files i.e.

<module xmlns="urn:jboss:module:1.1" name="org.jboss.ironjacamar.jdbcadapters"> 

So you have to put proper name of module.

4)com.oracle7 is driver name configuration of ojdbc7.jar in wildfly8. You can put your desired name which you are write in standalone.xml in driver tag.

I thought this error is related to class loading jars. But i faced new error java.sql.SQLException: You cannot set autocommit during a managed transaction! pls help me.

Aditi
  • 119
  • 8
0

Replace all your casts and statement wrapper by

PreparedStatement statement = connection.prepareStatement(sql);

http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#prepareStatement(java.lang.String)

In your code you should avoid using JBoss/Wildfly specific code.

Your application must also not include JBoss and Java EE libraries in your .ear or .war. This will avoid class cast exceptions from the same class loaded by 2 different class loaders.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
deleze
  • 661
  • 1
  • 7
  • 8
  • I changed it and my error was change i.e. org.jboss.jca.adapters.jdbc.jdk7.WrappedPreparedStatementJDK7 cannot be cast to oracle.jdbc.OraclePreparedStatement – Aditi Feb 12 '15 at 12:11