ClassCastException casting to a OracleConnection in Jdeveloper

Hi all,
Figured somebody on the list may know the answer to this one. Sounds to me like configuration step that I am missing.
I am running jdev 9031
I get a
java.lang.ClassCastException: com.evermind.sql.OrclCMTConnection
at tv.thirdspace.ova.debug.QueryTag.doEndTag(QueryTag.java:132)
at jsps.debug._debug._jspService(debug.jsp:24)
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:139)
at run time when I execute a jsp tag lib.
I am doing the following in the tag lib
try {
Context env = (Context) new InitialContext().lookup("java:comp/env");
ds = (DataSource) env.lookup("jdbc/TestConnectionPool");
}catch (NamingException e) {System.out.println(e.getMessage());}
conn = (OracleConnection)ds.getConnection();
It is failing when I attempt to cast the connection as a OracleConnection.
The data-sources.xml has the following datasource definition
<data-source
class="com.evermind.sql.DriverManagerDataSource"
name="TestConnectionPool"
location="jdbc/TestConnectionPool"
xa-location="jdbc/xa/OracleXADS"
ejb-location="jdbc/TestConnectionPool"
connection-driver="oracle.jdbc.driver.OracleDriver"
username="scott"
password="tiger"
url="jdbc:oracle:thin:@infinity:1521:test"
inactivity-timeout="30"
/>     
What am I missing??
- Manish

In the current version there is a restriction that you can only really have one (diagrammed) Struts configuration per project, as such we disable the option to create a new pageflow in the New gallery. What may be happening is that we're not recognising the fact that the existing xml file is a struts config (maybe the <!DOCTYPE > is wrong / missing? ) so we allow you to add a second and that messes things up.
See:
http://www.oracle.com/technology/products/jdev/howtos/10g/StrutsMultiConfigs/struts_multiconfig_howto.html

Similar Messages

  • ClassCastException casting CallableStatement to OracleCallableStatement

    Im trying to create a ViewObject based on a REF_CURSOR returned by PL/SQL stored procedure OUT parameter.
    I casted the normal CallableStatement to OracleCallableStatement so I can call the OracleCallableStatement.getCursor(index);
    CallableStatement statement = getDbTransaction.createCallableStatement(statementString, DbTransaction.DEFAULT);
    ResultSet rs = ((OracleCallableStatement)statement).getCursor(1);I get a "java.lang.ClassCastException: oracle_jdbc_driver_T4CCallableStatement_Proxy" when I run this piece of code.
    Jdeveloper version is Jdev10.1.3.1 Preview.
    regards,
    Anton

    I got a resolution for this. The reason for this exception is that I got the wrong import for the OracleCallableStatement. The correct import is "import oracle.jdbc.OracleCallableStatement" instead of "import oracle.jdbc.driver.OracleCallableStatement"
    See the related thread:
    Re: Dive into BC4J related  --REF CURSOR (executeQueryForCollection)
    regards,
    Anton

  • ClassCastException casting CallableStatement into OracleCallableStatement

    Well, i have configured Jakarta DBCP 1.1 with Jakarta Tomcat 4.1.29, JDK 1.4.2, with a database Oracle 9i over Win32 Platform.
    Everything works fine if i use Statements and make SQL sentences. But when i try to execute a stored procedure with a callable statement, i need to pass it a CLOB parameter, so i need to cast a CallableStatement into a OracleCallableStatement, to use the Oracle Extensions. This process makes a ClassCastException.
    This process works fine without DBCP, using just a connection, but fails when use DBCP connection pool.
    I have tried to cast the Connection into OracleConnection that i get from the pool, but i get the same error. Also I have checked Connection is not null and connection works.
    Could anyone gimme a solution? Thanx for your help!

    Can't you use method getClob from CallableStatement, and then pass the data to the clob using setCharacterStream(...)?
    BTW, I think DBCP wraps the genuine Oracle classes, which is the reason that your objects are not instances of Oracles classes.

  • ClassCastException in OracleSQLBuilderImpl.class

    Hi,
    I'm trying to run a simple test application on JDeveloper 9.0.5.0.0 using Postgresql as a database. I got the connection working just fine (I can browse the table structure and view table data) and I followed the ADF tutorial to create the test application:
    "Developing a Web Application Using the Default Technology Scope Tutorial"
    However, when I want to run the application I get a ClassCastException in oracle.jbo.server.OracleSQLBuilderImpl in isConnectionAlive().
    I investigated the class file and indeed a cast to an OracleConnection object is done.
    I don't understand how this is supposed to work with third party JDBC drivers. Am I missing something?
    Can anyone shed any light on this?
    Regards,
    Marc.
    NB. If necessary, I can provide the complete stacktrace.

    Steve,
    The question we have then is, If the BC4J configuration indicates SQL flavor is set to "SQL92", and the type map is set to "java" then why is OracleSQLBuilderImpl.class being executed?
    Thanks again,
    Phil Scuderi
    Following is the BC4J version number, the text of the data-source.xml file, and the stack trace.
    ********** We are deploying the application using BC4J version 9.0.3.10.62.
    ********** The date-sources.xml is:
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!DOCTYPE data-sources PUBLIC "Orion data-sources" "http://xmlns.oracle.com/ias/dtds/data-sources.dtd">
    <data-sources>
    <data-source class="com.evermind.sql.DriverManagerDataSource" connection-driver="com.attunity.jdbc.NvDriver" ejb-location="jdbc/AttunityDevelopmentDS" inactivity-timeout="30" location="jdbc/AttunityDevelopmentCoreDS" name="jdev-connection:AttunityDevelopment" password="dianif" pooled-location="jdbc/AttunityDevelopmentPooledDS" url="jdbc:attconnect://atifinad:[email protected]:8880/finaid;" username="atifinad" xa-location="jdbc/xa/AttunityDevelopmentXADS"/>
    </data-sources>
    ********** The exception stack trace is:
    Exception Stack Trace:
    java.lang.ClassCastException: com.attunity.jdbc.NvPreparedStatement
    at
    oracle.jbo.server.OracleSQLBuilderImpl.doStatementSetRowPrefetch(OracleSQLBu
    ilderImpl.java:926)
    at
    oracle.jbo.server.DBTransactionImpl.createPreparedStatement(DBTransactionImp
    l.java:2487)
    at
    oracle.jbo.server.DBTransactionImpl.createReUsePreparedStatement(DBTransacti
    onImpl.java:3234)
    at
    oracle.jbo.server.ViewObjectImpl.getPreparedStatement(ViewObjectImpl.java:63
    23)
    at
    oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:456)
    at
    oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.ja
    va:2593)
    at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:502)
    at
    oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:543)
    at
    oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:2557)
    at
    wsu.finaid.persistence.bc4j.FinAidAwardModuleImpl.getAwardSummary(FinAidAwar
    dModuleImpl.java:74)
    at
    edu.wsu.student.finaid.resource.handler.R_FinAidScholAwdSumHandlerImpl.getAw
    ardSummary(R_FinAidScholAwdSumHandlerImpl.java:82)
    at
    edu.wsu.student.finaid.process.MP_GetAwardSummary.persist(MP_GetAwardSummary
    .java:142)
    at
    oracle.cle.process.PersistingProcess.start(PersistingProcess.java:83)
    at oracle.cle.process.CLEStateMachine.start(CLEStateMachine.java:61)
    at oracle.cle.process.Process.start(Process.java:108)
    at oracle.cle.process.GenericProcess.start(GenericProcess.java:84)
    at oracle.cle.process.ParentProcess.start(ParentProcess.java:226)
    at oracle.cle.process.DisplayGroup.start(DisplayGroup.java:75)
    at oracle.cle.process.CLEStateMachine.start(CLEStateMachine.java:61)
    at oracle.cle.process.Service.start(Service.java:389)
    at
    oracle.clex.process.controller.HttpServletController.doPost(HttpServletContr
    oller.java:422)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:283)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at
    com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.ja
    va:66)
    at
    oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:284)
    at
    com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispa
    tcher.java:539)
    at
    com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletReq
    uestDispatcher.java:285)
    at
    com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDisp
    atcher.java:231)
    at
    oracle.portal.provider.v2.render.http.ResourceRenderer.renderBody(Unknown
    Source)
    at oracle.portal.provider.v2.render.RenderManager.render(Unknown
    Source)
    at oracle.portal.provider.v2.DefaultPortletInstance.render(Unknown
    Source)
    at
    oracle.webdb.provider.v2.adapter.soapV1.ProviderAdapter.showPortlet(Unknown
    Source)
    at
    oracle.webdb.provider.v2.adapter.soapV1.ProviderAdapter.handleHttp(Unknown
    Source)
    at java.lang.reflect.Method.invoke(Native Method)
    at oracle.webdb.provider.v2.adapter.SOAPServlet.doHTTPCall(Unknown
    Source)
    at oracle.webdb.provider.v2.adapter.SOAPServlet.service(Unknown
    Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at
    com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.ja
    va:66)
    at
    oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:284)
    at
    com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispa
    tcher.java:539)
    at
    com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletReq
    uestDispatcher.java:285)
    at
    com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandle
    r.java:771)
    at
    com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:170)
    at
    com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:72)
    at
    EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.ja
    va:802)
    at java.lang.Thread.run(Thread.java:484)

  • How to cast BufferedImage to RichImage

    Hi,
    I have an image of type BufferedImage. How can I show to the user at run time ?. I thought that I can do it using RichImage component but I am facing problem in casting.
    I am using Jdeveloper 12c the page is jsf
    Thanks
    Ahmad

    Dear Ahmad,
    Use below code its tested in my machine.
    import java.io.IOException;
    import sun.misc.BASE64Encoder;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.awt.image.BufferedImage;
    import javax.imageio.ImageIO;
    import oracle.adf.view.rich.component.rich.input.RichInputText;
    public class MainTester2 {
        private RichInputText rimg;
        public void setRimg(RichInputText rimg) {
            this.rimg = rimg;
        public RichInputText getRimg() {
            return rimg;
         * Maroof!
         * Encode image to string
         * @param image The image to encode
         * @param type jpeg, bmp, ...
         * @return encoded string
        public static String encodeToString(BufferedImage image, String type) {
            String imageString = null;
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            try {
                ImageIO.write(image, type, bos);
                byte[] imageBytes = bos.toByteArray();
                BASE64Encoder encoder = new BASE64Encoder();
                imageString = encoder.encode(imageBytes);
                bos.close();
            } catch (IOException e) {
                e.printStackTrace();
            return imageString;
        public static void main (String args[]) throws IOException { 
            /* Test image to string and string to image start */
            BufferedImage img = ImageIO.read(new File("C:\\Users\\maroof\\Downloads\\TR3.jpg"));
            BufferedImage newImg;
            String imgstr;
            imgstr = encodeToString(img, "png");
            System.out.println(imgstr);
            RichInputText imgTxt = new RichInputText();
            imgTxt.setValue(imgstr);
            System.out.println("Out of new == "+imgTxt.getValue().toString());
    Maroof

  • How to Use the Oracle Security (dynamic connection)  ADF Struts ?

    Hello All
    I need to use the security from Oracle in my application, I mean I use a connection to my DB , but This connection would have to be dynamic, I have to create different users with grants to my tables , and The users would have to connect to my application directly , I read something in the forum , but I'm not sure if it's possible , because I have appmodule created and they are connected to a same user. I need this be dynamic Could I use do This?. Someone have the same requirement?. Someone can help me , pleaser, Urgent!!
    Thanks all.
    Regards.

    Hello
    We were banging our heads on a similar thing, maybe this will help
    We needed to convert the wrapped connection to an OracleConnection so that we could do a proxy switch, but maybe you could apply it to your situation anyway
    1-you have to convert the Connection object to an OracleConnection in order to use the method that does the proxy switch
    The method to do this is getInnermostDelegate()
    Once you call this method, you get a new Connection object that can be cast to an OracleConnection object
    See below for the snippet of code
    // now switch the user and reselect
    if (conn instanceof DelegatingConnection) {
    properties.put("PROXY_USER_NAME","peter/peter");
    oraConn =((DelegatingConnection)conn).getInnermostDelegate();
    if (oraConn == null)
    out.println("oraConn is null\n");
    ((OracleConnection)oraConn).openProxySession(OracleConnection.PROXYTYPE_USER_NAME,properties);
    2-you have to put a setting in the xml file in conf/Catalina/localhost that allows you to call the getInnermostDelegate() method
    By default, Tomcat does not allow you to call this method, it will always return null
    You have to change the xml to allow it to return an object
    It seems that WebSphere and Tomcat both frown on vendor-specific methods that do not comply with the JDBC standards, but do allow it
    Here is the setting:
    <parameter>
    <!-- NOTE: This is necessary to enable access to the Oracle connection object -->
    <name>accessToUnderlyingConnectionAllowed</name>
    <value>true</value>
    </parameter>
    Note, this setting was also put in the conf/server.xml file
    Thanks
    Peter

  • NullPointer from constructor of oracle.sql.ARRAY

    This is a strange one, I'm hoping someone has seen this before.
    I'm seeing a nullpointer exception from the contructor of ARRAY(ArrayDescriptor, Connection, Object)
    This occurs when I'm trying to make a call from an application module to a stored procedure with custom database types.
    This seems to work fine in the embedded OC4J instance but fails when deployed to an application server on linux. The version is 10.1.2.
    thanks for your help.
    Joel
    Here is the part of the stack trace:
    java.lang.NullPointerException
         at oracle.jdbc.driver.PhysicalConnection.isDescriptorSharable(PhysicalConnection.java:5078)
         at com.evermind.sql.OracleConnectionBCELProxy__oracle_jdbc_driver_T4CConnection__SQLBCELProxy.isDescriptorSharable()
         at oracle.sql.ARRAY.<init>(ARRAY.java:118)
         at fastenal.website.model.services.products.ProductsServiceImpl.getPrices(ProductsServiceImpl.java:121)
    and relevant source code:
    public ProductPrices[] getPrices(String[] skus, Number accountNumberId, Number userId, Number catalogId){
    OracleCallableStatement st = null;
    try {
    Connection con = getCurrentConnection();
    System.out.println(con.getClass().toString() );
    // Create the type object
    Map map = con.getTypeMap();
    //map.put("SKU_DETAIL_TYPE", Class.forName("fastenal.integration.ws.products.ProductDetailSqlType"));
    map.put("WEB_PRICE_TYPE", ProductPriceSqlType.class);
    con.setTypeMap(map);
    ProductPriceSqlType[] pricesSql = new ProductPriceSqlType[skus.length];
    for (int i = 0; i < skus.length; i++) {
    pricesSql[i] = new ProductPriceSqlType("WEB_PRICE_TYPE", 0d, 0d, 0d, skus, null);
    //ProductDetailSqlType productsSQL = new
    ArrayDescriptor arrayDesc = ArrayDescriptor.createDescriptor("WEB_PRICE_TYPE_ARRAY", con);
    ARRAY prices = new ARRAY(arrayDesc, con, pricesSql);
    st = (OracleCallableStatement)getDBTransaction().createCallableStatement( PRICING_PLSQL
    , DBTransaction.DEFAULT);
    st.registerOutParameter(1, Types.ARRAY, "WEB_PRICE_TYPE_ARRAY");
    st.setARRAY(2, prices);
    //st.setString(3, strAccountNumber);
    if (accountNumberId!=null){
    st.setInt(3, accountNumberId.intValue() );
    }else{
    st.setNull(3, Types.NUMERIC );
    if (userId!=null){
    st.setInt(4, userId.intValue() );
    }else{
    st.setNull(4, Types.NUMERIC );
    if (catalogId!=null){
    st.setInt(5, catalogId.intValue() );
    }else{
    st.setNull(5, Types.NUMERIC );
    st.execute();
    prices = st.getARRAY(1);
    Object[] retVals = (Object[])prices.getArray();
    ProductPrices[] prodPrices = new ProductPrices[retVals.length];
    for (int i = 0; i < retVals.length; i++) {
    ProductPrices currPrices = new ProductPrices();
    ProductPriceSqlType sqlType = (ProductPriceSqlType)retVals[i];
    Double customPrice;
    if (sqlType.getCustomPrice()!=null){
    customPrice = new Double(sqlType.getCustomPrice().doubleValue() );
    }else{
    customPrice=null;
    Double promoPrice;
    if (sqlType.getPromoPrice()!=null){
    promoPrice = new Double(sqlType.getPromoPrice().doubleValue() );
    }else{
    promoPrice=null;
    Double wholeSalePrice;
    if (sqlType.getWholeSalePrice()!=null){
    wholeSalePrice = new Double(sqlType.getWholeSalePrice().doubleValue() );
    }else{
    wholeSalePrice=null;
    currPrices.setCustomPrice( customPrice );
    currPrices.setPromotionalPrice(promoPrice );
    currPrices.setWholesalePrice(wholeSalePrice);
    currPrices.setSku(sqlType.getSku());
    currPrices.setPromoEndDate(sqlType.getPromoEndDate());
    prodPrices[i] = currPrices;
    }//end for
    return prodPrices;
    }catch (SQLException s) {
    throw new JboException(s);
    }//end catch
    finally {
    if (st != null) try { st.close(); } catch (SQLException s2) {}
    }//end finally
    * Helper method to get the current connection.
    * As specified by
    * re:BC4J: How get Connection from Application Module
    * @return
    private Connection getCurrentConnection() {
    Statement st = null;
    try {
    st = getDBTransaction().createStatement(0);
    return st.getConnection();
    catch (SQLException s) {
    s.printStackTrace();
    return null;
    finally {
    if (st != null) try { st.close(); } catch (SQLException s2) {}

    Avi, thanks for your response. The connection is obtained from a BC4J appmod, which ultimately comes from a pooled datasource.
    When I look at the implementation class in the embeded OC4J environment it is com.evermind.sql.OracleConnectionBCELProxy__com_evermind_sql_OrionCMTConnection__SQLBCELProxy. The call to ARRAY works in this environment.
    On the application server the runtime implementation of the connection is com.evermind.sql.ConnectionBCELProxy__com_evermind_sql_OrionCMTConnectionFinalize__SQLBCELProxy. This fails with the exception in the original post.
    In both environments I can successfuly cast to an OracleConnection so I'm pretty sure both implementaion classes are subclasses of OracleConnection.
    Both environments are 10.1.2.
    thanks for your help so far.
    jk

  • How to use the Oracle 10g JDBC OCI driver in JBoss ?

    Greetings,
    I deployed ojdbc14.jar in JBoss and I created an Oracle datasource. I have the following questions:
    1. In the datasource descriptor file I have:
    <connection-url>jdbc:oracle:oci:@(description=(address=(host=localhost)(protocol=tcp)(port=1521))(connect_data=(SERVICE_NAME=xe)))</connection-url>
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    Is it enough in order to use the Oracle 10g JDBC OCI driver ?
    2. After having looked-up the datasource and created a connection, the classe of these objects are org.jboss.resource.adapter.jdbc.WrapperDataSource and, respectivelly, org.jboss.resource.adapter.jdbc.WrappedConnection. How can I have access to oracle.jdbc.oci and oracle.jdbc.pool packages ?
    Many thanks in advance,
    Nicolas

    Hello
    We were banging our heads on a similar thing, maybe this will help
    We needed to convert the wrapped connection to an OracleConnection so that we could do a proxy switch, but maybe you could apply it to your situation anyway
    1-you have to convert the Connection object to an OracleConnection in order to use the method that does the proxy switch
    The method to do this is getInnermostDelegate()
    Once you call this method, you get a new Connection object that can be cast to an OracleConnection object
    See below for the snippet of code
    // now switch the user and reselect
    if (conn instanceof DelegatingConnection) {
    properties.put("PROXY_USER_NAME","peter/peter");
    oraConn =((DelegatingConnection)conn).getInnermostDelegate();
    if (oraConn == null)
    out.println("oraConn is null\n");
    ((OracleConnection)oraConn).openProxySession(OracleConnection.PROXYTYPE_USER_NAME,properties);
    2-you have to put a setting in the xml file in conf/Catalina/localhost that allows you to call the getInnermostDelegate() method
    By default, Tomcat does not allow you to call this method, it will always return null
    You have to change the xml to allow it to return an object
    It seems that WebSphere and Tomcat both frown on vendor-specific methods that do not comply with the JDBC standards, but do allow it
    Here is the setting:
    <parameter>
    <!-- NOTE: This is necessary to enable access to the Oracle connection object -->
    <name>accessToUnderlyingConnectionAllowed</name>
    <value>true</value>
    </parameter>
    Note, this setting was also put in the conf/server.xml file
    Thanks
    Peter

  • Proxy Authentication with JDBC Datasource instead of JDBC URL?

    Hello,
    A requirement for my current project (ADF 10g) is that a user should be able to log in with his regular database account. For the moment, this is implemented using Proxy Authentication, as described in the following article:
    http://blogs.oracle.com/jheadstart/2008/01/using_proxy_authentication.html
    For now, we are using a JDBC URL defined in the application module config for the BC. In short: a ProxyAuthConnectionPoolManager class was created that overrides the default ConnectionPoolManagerImpl. The getConnection method has been overridden to create a standard connection (with the username/pw defined on the AM), and additionally, create a proxy connection within this connection with the specific user credentials. The (simplified) code:
        public Connection getConnection(String key, String url, Properties props, String username, String pwd) {
            // first fetch a default connection from the pool through the superclass
            Connection connection = super.getConnection(key, url, props, username, pwd);
            // cast into an OracleConnection
            OracleConnection oraConnection = (OracleConnection) connection;
                // close any proxy sessions that would still exist on the connection
                if (oraConnection.isProxySession()) oraConnection.close(OracleConnection.PROXY_SESSION);
                // get a handle on the session scope
                Map sessionScope = ADFContext.getCurrent().getSessionScope();
                if (sessionScope != null) {
                    // find the user object in the session (the account the user logs in with)
                    ProxyAuthUser user = (ProxyAuthUser) sessionScope.get(ProxyAuthUser.JHS_USER_KEY);
                    if (user != null) {
                        // create a property map with the end user credentials
                        Properties proxyProps = new Properties();
                        proxyProps.put(OracleConnection.PROXY_USER_NAME, user.getDbUsername() + "/" + user.getDbPassword());
                        proxyProps.put(OracleConnection.PROXY_USER_PASSWORD, user.getDbPassword());
                        // open the proxy session
                        oraConnection.openProxySession(OracleConnection.PROXYTYPE_USER_NAME, proxyProps);
                return oraConnection; 
        }Now, this works perfectly when using a JDBC URL. But when I switch the JDBC Datasource the ProxyAuthConnectionPoolManager class is not called anymore. This is all done in code in the Application Server. While using a JDBC Datasource is actually necessary: otherwise for each environment (dev, test, production,...) a different WAR file is needed.
    What class can I override with code similar to the piece above, to open a proxy connection inside the existing connection, when using a JDBC Datasource?
    Your help would be greatly appreciated!
    Chris

    Hello Krasimir,
    Frank Nimphius gave me the solution to this problem. The prepareSession is indeed the best place to put the code:
       private OracleConnection oconn = null;
       public void prepareSession(SessionData SessionData) {
          super.prepareSession(SessionData);
          oconn = ((PrxyTransactionImpl)this.getDBTransaction()).getPrxyConnection();
          // Specify the user that connects through the proxy user and its roles
          Properties prop = new Properties();
          prop.put(OracleConnection.PROXY_USER_NAME,"hr");
          prop.put(OracleConnection.PROXY_USER_PASSWORD,"hr");
          //prop.put(OracleConnection.PROXY_ROLES, roles);
          // Open the proxy session (DB-authenticated users)
          try {
             oconn.openProxySession(OracleConnection.PROXYTYPE_USER_NAME, prop);
          catch (SQLException e) {
             // Close the connection, to avoid connection to remain open after exception
             oconn.abort();
             e.printStackTrace();
       }But Frank also created the following helper classes to extend the ADF BC behavior:
       package oracle.sample.dbprxy.adfbc;
       import oracle.jbo.server.DBTransactionImpl2;
       import oracle.jbo.server.DatabaseTransactionFactory;
        * TransactionFactory that returns PrxTransactionImpl, which is a subclass of
        * DBTransactionImpl2
        * @author Frank Nimphius
       public class PrxyDatabaseTransactionFactory extends DatabaseTransactionFactory {
          public PrxyDatabaseTransactionFactory() {
             super();
           * Override the create method to return an instance of PrxyTransactionImpl instead
           * of DBTransactionImpl2
           * @return PrxyTransactionImpl
          public DBTransactionImpl2 create() {
             return new PrxyTransactionImpl();
       package oracle.sample.dbprxy.adfbc;
       import oracle.jbo.server.DBTransactionImpl2;
       import oracle.jdbc.internal.OracleConnection;
       public class PrxyTransactionImpl extends DBTransactionImpl2 {
          public PrxyTransactionImpl() {
             super();
           * The DBTransactionImpl2 does not expose the connection in a public
           * method. This class is a wrapper to expose the connection to the
           * BC app, so it can be accessed in the ApplicationModuleImpl class
           * @return OracleConnection - SQL Connection
          public OracleConnection getPrxyConnection() {
             return (OracleConnection) this.getJdbcConnection();
       }In the configuration of your Application Module, you have to set the property "TransactionFactory" (normally the last one in the list) to oracle.sample.dbprxy.adfbc.PrxyDatabaseTransactionFactory. This way, the DBTransaction() of your AM will have a getPrxyConnection() method and you will have the connection at your disposal. You won't need the createPreparedStatement in your code anymore.
    To close the connection, this is the code behind my "logout button" on the backing bean. Application Module Pooling and Connection Pooling will take care of the rest for you!
       ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext();
       HttpSession session = (HttpSession)ectx.getSession(false);
       session.invalidate();Another thing: be sure to set the internalconnection property to a different JDBC Datasource (or file based) than the one you are using to connect to the database (the default value). Otherwise connection pooling will be confused and there will be too much pending database connections.
    This works for me, all sessions are closed in time and logging out seems secure. I do not have my complete, adjusted code here at my disposal, but next week, when I'm back at work, I'll have a look to see if there is anything I forgot to mention. So this should get you started, but I'll keep you posted!
    A huge thank you to Frank again for helping me (/us) out with this problem!! And sorry I forgot to post the answer here sooner. I was too busy with testing it. :-)
    Regards,
    Chris

  • Simple RMI problem

    I am trying to set up a client server RMI connection, but i get the following error when running the server. I am new to using RMI so any help would be great, thanks so much,
    Fred
    Exception in thread "main" java.lang.ClassCastExcepti
    cast to IMServer
    at OutwardFacing.main(OutwardFacing.java:14)
    here is my code:
    import java.rmi.*;
    import java.rmi.registry.LocateRegistry;
    import java.rmi.registry.Registry;
    public class OutwardFacing {
         public static void main(String[] args)
         //get the remote object from the registry
              try
         String url = "//localhost/server1";
    **14**     IMServer server1 = (IMServer)Naming.lookup(url);
         System.out.println("Got remote object");
         server1.Register("fred", "password");
         server1.ListRegistered();
         catch (RemoteException exc)
         System.out.println("Error in lookup: " + exc.toString());
         catch (java.net.MalformedURLException exc)
         System.out.println("Malformed URL: " + exc.toString());
         catch (java.rmi.NotBoundException exc)
         System.out.println("NotBound: " + exc.toString());
    }

    Cast the object you're looking up to the remote interface it implements, not to the type of the implementation class.

  • ClassCastException  Jdeveloper

    Hi,
    I am working with Oracle Jdeveloper 10g (9.0.5) and Oracle Database 10g.
    I am getting the following exception
    java.lang.ClassCastException
         at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:112)
    I think the problem is casting (OracleConnection) Connection
    What could be the reason?
    What can i do to solve this problem?
    Thanks

    Hi, the stack is:
    java.lang.ClassCastException
         at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:112)
         at mipaquete.generacion.fdf2pdf.AccesoBD.consultasBDXML(AccesoBD.java:226)
         at mipaquete.generacion.fdf2pdf.AccesoBD.cargarDocumeto(AccesoBD.java:338)
         at mipaquete.generacion.fdf2pdf.GestorImpresionFacade.generarPDFDesdeXML(GestorImpresionFacade.java:437)
         at mipaquete.generacion.fdf2pdf.DocumentoAImprimir.generarPDFMultipleXML(DocumentoAImprimir.java:379)
         at mipaquete.generacion.GeneradorPDFXMLMultiple.proccessRequest(GeneradorPDFXMLMultiple.java:173)
         at mipaquete.generacion.GeneradorPDF.doPost(GeneradorPDF.java:44)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:604)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Unknown Source)
    The code source is:
    Connection conexion;
    StructDescriptor descriptorTipo =
    StructDescriptor.createDescriptor("mi_tipo", conexion);
    The datasource is:
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!DOCTYPE data-sources PUBLIC "Orion data-sources" "http://xmlns.oracle.com/ias/dtds/data-sources.dtd">
    <data-sources>
    <data-source name="jdev-connection-miconexion" class="com.evermind.sql.DriverManagerDataSource" location="jdbc/miconexionCoreDS" xa-location="jdbc/xa/miconexionXADS" ejb-location="jdbc/miconexionDS" pooled-location="jdbc/miconexionPooledDS" connection-driver="oracle.jdbc.driver.OracleDriver" username="" password="" url="jdbc:oracle:thin:@mihost:1523:MICONEXION" inactivity-timeout="30"/>
    </data-sources>

  • ClassCastException with OracleConnection in Oracle 9i

    I have a piece of code that works perfectly with Oracle 8i and JDK 1.3.
    Now I've migrated to Oracle 9i and JDK 1.4. I continue working with tomcat and I've configured server.xml file (some changes about 'url' and 'username').
    I get a ClassCastException when I try to make a explicit cast to OracleConnection of the connection object recovered. This is the code:
    public class CargadorRecursos {
         public Connection devuelveConexion()
              throws javax.naming.NamingException, SQLException {
              Context envContext = devuelveContexto();
              DataSource ds = (DataSource) envContext.lookup("jdbc/prosegur");
              Connection conn = ds.getConnection();
              return conn;
    in another classes I do:
    OracleConnection conn = (OracleConnection) CargadorRecursos.getCargador().devuelveConexion();
    and then the ClassCastException is raised in the web browser.
    Please, help.

    Cast class exception means you are trying to cast an object to something that it can't be case too.
    You can determine the actual class of an instance by doing the following...
    System.out.println("class=" + myinstance.getClass().getName());
    Once you know the class that actually is being used you can determine the course of action to take...
    1. It isn't the class that you think it is, something is wrong with your code.
    2. Something changed outside of your code and you will have to code around the problem.
    3. Class loaders are being used and you are using class instances from two different class loaders - use the same class loader.

  • Java.lang.ClassCastException: oracle.xml.parser.v2.XMLText cannot be cast to org.w3c.dom.Element

    Hello
    I am getting java.lang.ClassCastException: oracle.xml.parser.v2.XMLText cannot be cast to org.w3c.dom.Element error. This code is in java which is present in java embedding.
    The SOA is parsing the xml in java code using oracle.xml.parser.v2 . This wont be a problem if the SOA uses default w3c DOM parser. How do i force SOA to use w3c DOM parser.
    Is there any thing i can do with class loading?
    Kindly help.
    Regards
    Sharat

    Can you paste your java code here ? I assume, you must have tried type-casting.

  • Cause: java.lang.ClassCastException...can not be casted to ModuleLocalHome

    Bom Dia
    Nesta solução NF-e do B2B  Outbound Attachment +Body  eu tive um problema ao testar o Module Gui  gerei o pacote .ear  fiz o deploy do mesmo no J2ee e
    acontece um erro quando testo o envio do e-mail
    Message processing failed. Cause: java.lang.ClassCastException: class com.sap.sdn.nfe.SetAttachmentNameLocalHomeImpl0_0 can not be casted to ModuleLocalHome or SModuleLocalHome
    1 - já tirei os .jar de referencia do ".ear"(Extrai usando o WinZip) mais não funcionou...
    .jar extraido do .EAR antes do deploy..!
    aii_af_cci.jar
    aii_af_ms_api.jar
    aii_af_trace.jar
    aii_af_cpa.jar
    aii_af_ms_spi.jar
    aii_af_mp.jar
    aii_af_svc.jar
    Alguém teria alguma dica doque poderia estar ocorrendo..?
    Agradeço desde já
    RONALDO DE MORAES

    Roberti ...,
    Eliminando as classes geradas e ajustando para as classes standard...!!
    Existiam alguns erros.....com.sap.sdn.nfe.SetAttachmentNameLocalhome quando na verdade deveria ser isso                                 com.sap.aii.af.mp.module.ModuleLocalHome
    esse erro  só notei quando  olhei  a doc   postada pelo  Roberti ...
    http://wiki.sdn.sap.com/wiki/pages/editpage.action?pageId=233474286
    Obrigado ...pela força Robert e Henrique

  • Exception:org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper cannot be cast to oracle.jdbc.OracleConnection

    Hi All,
    i am using jdev version 11.1.1.5.0
    and deployed my Adf application on Apache Tomcat 6.0.
    in my use case i have created simple adf application using adf business component. create a vo based on eo and drag-drop on jspx page.
    i have created JNDI data source in Apache server using edit context.xml file and add following line-
    <Resource name="jdbc/TestDB" auth="Container"
                  type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
                  url="jdbc:oracle:thin:@localhost:1521:dst"
                  username="jagrandb" password="jagrantest" maxActive="20" maxIdle="10"
                  maxWait="-1"  accessToUnderlyingConnectionAllowed="true" />
    3.using same data source in my adf applicatioin as -
      right click on AM --> Configuration-->edit-->select connection type jdbc datasource  -->java:/comp/env/jdbc/TestDB  
    4. after that i have deployed my application on apace server but when i have running application i have got following error-
    org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper cannot be cast to oracle.jdbc.OracleConnection
    i have goggling and find  following solution-
    oracle.jdbc.driver.OracleConnection delConn = (oracle.jdbc.driver.OracleConnection) ((org.apache.tomcat.dbcp.dbcp.DelegatingConnection)c_stmt.getConnection()).getDelegate();
    but my problem is that i'm using Adf Business Component so where i set following type casting.
    Is there any method on ADF BC which handle JNDI Data source setting or any other way to do this.
    thanks in Advance
    Manish

    Hi dvohra21,
    thanks for reply.
    i don't understand where i go to set accessToUnderlyingConnectionAllowed =true
    i have already set this property on context.xml file
    <Resource name="jdbc/TestDB" auth="Container"
                  type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
                  url="jdbc:oracle:thin:@localhost:1521:dst"
                  username="jagrandb" password="jagrantest" maxActive="20" maxIdle="10"
                  maxWait="-1"  accessToUnderlyingConnectionAllowed="true" />
    any other place where i set this propery
    please elaborate this steps how to Configuree DBCP

Maybe you are looking for