webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  getConnection from PoolConnection

    Posted Mon November 26, 2001 11:53 AM

    Hi.
    I get ClassCastException:
    //------------------------------------------- TConnection connection = tConnectionPool.getConnection();
    if(connection == null) {
    System.out.println(“connection = null”);
    }
    //System.out.println(connection.getClass());
    System.out.println(“debag = after connection”);

    TXMLObjectAccessor xmlObjectAccessor =
    (connection).newXMLObjectAccessor(TAccessLocation.newInstance( “sailing” ),TJDOMObjectModel.getInstance() );

    System.out.println(“debag = after accessor”);
    //-------------------------------------------


    Exception in thread “main” java.lang.ClassCastException: com.softwareag.tamino/db.API.accessor.TXMLObjectAccessorImpl
    at com.softwareag.tamino.db.API.connection.TConnectionWrapper.newXMLObjectAccessor(TConnectionWrapper.java:67)
    at TestPool.main(TestPool.java:73)

    I can not do:
    ((TConnectionWrapper) connection).newXMLObjectAccessor(…
    because TConnectionWrapper is not public class.

    What is wrong?
    Please hellp me.


    #webMethods-Tamino-XML-Server-APIs
    #webMethods
    #API-Management


  • 2.  RE: getConnection from PoolConnection

    Posted Tue November 27, 2001 01:19 PM

    I’m not sure we’re using the same version of the API, but this code works for me with Version 3.1.0.2 of the API.

    code:

    TConnection myConnection = null;
    TConnectionPoolManager myPoolManager = TConnectionPoolManager.getInstance();
    if (myPoolManager.hasPool(“POOL_NAME”)) {
    myConnection = myPoolManager.getConnection(“POOL_NAME”);
    }
    else {
    System.out.println(“Connection Pool POOL_NAME is not defined - check ManagedConnectionPools.xml”);
    System.exit(0);
    }

    You need to define a connection pool in a file called “ManagedConnectionPools.xml” and this must be available in classpath. The contents look like this:

    code:



    http://server/tamino/database
    user
    password
    2
    5
    900




    #webMethods
    #webMethods-Tamino-XML-Server-APIs
    #API-Management


  • 3.  RE: getConnection from PoolConnection

    Posted Thu November 29, 2001 10:08 AM

    I use version 3.1.0.2
    I have not problem with get connection,
    it throw ClassCastException when is createed XMLObjectAccessor.

    //---------------------------------------------
    System.out.println(“debag = after connection”);
    TXMLObjectAccessor xmlObjectAccessor =
    connection.newXMLObjectAccessor(TAccessLocation.newInstance( “sailing” ),TJDOMObjectModel.getInstance() );

    System.out.println(“debag = after accessor”);
    //---------------------------------------------

    Some problem is in class TConnectionWrapper.
    Method newXMLObjectAccessor create TXMLObjectAccessor instance but then propabli
    cast txmlobjectaccessor to another class or inerface.(throw ClassCastException)


    #webMethods-Tamino-XML-Server-APIs
    #API-Management
    #webMethods


  • 4.  RE: getConnection from PoolConnection

    Posted Thu November 29, 2001 03:45 PM

    My thinking was that if your TConnection is not initialized correctly (for whatever reason) then when you invoke its “newXMLObjectAccessor()” method you might get a problem. In your first code snippet you wrote:

    code:

    TConnection connection = tConnectionPool.getConnection();


    but in the new API Documentation I don’t see this as a documented way of creating a TConnection object (getConnection() is a method of TConnectionPoolManager and takes a String argument).
    I can continue my example code like this:

    (follows on from creating myConnection…)
    // Build an XMLObjectAccessor
    TXMLObjectAccessor xmlObjectAccessor = myConnection.newXMLObjectAccessor(TAccessLocation.newInstance( DATABASE_COLLECTION ),
    TJDOMObjectModel.getInstance() );
    System.out.println(“debug = after accessor”);

    and this works. Sorry if it doesn’t help you.
    Maybe you could post your complete source code?

    [This message was edited by Bill Leeney on 29 Nov 2001 at 15:25.]


    #API-Management
    #webMethods-Tamino-XML-Server-APIs
    #webMethods