BC4J, disconnecting

I'm using data web beans in my jsp application. When getting a request from a new client a new database session is created. How can I disconnect idle sessions from the bean itself after closing the browser or after some period of inactivity?

We also have the same issue of JDBC connection to the database is open even after using appModule.getTransaction().disconnect().
This is a very critical issue as we are noticing that, as the number of users increases, the number of processes on the database are increasing and not getting killed.
Any help from JDEV team.
Virinchi

Similar Messages

  • Bc4j error after database disconnect

    I'm running a bc4j web application in oc4j 9.0.3. If for some reason the application module is disconnected from the database (e.g. a database restart), I get the a connection reset by peer error the next time the application tries to get an application module instance. This is apparently happening during rollback (even though I'm sure there were no open transactions). Does anybody have some suggestions??
    thanks, Cor
    the error I get is:
    JBO-30003: The application pool (AMvseLocal) failed to checkout an application module due to the following exception:
    oracle.jbo.DMLException: JBO-26066: Error during rollback.
         at oracle.jbo.server.DefaultTxnHandlerImpl.handleRollback(DefaultTxnHandlerImpl.java:153)
         at oracle.jbo.server.DBTransactionImpl.doRollback(DBTransactionImpl.java:3657)
         at oracle.jbo.server.DBTransactionImpl.rollback(DBTransactionImpl.java:1826)
         at oracle.jbo.server.ApplicationModuleImpl.resetState(ApplicationModuleImpl.java:3156)
         at oracle.jbo.server.ApplicationModuleImpl.resetState(ApplicationModuleImpl.java:3145)
         at oracle.jbo.server.DBTransactionImpl.disconnect(DBTransactionImpl.java:3971)
         at oracle.jbo.server.DBTransactionImpl2.disconnect(DBTransactionImpl2.java:306)
         at oracle.jbo.server.DBTransactionImpl.disconnect(DBTransactionImpl.java:4108)
         at oracle.jbo.common.ampool.DefaultConnectionStrategy.disconnect(DefaultConnectionStrategy.java:328)
         at oracle.jbo.common.ampool.ApplicationPoolImpl.disconnect(ApplicationPoolImpl.java:2979)
         at oracle.jbo.common.ampool.ApplicationPoolImpl.recycleUnreferencedInstance(ApplicationPoolImpl.java:1586)
         at oracle.jbo.common.ampool.ApplicationPoolImpl.doCheckout(ApplicationPoolImpl.java:1386)
         at oracle.jbo.common.ampool.ApplicationPoolImpl.useApplicationModule(ApplicationPoolImpl.java:2062)
         at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:398)
         at oracle.jbo.http.HttpSessionCookieImpl.useApplicationModule(HttpSessionCookieImpl.java:230)
         at oracle.jbo.html.jsp.datatags.ApplicationModuleTag.doStartTag(ApplicationModuleTag.java:193)
         at login.jspService(_login.java:98)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at sphinx.vse.filter.AuthentifiedFilter.doFilter(AuthentifiedFilter.java:67)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:560)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:479)
    ## Detail 0 ##
    java.sql.SQLException: E/A-Exception: Connection reset by peer: socket write error
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:187)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:229)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:342)
         at oracle.jdbc.driver.OracleConnection.rollback(OracleConnection.java:1373)
         at oracle.jbo.server.DefaultTxnHandlerImpl.handleRollback(DefaultTxnHandlerImpl.java:139)
         at oracle.jbo.server.DBTransactionImpl.doRollback(DBTransactionImpl.java:3657)
         at oracle.jbo.server.DBTransactionImpl.rollback(DBTransactionImpl.java:1826)
         at oracle.jbo.server.ApplicationModuleImpl.resetState(ApplicationModuleImpl.java:3156)
         at oracle.jbo.server.ApplicationModuleImpl.resetState(ApplicationModuleImpl.java:3145)
         at oracle.jbo.server.DBTransactionImpl.disconnect(DBTransactionImpl.java:3971)
         at oracle.jbo.server.DBTransactionImpl2.disconnect(DBTransactionImpl2.java:306)
         at oracle.jbo.server.DBTransactionImpl.disconnect(DBTransactionImpl.java:4108)
         at oracle.jbo.common.ampool.DefaultConnectionStrategy.disconnect(DefaultConnectionStrategy.java:328)
         at oracle.jbo.common.ampool.ApplicationPoolImpl.disconnect(ApplicationPoolImpl.java:2979)
         at oracle.jbo.common.ampool.ApplicationPoolImpl.recycleUnreferencedInstance(ApplicationPoolImpl.java:1586)
         at oracle.jbo.common.ampool.ApplicationPoolImpl.doCheckout(ApplicationPoolImpl.java:1386)
         at oracle.jbo.common.ampool.ApplicationPoolImpl.useApplicationModule(ApplicationPoolImpl.java:2062)
         at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:398)
         at oracle.jbo.http.HttpSessionCookieImpl.useApplicationModule(HttpSessionCookieImpl.java:230)
         at oracle.jbo.html.jsp.datatags.ApplicationModuleTag.doStartTag(ApplicationModuleTag.java:193)
         at login.jspService(_login.java:98)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at sphinx.vse.filter.AuthentifiedFilter.doFilter(AuthentifiedFilter.java:67)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:560)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:479)

    This problem appeared here today, but the first time I try to access the application the exception is a little bit different:
    JBO-30003: The application pool (SiscomModuleLocal) failed to checkout an application module due to the following exception:
    oracle.jbo.DMLException: JBO-26066: Error during rollback.
         at oracle.jbo.server.DefaultTxnHandlerImpl.handleRollback(DefaultTxnHandlerImpl.java:153)
    ## Detail 0 ##
    java.sql.SQLException: No more data to read from socket
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:1160)
         at oracle.jdbc.ttc7.MAREngine.unmarshalUB1(MAREngine.java:963)
         at oracle.jdbc.ttc7.MAREngine.unmarshalSB1(MAREngine.java:893)
         at oracle.jdbc.ttc7.Ocommoncall.receive(Ocommoncall.java:104)
         at oracle.jdbc.ttc7.TTC7Protocol.rollback(TTC7Protocol.java:487)
         at oracle.jdbc.driver.OracleConnection.rollback(OracleConnection.java:1376)
         at oracle.jbo.server.DefaultTxnHandlerImpl.handleRollback(DefaultTxnHandlerImpl.java:139)
    If I try to access the application for now on, then I start getting the same exception as you:
    JBO-30003: The application pool (SiscomModuleLocal) failed to checkout an application module due to the following exception:
    oracle.jbo.DMLException: JBO-26066: Error during rollback.
         at oracle.jbo.server.DefaultTxnHandlerImpl.handleRollback(DefaultTxnHandlerImpl.java:153)
    ## Detail 0 ##
    java.sql.SQLException: Io exception: Connection aborted by peer: socket write error
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
         at oracle.jdbc.driver.OracleConnection.rollback(OracleConnection.java:1380)
         at oracle.jbo.server.DefaultTxnHandlerImpl.handleRollback(DefaultTxnHandlerImpl.java:139)
    Reading some posts on google, I found this: "I've seen this exception before under different circumstances, so you can
    take my advice with a grain of salt. Anyhow, in my experience, the 'No more
    data from socket' error has been related to the database timing out."
    So I'm going to check the settings for my connection pool, and let you know the results.
    []'s
    Alexandre Mello.

  • How to disconnect the BC4J transation

    HI ALL~
    I have a very unusual problem~
    I use Jheadstart 9.0.5.1.9
    problem description:I have a project called Testproject,
    when I execute browse and connect to the page of Testproject,the Testproject will create session with database,but when I close the browse, the transation with Testproject and database doesn't disconnected,the session still remain in database??????
    How could I to solve the problem??
    Is there a method or action private me to disconnect the BC4J transation when browse closed??
    thank's all~

    I need some help with the JHeadStart, Im tring to migrate a Oracle forms applications to a j2ee applications
    In the tutorial they say that i need to create a new workspace and a new JHeadStart project
    the problem is that i dont have that option in the pop up menu
    so I first
    - create a new Application Workspace with web Application (default) template,
    - then I enabled the jheadstart on this project
    - after that I go to the designer generator and go throw the wizard
    - the jdeveloper create many files
    - then in the file ViewControllerApplicationsStructure I run the generator,
    the program create many files but just before he create the struts-config.xml, the program fail and print in the console this
    mesaje
    java.lang.ArrayIndexOutOfBoundsException: 0
    at oracle.jheadstart.tools.jag.StrutsConfigGenerator.generate(StrutsConf
    igGenerator.java:216)
    at oracle.jheadstart.tools.jag.ApplicationGenerator.generateServiceFiles
    (ApplicationGenerator.java:1235)
    at oracle.jheadstart.tools.jag.ApplicationGenerator.generateApplication(
    ApplicationGenerator.java:577)
    at oracle.jheadstart.tools.jag.ApplicationGenerator.<init>(ApplicationGe
    nerator.java:355)
    at oracle.jheadstart.tools.jag.JagRunner$1.run(JagRunner.java:76)
    at java.lang.Thread.run(Thread.java:534)
    I have install
    - Oracle JDeveloper 10 g 10.1.2.0.0
    - Oracle DataBase 9i
    - Oracle Designer 9i
    - JHeadStart 10 g 10.1.2.0
    What can i do??

  • HOWTO: Using a BC4J Application Module in an Stateless EJB Session Bean

    HOWTO: Using a BC4J Application Module in an Stateless EJB Session Bean
    by Steve Muench
    Overview
    BC4J provides automatic facilities for deploying any application module as a stateful EJB session bean. If you want to leverage the features of your BC4J application module from a stateless EJB session bean, it's not automatic but it is straightforward to implement. This howto article explains the details.
    For our example, we will create a stateless EJB session bean that uses a container-managed transaction. To keep things simple, let's assume the session bean has a single public method on its remote interface named createDepartment() with the following signature:
    public void createDepartment(int id, String name, String loc) throws AppException
    AppException is an example of an application-specific exception that our method will throw if any problems arise during its execution.The goal of this article is to illustrate how to use the BC4J application module named com.example.hr.HRApp as part of the implementation of this createDepartment method on our stateless enterprise bean. Let's assume that the HRApp application module has a view object member named Departments, based on the com.example.hr.DeptView view object, based on the familiar DEPT table and related to the com.example.hr.Dept entity object so our view can be updateable.
    Creating the Stateless Session Bean
    We can start by using the JDeveloper Enterprise Bean wizard to create a new stateless session bean called StatelessSampleEJB implemented by:[list][*]com.example.StatelessSampleEJBBean (Bean class)[*]com.example.StatelessSampleEJBHome (Home interface)[*]com.example.StatelessSampleEJB (Remote interface)[list]
    We then use the EJB Class Editor to add the createDepartment method to the remote interface of StatelessSampleEJB with the signature above. We edit the remote interface to make sure that it also reflects that the createDepartment method thows the AppException like this:
    package com.example;
    import javax.ejb.EJBObject;
    import java.rmi.RemoteException;
    public interface StatelessSampleEJB extends EJBObject {
      void createDepartment(int id, String name, String loc)
      throws RemoteException,AppException;
    }Before we start adding BC4J into the picture for our implementation, our StatelessSampleEJBBean class looks like this:
    package com.example;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    public class StatelessSampleEJBBean implements SessionBean {
      public void ejbCreate(){}
      public void ejbActivate(){}
      public void ejbPassivate(){}
      public void ejbRemove(){}
      public void setSessionContext(SessionContext ctx){
      public void createDepartment(int id, String name, String loc) 
      throws AppException {
        // TODO: Implement method here
    }We can double-click on the ejb-jar.xml file in our project to see the XML deployment descriptor for the bean we just created:
    <ejb-jar>
       <enterprise-beans>
          <session>
             <description>Session Bean ( Stateless )</description>
             <display-name>StatelessSampleEJB</display-name>
             <ejb-name>StatelessSampleEJB</ejb-name>
             <home>com.example.StatelessSampleEJBHome</home>
             <remote>com.example.StatelessSampleEJB</remote>
             <ejb-class>com.example.StatelessSampleEJBBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
          </session>
       </enterprise-beans>
    </ejb-jar>We need to add the extra <assembly-descriptor> section in this file to indicate that the createDepartment method will require a transaction. After this edit, the ejb-jar.xml file looks like this:
    <ejb-jar>
       <enterprise-beans>
          <session>
             <description>Session Bean ( Stateless )</description>
             <display-name>StatelessSampleEJB</display-name>
             <ejb-name>StatelessSampleEJB</ejb-name>
             <home>com.example.StatelessSampleEJBHome</home>
             <remote>com.example.StatelessSampleEJB</remote>
             <ejb-class>com.example.StatelessSampleEJBBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
          </session>
       </enterprise-beans>
       <assembly-descriptor>
          <container-transaction>
             <method>
                <ejb-name>StatelessSampleEJB</ejb-name>
                <method-name>createDepartment</method-name>
                <method-params>
                   <method-param>int</method-param>
                   <method-param>java.lang.String</method-param>
                   <method-param>java.lang.String</method-param>
                </method-params>
             </method>
             <trans-attribute>Required</trans-attribute>
          </container-transaction>
       </assembly-descriptor>
    </ejb-jar>
    Aggregating a BC4J Application Module
    With the EJB aspects of our bean setup, we can proceed to implementing the BC4J application module aggregation.
    The first thing we do is add private variables to hold the EJB SessionContext and the instance of the aggregated BC4J ApplicationModule, like this:
    // Place to hold onto the aggregated appmodule instance
    transient private ApplicationModule _am  = null;
    // Remember the SessionContext that the EJB container provides us
    private           SessionContext    _ctx = null;and we modify the default, empty implementation of the setSessionContext() method to remember the session context like this:
    public void setSessionContext(SessionContext ctx){ _ctx = ctx; }We add additional constants that hold the names of the J2EE datasource that we want BC4J to use, as well as the fully-qualified name of the BC4J application module that we'll be aggregating:
    // JNDI resource name for the J2EE datasource to use
    private static final String DATASOURCE = "jdbc/OracleCoreDS";
    // Fully-qualified BC4J application module name to aggregate
    private static final String APPMODNAME = "com.example.hr.HRApp";We expand the now-empty ejbCreate() and ejbRemove() methods to create and destory the aggregated instance of the BC4J application module that we'll use for the lifetime of the stateless session bean. When we're done, ejbCreate() it looks like this:
    public void ejbCreate() throws CreateException {
      try {
        // Setup a hashtable of environment parameters for JNDI initial context
        Hashtable env = new Hashtable();
        env.put(JboContext.INITIAL_CONTEXT_FACTORY,JboContext.JBO_CONTEXT_FACTORY);
        // NOTE: we want to use the BC4J app module in local mode as a simple Java class!
        env.put(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);
        env.put(PropertyConstants.INTERNAL_CONNECTION_PARAMS,DATASOURCE);
        // Create an initial context, using this hashtable of environment params
        InitialContext ic = new InitialContext(env);
        // Lookup a home interface for the application module
        ApplicationModuleHome home = (ApplicationModuleHome)ic.lookup(APPMODNAME);
        // Using the home, create the instance of the appmodule we'll use
        _am = home.create();
        // Register the BC4J factory to handle EJB container-managed transactions
        registerContainerManagedTransactionHandlerFactory();
      catch(Exception ex) {
         ex.printStackTrace();
        throw new CreateException(ex.getMessage());
    }and ejbRemove() looks like this:
    public void ejbRemove() {
      try {
        // Cleanup any appmodule resources before getting shutdown
        _am.remove();
      catch(JboException ex) { /* Ignore */ }
    }The helper method named reigsterContainerManagedTransactionHandlerFactory() looks like this:
    private void registerContainerManagedTransactionHandlerFactory() {
      SessionImpl session = (SessionImpl)_am.getSession();
      session.setTransactionHandlerFactory(
        new TransactionHandlerFactory() {
          public TransactionHandler  createTransactionHandler() {
            return new ContainerManagedTxnHandlerImpl();
          public JTATransactionHandler createJTATransactionHandler() {
            return new ContainerManagedTxnHandlerImpl();
    }The last detail is to use the BC4J appmodule to implement the createDepartment() method. It ends up looking like this:
    public void createDepartment(int id, String name, String loc)
    throws AppException {
      try {
        // Connect the AM to the datasource we want to use for the duration
        // of this single method call.
        _am.getTransaction().connectToDataSource(null,DATASOURCE,false);
        // Use the "Departments" view object member of this AM
        ViewObject departments = _am.findViewObject("Departments");
        // Create a new row in this view object.
        Row newDept = departments.createRow();
        // Populate the attributes from the parameter arguments.
        newDept.setAttribute("Deptno", new Number(id));
        newDept.setAttribute("Dname", name);
        newDept.setAttribute("Loc", loc);
        // Add the new row to the view object's default rowset
        departments.insertRow(newDept);
        // Post all changes in the AM, but we don't commit them. The EJB
        // container managed transaction handles the commit.
        _am.getTransaction().postChanges();
      catch(JboException ex) {
        // To be good EJB Container-Managed Transaction "citizens" we have
        // to mark the transaction as needing a rollback if there are problems
        _ctx.setRollbackOnly();
        throw new AppException("Error creating dept "+ id +"\n"+ex.getMessage());
      finally {
        try {
          // Disconnect the AM from the datasource we're using
          _am.getTransaction().disconnect();
        catch(Exception ex) { /* Ignore */ }
    Building a Test Client
    With the EJB-Tier work done, we can build a sample client program to test this new stateless EJB Session Bean by selecting the bean in the Oracle9i JDeveloper IDE and choosing "Create Sample Java Client" from the right-mouse menu.
    When the "Sample EJB Client Details" dialog appears, we take the defaults of connecting to embedded OC4J container. Clicking the (OK) button generates the following test class:
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import com.example.StatelessSampleEJB;
    import com.example.StatelessSampleEJBHome;
    public class SampleStatelessSampleEJBClient {
      public static void main(String [] args) {
        SampleStatelessSampleEJBClient sampleStatelessSampleEJBClient =
           new SampleStatelessSampleEJBClient();
        try {
          Hashtable env = new Hashtable();
          env.put(Context.INITIAL_CONTEXT_FACTORY,
                  "com.evermind.server.rmi.RMIInitialContextFactory");
          env.put(Context.SECURITY_PRINCIPAL, "admin");
          env.put(Context.SECURITY_CREDENTIALS, "welcome");
          env.put(Context.PROVIDER_URL,
                  "ormi://localhost:23891/current-workspace-app");
          Context ctx = new InitialContext(env);
          StatelessSampleEJBHome statelessSampleEJBHome =
               (StatelessSampleEJBHome)ctx.lookup("StatelessSampleEJB");
          StatelessSampleEJB statelessSampleEJB;
          // Use one of the create() methods below to create a new instance
          // statelessSampleEJB = statelessSampleEJBHome.create();
          // Call any of the Remote methods below to access the EJB
          // statelessSampleEJB.createDepartment( int id, java.lang.String name, java.lang.String loc );
        catch(Throwable ex) {
          ex.printStackTrace();
    }We uncomment the call to the create() method and add a few calls to the createDepartment() method so that the body of the test program now looks like this:
    // Use one of the create() methods below to create a new instance
    statelessSampleEJB = statelessSampleEJBHome.create();
    // Call any of the Remote methods below to access the EJB
    statelessSampleEJB.createDepartment( 13, "Test1","Loc1");
    System.out.println("Created department 13");
    statelessSampleEJB.createDepartment( 14, "Test2","Loc2");
    System.out.println("Created department 14");
    try {
      // Try setting a department id that is too large!
      statelessSampleEJB.createDepartment( 23456, "Test3","Loc3");
    catch (AppException ax) {
      System.err.println("AppException: "+ax.getMessage());
    }Before we can successfully run our SampleStatelessSampleEJBClient we need to first run the EJB bean that the client will try to connect to. Since Oracle9i JDeveloper supports local running and debugging of the EJB-Tier without doing through a full J2EE deployment step, to accomplish this prerequisite step we just need to right-mouse on the StatelessSampleEJB node in the System Navigator and select "Run". This starts up the embedded OC4J instance and runs the EJB right out of the current out path.Finally, we can run the SampleStatelessSampleEJBClient, and see the output of the test program in the JDeveloper log window:
    Created department 13
    Created department 14
    AppException: Error creating dept 23456
    JBO-27010: Attribute set with value 23456 for Deptno in Dept has invalid precision/scale
    Troubleshooting
    One error that might arise while running the example is that the database connection information in your data-sources.xml for the jdbc/OracleCoreDS datasource does not correspond to the database you are trying to test against. If this happens, then double-check the file .\jdev\system\oc4j-config\data-sources.xml under the JDeveloper installation home directory to make sure that the url value provided is what you expect. For example, to work against a local Oracle database running on your current machine, listening on port 1521, with SID of ORCL, you would edit this file to have an entry like this for jdbc/OracleCoreDS :
    <data-source
        class="com.evermind.sql.DriverManagerDataSource"
        name="OracleDS"
        location="jdbc/OracleCoreDS"
        xa-location="jdbc/xa/OracleXADS"
        ejb-location="jdbc/OracleDS"
        connection-driver="oracle.jdbc.driver.OracleDriver"
        username="scott"
        password="tiger"
        url="jdbc:oracle:thin:@localhost:1521:ORCL"
        inactivity-timeout="30"
    />This is the data-sources.xml file that gets used by the embedded OC4J instance running in JDeveloper.
    Conclusion
    Hopefully this article has illustrated that it is straightforward to utilize the full power of BC4J in local mode as part of your EJB Stateless Session Beans using container-managed transaction. This example illustrated a single createDepartment method in the enterprise bean, but by replicating the application module interaction code that we've illustrated in createDepartment, any number of methods in your stateless session bean can use the aggregated application module instance created in the ejbCreate() method.
    Code Listing
    The full code listing for the SampleStatelessEJB bean implementation class looks like this:
    * StatelessSampleEJB
    * Illustrates how to use an aggregated BC4J application module
    * in local mode as part of the implementation of a stateless
    * EJB session bean using container-managed transaction.
    * HISTORY
    * smuench/dmutreja 14-FEB-2002 Created
    package com.example;
    import oracle.jbo.*;
    import oracle.jbo.server.*;
    import javax.ejb.*;
    import oracle.jbo.domain.Number;
    import oracle.jbo.common.PropertyConstants;
    import java.util.Hashtable;
    import javax.naming.InitialContext;
    import oracle.jbo.server.ejb.ContainerManagedTxnHandlerImpl;
    public class StatelessSampleEJBBean implements SessionBean {
      // JNDI resource name for the J2EE datasource to use
      private static final String DATASOURCE = "jdbc/OracleCoreDS";
      // Fully-qualified BC4J application module name to aggregate
      private static final String APPMODNAME = "com.example.hr.HRApp";
      // Place to hold onto the aggregated appmodule instance
      transient private ApplicationModule _am  = null;
      // Remember the SessionContext that the EJB container provides us
      private           SessionContext    _ctx = null;
      public void ejbCreate() throws CreateException {
        try {
          // Setup a hashtable of environment parameters for JNDI initial context
          Hashtable env = new Hashtable();
          env.put(JboContext.INITIAL_CONTEXT_FACTORY,JboContext.JBO_CONTEXT_FACTORY);
          env.put(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);
          env.put(PropertyConstants.INTERNAL_CONNECTION_PARAMS,DATASOURCE);
          // Create an initial context, using this hashtable of environment params
          InitialContext ic = new InitialContext(env);
          // Lookup a home interface for the application module
          ApplicationModuleHome home = (ApplicationModuleHome)ic.lookup(APPMODNAME);
          // Using the home, create the instance of the appmodule we'll use
          _am = home.create();
          // Register the BC4J factory to handle EJB container-managed transactions
          registerContainerManagedTransactionHandlerFactory();
        catch(Exception ex) {
           ex.printStackTrace();
          throw new CreateException(ex.getMessage());
      public void ejbActivate(){}
      public void ejbPassivate(){}
      public void ejbRemove(){}
      public void setSessionContext(SessionContext ctx){ _ctx = ctx; }
      public void createDepartment(int id, String name, String loc)
      throws AppException {
        try {
          // Connect the AM to the datasource we want to use for the duration
          // of this single method call.
          _am.getTransaction().connectToDataSource(null,DATASOURCE,false);
          // Use the "Departments" view object member of this AM
          ViewObject departments = _am.findViewObject("Departments");
          // Create a new row in this view object.
          Row newDept = departments.createRow();
          // Populate the attributes from the parameter arguments.
          newDept.setAttribute("Deptno", new Number(id));
          newDept.setAttribute("Dname", name);
          newDept.setAttribute("Loc", loc);
          // Add the new row to the view object's default rowset
          departments.insertRow(newDept);
          // Post all changes in the AM, but we don't commit them. The EJB
          // container managed transaction handles the commit.
          _am.getTransaction().postChanges();
        catch(JboException ex) {
          // To be good EJB Container-Managed Transaction "citizens" we have
          // to mark the transaction as needing a rollback if there are problems
          _ctx.setRollbackOnly();
          throw new AppException("Error creating dept "+ id +\n"+ex.getMessage());
        finally {
          try {
            // Disconnect the AM from the datasource we're using
            _am.getTransaction().disconnect();
          catch(Exception ex) { /* Ignore */ }
      private void registerContainerManagedTransactionHandlerFactory() {
        SessionImpl session = (SessionImpl)_am.getSession();
        session.setTransactionHandlerFactory(
          new TransactionHandlerFactory() {
            public TransactionHandler createTransactionHandler() {
              return new ContainerManagedTxnHandlerImpl();
            public JTATransactionHandler createJTATransactionHandler() {
              return new ContainerManagedTxnHandlerImpl();

    Hi Steve, It4s me again;
    About the question I made, I tried with a single assembly-descriptor tag and a single container-transaction tag in the deployment descriptor of the session bean and these were the results.
    java.lang.NullPointerException
         void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
         java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         void __Proxy1.modificaEnvoltura(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String)
         void SamplemdeController.envolturaControlEJBClient.main(java.lang.String[])
    Then I tried with multiple assembly-descriptor tags each with a single container-transaction tag and the results were:
    java.lang.NullPointerException
         void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
         java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         void __Proxy1.modificaEnvoltura(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String)
         void SamplemdeController.envolturaControlEJBClient.main(java.lang.String[])
    Finally I tried with a single assembly-descriptor and multiple container tags and the results were:
    java.lang.NullPointerException
         void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
         java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         void __Proxy1.modificaEnvoltura(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String)
         void SamplemdeController.envolturaControlEJBClient.main(java.lang.String[])
    How can I make my Stateless Session bean work out?

  • Problem in Connection pooling after deploying BC4J App Module as EJB

    Hi,
    We have deployed the application modules on standalone OC4J as stateful EJB session beans.
    The problem is that with each user, the number of database connections seem to increase. This is making the application unscalable, which defeats the purpose of using EJB!
    Can someone please suggest how to limit the number of database conections in this scenario?
    Can this be solved by application module pooling? How can we use the PoolMgr to work with the session beans?
    We have tried to invoke disconnect on the application module after calling methods(using appmodule.disconnect(true)) and reconnect (appmodule.reconnect()) on entering the method. This keeps the number of connections low and works the first time the method is invoked. But subsequently, it gives nullpointerexception when the Row is accessed in the JSP.
    The exception we are getting is :
    java.lang.NullPointerException
         at oracle.jbo.client.remote.ViewUsageImpl.getStructDef(ViewUsageImpl.java:241)
         at oracle.jbo.client.remote.ViewUsageImpl.findAttributeDef(ViewUsageImpl.java:275)
         at oracle.jbo.client.remote.RowImpl.getAttributeIndexOf(RowImpl.java:368)
         at oracle.jbo.client.remote.RowImpl.getAttribute(RowImpl.java:144)
         at Supplier.client.ejb.beanmanaged.SupplierAM_IntPaymtVORowBeanManagedClient.getMdid(SupplierAM_IntPaymtVORowBeanManagedClient.java:63)
         at supplier.sccPayCheq._jspService(_sccPayCheq.java:102)
         [SRC:/Supplier/sccPayCheq.jsp:44]
    The Application module configuration (in bc4j.xcfg) is:
    <AppModuleConfig name="SupplierAM9iAS">
    <AppServerConnectionName>StandaloneOC4JConnection</AppServerConnectionName>
    <AppModuleJndiName>Supplier.SupplierAM</AppModuleJndiName>
    <java.naming.security.credentials>admin</java.naming.security.credentials>
    <DeployPlatform>EjbIas</DeployPlatform>
    <java.naming.security.principal>admin</java.naming.security.principal>
    <DtMiddleTierDeploymentProfile>ProjectMiddleTier.deploy</DtMiddleTierDeploymentProfile>
    <ApplicationName>Supplier.SupplierAM</ApplicationName>
    <DtDeploymentProfile>ProjectEJB.deploy</DtDeploymentProfile>
    <DtCommonDeploymentProfile>ProjectCommon.deploy</DtCommonDeploymentProfile>
    <JDBCDataSource>jdbc/ConnectionCoreDS</JDBCDataSource>
    <jbo.server.internal_connection>jdbc/ConnectionCoreDS</jbo.server.internal_connection>
    <jbo.ejb.txntype>local</jbo.ejb.txntype>
    <jbo.doconnectionpooling>true</jbo.doconnectionpooling>
    <ApplicationPath>ProjectEJB</ApplicationPath>
    </AppModuleConfig>
    The Datasource used (in $ORACLE_HOME/j2ee/home/config/data-sources.xml) is:
    <data-source
              class="oracle.jdbc.pool.OracleConnectionCacheImpl"           connection-driver="oracle.jdbc.driver.OracleDriver"
              ejb-location="jdbc/ConnectionDS"
              inactivity-timeout="30"
              location="jdbc/ConnectionCoreDS"
              name="ConnectionDS"
              password="*******"
              pooled-location="jdbc/ConnectionPooledDS"
              url="jdbc:oracle:thin:@<IPADDESS>:<SID>"
              username="USER"
              xa-location="jdbc/xa/ConnectionXADS"
              max-connections="5"
              min-connections="1"/>

    Can this be solved by application module pooling? How
    can we use the PoolMgr to work with the session
    beans?You can use a stateless checkout/checkin appmodule.
    Take a look at the following help topics which explain this in good detail.
    "About Application Module Pooling"
    "About JSP Pages and Application Module Pooling"
    The pool can help reuse the appmodule instance across requests thus reducing the number of concurrent db sessions.
    Dhiraj

  • 902: DefaultConnectionStrategy is disconnecting an application module conne

    Very odd exception from BC4J 902
    We have 4 ears deployed to this appserver, hot deploy happens most days for all 4 deployed ears.
    There's common classes deployed in all ears. Some times we see class cast exe's but that may be another issue.
    We've not changed anything in our env. but this afternoon one of our apps (.ear) started the following malfunctions.
    We haven't bounced oc4j for 2 days and don't want to because I suspect these errors will stop, but for what period of time?
    Our dev OC4J environment has this intermittant situation started happening.
    We're intermittantly seeing the following exceptions in SqlVO.executeQuerry()
    The use case will usually work with a new session (new browser).
    Some use cases will then fail 100% for the 2nd to nth try.
    The main piece of odd evidence we see is the following line in the
    log file. Note the lack of NL after the bind param "SCRIBE"
    [415531] Clear QueryCollection in cache...
    [415531] DRVR DBG1 Statement.setEscapeProcessing
    Binding param 1: SCRIBEDefaultConnectionStrategy is disconnecting an application module connection
    [415534] ViewObject close prepared statements...When the use case executes properly (no NPE) the log does not
    have the text DefaultConnectionStrategy is ...
    or the close prepared statements line.
    Exception from a SqlVO we intermitantly see #1
    java.lang.NullPointerException
        at oracle.jbo.common.WeakHashtableImpl.put(WeakHashtableImpl.java:264)
        at oracle.jbo.common.WeakHashtable.put(WeakHashtable.java:97)
        at oracle.jbo.server.ViewObjectImpl.updateQueryCollectionCache(ViewObjectImpl.java:3332)
        at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:524)
        at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:543)
        at oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:2557)
        at _storeDetails._jspService(_storeDetails.java:305)
        at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
        at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
        at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
        at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:721)
        at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
        at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
        at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
        at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
    Exception type #2 from SqlVo we intermittantly see
    instance of=class java.lang.NullPointerException
    java.lang.NullPointerException
         at oracle.jdbc.dbaccess.DBDataSetImpl._createOrGetDBItem(DBDataSetImpl.java:559)
         at oracle.jdbc.dbaccess.DBDataSetImpl.setBytesBindItem(DBDataSetImpl.java:1783)
         at oracle.jdbc.driver.OraclePreparedStatement.setItem(OraclePreparedStatement.java:1005)
         at oracle.jdbc.driver.OraclePreparedStatement.setString(OraclePreparedStatement.java:1387)
         at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:2520)
         at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:2905)
         at oracle.jbo.server.ViewRowSetImpl.bindParameters(ViewRowSetImpl.java:1279)
         at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:485)
         at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java: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 _offStoreHistory._jspService(_offStoreHistory.java:304)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)Thanks, curt

    Curt:
    In your first failure, it seems one thread is closing JDBC connection of the AM while another thread is trying to use the same AM to do executeQuery.
    Similar problem for the second failure...
    Most likely explanation has to do with hot deployment. When you hot-deploy your app, your old instance is invalidated, which would close your connection.
    Bottom line: don't do hot deploy while there are active sessions.
    Thanks.
    Sung

  • Oracle 10g Lite with ADF/BC4J Application(Offline access in Mobile )

    Hi All,
    We have the following requirement from one of our client.
    Customer Company has R12 Apps instance(which is having 10g Database APPSDB). The users will come in the morning
    and connect to the System(NEWSYSTEM) to download their daily worksheet(resides in APPSDB) to their Mobile Devices
    (Windows XP - http://www.keenzo.com/zoom.asp?zoom=3830134) and then disconnect from the system. The download of data
    should start after login into their Mobile Device Custom Application So that only their worksheet will be downloaded
    to their Mobile Device DB.
    Then they will goto their fields and review their daily worksheet in the Mobile Device application(NEW APPLICATION)
    in offline mode. And update in the application with their findings, which should be stored in the Mobile Device database(MOBILEDB).
    In the evening the uses will come and connect to the system(NEWSYSTEM) and login into their Mobile Application and
    start the upload process, then the updated data from their Mobile Database will be uploaded into APPSDB via the NEWSYSTEM.
    I checked the links, http://www.oracle.com/technology/products/lite/index.html and http://lite.us.oracle.com and I have
    got some understanding about Oracle 10g Lite. For the above requirement we are proposing the NEWSYSTEM as Oracle 10g Lite Server
    and the NEW APPLICATION as ADF/BC4J which can run in their Mobile Devices(work offline and then sync with DB).
    I have the following questions.
    1) The above proposing system is feasible?
    2) Can we develop the Mobile Application using ADF/BC4J and using that we would like to
    control the sync process from our custom application.(so that only their worksheet will come to their Mobile Device DB)
    3) If I want to have the above system,
    a) I should have Oracle 10g Lite server installed(im Unix or Windows)
    b) I should have Oracle 10g Lite client installed in a Windows PC/Laptop
    c) To get my custom application in My Mobile Device, first I have to deploy the application
    in Oracle 10g server using Oracle Mobile Server. Then I have to connect my Mobile Device to the Oracle 10g Lite server,
    and deploy the application in my Mobile Device using Oracle Mobile Manager.
    4) I would like to do a POC before start the project.
    What are all the installations I have to do in my Laptop.(Consider I am installing Oracle 10g Lite server/client, Mobile Manager in my Laptop)
    I am new to Oracle 10g Lite, correct me if any of my understanding is wrong.
    If you have any comments in the approach please add it.
    Thanks in advance.
    With Regards,
    Kali.

    1) The above proposing system is feasible?
    perfecly feasible, and actually a reasonably standard use of oracle lite
    2) Can we develop the Mobile Application using ADF/BC4J and using that we would like to
    control the sync process from our custom application.(so that only their worksheet will come to their Mobile Device DB)
    Actually two different questions here. The application code that runs on the client device can be written in any thing that will run on that type of device, and is capable of using the APIs to connect to the local database, and the other functionality like synchronisation. From the forum there look to be VB, C, java users out there (an i even believe if you wanted to, you could use forms). Main decision regarding the Platform for the application code development tends to be whatever you have the skills in.
    In terms of the sync process only downloading a particular users worksheet, this would be defined when you define the snapshots of the database tables you want to download, rather than the sync login process itself.
    For example - you have a table WORKSHEETS on the server that you want to download, it has a column EMP_NO which is the employee identifier. You would define the selection for the snapshot as
    select * from WORKSHEETS where EMP_NO=:emp_no (note the bind variable)
    when you then add users to the oracle lite application (actually the database), then you will have a parameter called EMP_NO to define with the employee number for that particular user, and this will be used automatically as the bind variable in the download.
    NOTE subsetting in this way does not need to be direct, for example things like
    select * from TASKS where id in (select task_id from user_tasks where emp_no=:emp_no) is perfectly valid
    NOTE when reading the forum and documentation, be careful of the word application. There are actually two different things to be developed, both normally called 'application'
    Within oracle lite you create an application with publication items, scripts, sequences etc. and then subscribe your users to this application. The application in this context is actually the database and synchronisation management ONLY (you can include files and code for download)
    The second application is your runtime code that has a user interface, functionality, processing and validation. This is written in some development platform, and accesses the database created above for select, insert, update etc.
    3) If I want to have the above system,
    a) I should have Oracle 10g Lite server installed(im Unix or Windows)
    YES this goes on the app server and installs a repository schema MOBILEADMIN within your database
    b) I should have Oracle 10g Lite client installed in a Windows PC/Laptop
    YES - once the server is set up, this is downloaded and set up by accessing the <server url>/webtogo/setup
    c) To get my custom application in My Mobile Device, first I have to deploy the application in Oracle 10g server using Oracle Mobile Server. Then I have to connect my Mobile Device to the Oracle 10g Lite server,
    and deploy the application in my Mobile Device using Oracle Mobile Manager.
    steps in outline are
    1) install server
    2) develop the oracle lite application (ie: database) and publish this to the mobile server (can use the development kit or java APIs for these two steps
    3) add a user with the relevant subsetting parameters
    4) set up oracle lite win32 client on the laptop from the server download
    5) synchronise using the msync utility on the client to create the databases and odbc entries
    6) develop your application code using the client database
    7) during development, then changes to database structure would be via changes and re-publish of the oracle lite application, followed by a sync to update the client database
    8) once all development is complete, the runtime application code can be bundled up into the oracle lite application if you want, and then the initial sync for live users will download the database and application code.
    4) I would like to do a POC before start the project.
    What are all the installations I have to do in my Laptop.(Consider I am installing Oracle 10g Lite server/client, Mobile Manager in my Laptop)
    You can set up a standalone server on the laptop, but better to do this on a development app server so you can use the main server development database as the data souce for the snapshot definitions (pretty easy install). there are conflicts if you try and put the oracle lite client and the mobile development kit on the same machine, but if you are familiar with java, the API development is fairly straightforward to use (i have developed applications in this, and i know only the basics of java) you do not need the MDK
    Basic for a POC i would say is to
    1) set up mobile server on development
    2) define a simple oracle ite application on two server tables. one has select * from table, and the other has select * from table where .... including bind variable. at this stage use complete refresh as the mode for simplicity
    3) publish the application, create user and define the subsetting variable
    4) set up mobile client and synchronise user. use the msql utility to interrogate the database and check the content, and do some updates 9standards SQL syntax)
    5) create simple appliaction code to conect to and read the database on the client
    6) do a sync after the updates above and check they appear in the server
    The above should be reasonably quick and proves
    a) ability to define the data you want to be sent to the users
    b) ability to create an app to manage the database running on the client device in you preferred software platform
    c) data download and upload
    after this basic POC, you can extend into defining fast refreshes to improve the efficiency of the sync process, managing the MGP process, developing a more comprehensive database and application etc. If you have complex joins between server table, you may also want to look at creating views to denormalise data and use these as the basis for the snapshots

  • URGENT  timout problems with bc4j

    Hello Jdev Team,
    We have a serious problem with the BC4J. The situation is as
    follows:
    We use BC4J with jsp pages an run the whole thing on a j2ee
    Container.
    We have written our own ApplicationPool class and
    ApplicationModule datatag because the users have to login
    using different credentials. The login users are db-users. The
    application release mode is reserved.
    The application crashes frequently. 2 errors occur.
    First of all we get an JBO-30003: "The application pool, {AM
    Name}, failed to checkout an application module instance."
    after the BC4J Container timeout --> messages ("BC4J HTTP
    Container was timed out" and "The binding listener for { AM
    name} was timed out")
    We haven't found a way to alter the BC4J container timeout.
    Where do we customize the timeout?
    We have tried to use the HttpSessionTimeOut variable but it
    seems to have no effect.
    I hope you can help us with this one.
    Second problem is that the J2EE Container stops functioning
    after a couple of requests.
    Even if an other browser is started (on the same or different
    machine) the Container does not respond to any request.
    We have found a Thread on technet handling this kind of problem
    but the solution doesn't work in our case.
    (the solution on technet was to put synchronized(session) around
    each JSP page)
    Now we run the application under Apache/Jserv and with the same
    Runtime packages as used in the Container and the problem
    seems to have disappeared.
    Here follows the code of the ApplicationPool class:
    The class is based on an example posted on technet
    * @author Juan Oropeza
    package be.cronos.dbwise.jbo;
    import oracle.jbo.common.ampool.ApplicationPoolImpl;
    import oracle.jbo.ApplicationModule;
    import java.util.Properties;
    public class SeperateLoginApplicationPool extends
    ApplicationPoolImpl
    private String vConnectURL;
    private String vUsername;
    private String vPassword;
    public SeperateLoginApplicationPool()
    public void setConnectInfo(String pUsername, String pPassword,
    String pConnectURL)
    this.vUsername = pUsername;
    this.vPassword = pPassword;
    this.vConnectURL = pConnectURL;
    protected void connect(ApplicationModule appModule)
    if (!appModule.getTransaction().isConnected())
    appModule.getTransaction().connect(vConnectURL ,
    vUsername, vPassword);
    //use Optimistic locking as default for all transactions
    appModule.getTransaction().setLockingMode
    (oracle.jbo.Transaction.LOCK_OPTIMISTIC);
    * checkin
    * @param appModule
    public synchronized void checkin(ApplicationModule appModule)
    // release the instance regardless of the release mode
    // this is necessary since we need a fresh instance each
    time.
    this.releaseInstance(appModule);
    this.releaseInstances();
    public void disconnect(ApplicationModule pAppModule, boolean
    pRetainState)
    super.disconnect(pAppModule, pRetainState);
    Here is the code of the applicationPool datatag:
         * @author Juan Oropeza
    * @author Ief Cuynen
    * @version 1.1
    /* Modification history
    package be.cronos.dbwise.datatags;
    import be.cronos.dbwise.jbo.SeperateLoginApplicationPool;
    import javax.servlet.jsp.tagext.TagSupport;
    import javax.servlet.jsp.JspException;
    import java.io.StringWriter;
    import java.io.PrintWriter;
    import oracle.jbo.html.jsp.ConnectionInfo;
    import oracle.jbo.common.ampool.PoolMgr;
    import oracle.jbo.common.ampool.ApplicationPool;
    import oracle.jbo.ApplicationModule;
    import oracle.jbo.html.jsp.JSPApplicationRegistry;
    import java.util.Properties;
    import java.util.Hashtable;
    import java.util.Enumeration;
    public class ApplicationModuleTag extends TagSupport
    String fApplicationName;
    String fConfigName;
    String fUsername;
    String fPassword;
    String fConnectionURL;
    String fIiopUserName;
    String fIiopPassword;
    JSPApplicationRegistry fAppRegistry;
    public ApplicationModuleTag()
    public void setId(String pAppName)
    { this.fApplicationName = pAppName; }
    public void setConfigname(String pValue)
    { this.fConfigName = pValue; }
    * doEndTag
    * @return int
    * @exception javax.servlet.jsp.JspException
    public int doEndTag() throws JspException
    try
    SeperateLoginApplicationPool pool = null;
    init();
    // Get an application module resource.
    fAppRegistry = JSPApplicationRegistry.getInstance();
    // this step will access the custom pool from the property
    file
    appRegistry.registerApplicationFromPropertyFile
    (fApplicationName);
                   // Since we don't want to use a
    PropertyFile per AM, we have written are own
    registerApplicationModule method
    this.registerApplicationModule();
    // get an instance of the pool, which is already existing
                   pool = (SeperateLoginApplicationPool)
    PoolMgr.getInstance().getPool(fApplicationName);
    // get an instance of the application module
    synchronized(pool)
    // Setup the connection information
    pool.setConnectInfo(fUsername, fPassword,
    fConnectionURL);
    // This instance will be used by the rest of the
    DataWebBeans since it&#8217;s part of the context.
                        try
                             //After the BC4J
    container timeout, this method will raise an exception
         ApplicationModule am =
    fAppRegistry.getAppModuleInstance(fApplicationName, pageContext);
                        catch(Exception e)
                             System.out.println
    ("JspRegistry has failed to get application module instance");
    setPageContextValues();
    catch(Exception ex)
    StringWriter writer = new StringWriter();
    PrintWriter prn = new PrintWriter(writer);
    ex.printStackTrace(prn);
    prn.flush();
    throw new JspException(writer.toString());
    return SKIP_BODY;
    * for internal use only
    private void init()
    fUsername = (String)pageContext.getSession().getValue
    ("username");
    fPassword = (String)pageContext.getSession().getValue
    ("password");
    fConnectionURL = (String)pageContext.getSession().getValue
    ("connectionURL");
    private void setPageContextValues()
    // place default renderers into session, these will not be
    exposed via config file
    pageContext.getSession().putValue
    ("oracle_ord_im_OrdImageDomain_Renderer", "oracle.ord.html.OrdBui
    ldURL");
    pageContext.getSession().putValue
    ("oracle_ord_im_OrdAudioDomain_Renderer","oracle.ord.html.OrdBuil
    dURL");
    pageContext.getSession().putValue
    ("oracle_ord_im_OrdVideoDomain_Renderer","oracle.ord.html.OrdBuil
    dURL");
    pageContext.getSession().putValue
    ("oracle_ord_im_OrdVirDomain_Renderer", "oracle.ord.html.OrdBuild
    URL");
    pageContext.getSession().putValue
    ("oracle_ord_im_OrdImageDomain_EditRenderer", "oracle.ord.html.Fi
    leUploadField");
    pageContext.getSession().putValue
    ("oracle_ord_im_OrdAudioDomain_EditRenderer", "oracle.ord.html.Fi
    leUploadField");
    pageContext.getSession().putValue
    ("oracle_ord_im_OrdVideoDomain_EditRenderer", "oracle.ord.html.Fi
    leUploadField");
    pageContext.getSession().putValue
    ("oracle_ord_im_OrdVirDomain_EditRenderer", "oracle.ord.html.File
    UploadField");
    protected synchronized void registerApplicationModule()
    PoolMgr vPoolMgr = PoolMgr.getInstance();
              try
    if (!vPoolMgr.isPoolCreated(fApplicationName))
                        // Parse the ConfigName
                        String vConfigPackage =
    fConfigName.substring(0, fConfigName.lastIndexOf('.'));
    String vConfigSection = fConfigName.substring
    (fConfigName.lastIndexOf('.') + 1);
                        //Strip out the AM Class
                        vConfigPackage =
    vConfigPackage.substring(0, vConfigPackage.lastIndexOf('.'));
    Properties vProps = new Properties();
    vProps.put("ConfigName",fConfigName);
                        ApplicationPool vAppPool =
    vPoolMgr.createPool(fApplicationName,vConfigPackage,
    vConfigSection, vProps);
                        vAppPool.setUserName
    (this.fUsername);
                        vAppPool.setPassword
    (this.fPassword);
              catch (Exception ex)
                   ex.printStackTrace();
                   throw new RuntimeException(ex.toString
    * release() called after doEndTag() to reset state
    public void release()
              super.release();
              fApplicationName = null;
              fConfigName = null;
              fUsername = null;
              fPassword = null;
              fConnectionURL = null;
              fIiopUserName = null;
              fIiopPassword = null;
              JSPApplicationRegistry fAppRegistry = null;
    Another thing is that the JSPApplicationRegistry contains a bug
    (I think)
    It doesn't use the HttpSessionTimeOut variable at all (see
    following code)
    this piece of code is a Method from the
    JSPApplicationRegistry.java File taken from package
    oracle.jbo.html.jsp;
    static synchronized public void
    registerApplicationFromPropertyFile(HttpSession session, String
    sPropFileName)
    if(!mPoolManager.isPoolCreated(sPropFileName))
    registerApplicationFromPropertyFile(sPropFileName);
    if (!PropertyConstants.TRUE.equals((String)session.getValue
    (SESSION_INITIALIZED)))
    Hashtable settings = getAppSettings(sPropFileName);
    /* The timeout variable is declared here */
    int nTimeOut = 300;
    if (settings != null)
    // see if we have a setting for the session timeout
    String sTimeOut;
    /* get the HttpSessionTimeOut variable */
    if(settings.get("HttpSessionTimeOut") != null)
    sTimeOut = (String)settings.get
    ("HttpSessionTimeOut");
    if(sTimeOut != null)
    /* Put the value in the variable... and that's the last thing it
    does. nTimeOut isn't used anywhere in the class */
    nTimeOut = Integer.parseInt(sTimeOut);
    if(settings.get("ImageBase") != null)
    session.putValue("ImageBase", settings.get
    ("ImageBase"));
    else
    settings.put("ImageBase", "/webapp/images");
    session.putValue("ImageBase", "/webapp/images");
    if(settings.get("CSSURL") != null)
    session.putValue("CSSURL",settings.get("CSSURL"));
    else
    settings.put("CSSURL", "/webapp/css/oracle.css");
    session.putValue
    ("CSSURL", "/webapp/css/oracle.css");
    // place default renderers into session, these will not
    be
    // exposed via config file
    session.putValue
    ("oracle_ord_im_OrdImageDomain_Renderer", "oracle.ord.html.OrdBui
    ldURL");
    session.putValue
    ("oracle_ord_im_OrdAudioDomain_Renderer","oracle.ord.html.OrdBuil
    dURL");
    session.putValue
    ("oracle_ord_im_OrdVideoDomain_Renderer","oracle.ord.html.OrdBuil
    dURL");
    session.putValue
    ("oracle_ord_im_OrdVirDomain_Renderer", "oracle.ord.html.OrdBuild
    URL");
    session.putValue
    ("oracle_ord_im_OrdImageDomain_EditRenderer", "oracle.ord.html.F
    ileUploadField");
    session.putValue
    ("oracle_ord_im_OrdAudioDomain_EditRenderer", "oracle.ord.html.F
    ileUploadField");
    session.putValue
    ("oracle_ord_im_OrdVideoDomain_EditRenderer", "oracle.ord.html.F
    ileUploadField");
    session.putValue
    ("oracle_ord_im_OrdVirDomain_EditRenderer", "oracle.ord.html.F
    ileUploadField");
    session.putValue(SESSION_INITIALIZED,
    PropertyConstants.TRUE);
    Am I mistaken or is it a bug?
    Thank you for your fast response.
    Greetings,
    Ief Cuynen

    First of all we get an JBO-30003: "The application pool, {AM Name}, failed to checkout an application module
    instance."
    The JBO-30003 exception is thrown whenever the pool cannot
    properly create/recycle an application module. Please see the
    exception details (scan the exception stack to find the exception
    details) for more information regarding the "root" cause of the
    exception.
    We haven't found a way to alter the BC4J container timeout. Where do we customize the timeout?
    The BC4J container is timed out when the HttpSession is timed
    out. The session timeout is configurable via the web.xml file
    for the J2EE application. Your servlet container may also
    include another mechanism for setting a session timeout.
    Second problem is that the J2EE Container stops functioning after a couple of requests. Even if an other browser
    is started (on the same or different machine) the Container does
    not respond to any request. We have found a Thread on technet
    handling this kind of problem but the solution doesn't work in
    our case.
    The issue sounds like a deadlock. Please use kill -3 (Solaris)
    or ctrl-break (NT) at the java server console to print the thread
    stack trace to stdout. This will contain more information
    regarding which threads are blocked and where. If you would like
    you can send the stack trace to me via mail and I can take a look
    at it.
    The solution of synchronizing your pages with the HttpSession
    context is required only if you are using the BC4J datatags with
    HTML frames (i.e. have multi-threaded application module
    access for a given session). Please note that this solution may
    have a performance impact and should not be implemented unless
    absolutely necessary.
    Another thing is that the JSPApplicationRegistry contains a bug (I think). It doesn't use the HttpSessionTimeOut variable
    at all (see following code)
    This parameter was deprecated after 3.1. It looks like the code
    which used the parameter may have been removed prematurely.
    Sorry for the confusion. Please use the J2EE compliant
    mechanisms mentioned above to configure the session timeout in
    3.2.
    Finally, please note that JDeveloper9i includes new integrated
    features for the often requested feature of supporting different
    db users with the same application pool! Please stay tuned.

  • Dynamic BC4J JDBC credential problem

    I am using bc4j 9.0.3.1 and trying to dynamically change jdbc credentials and connect to different databases. I did everything as described in article "How to support Dynamic JDBC Credentials".
    I was able successfully connect from web application to database, but when I request ViewObject from app module - I got error "Error Message: JBO-25200: Application module is not connected to a database".
    What happened is following:
    My apps connect to database, it print following debug message:
    [458] Creating a new pool resource
    [459] Trying connection/2: url='jdbc:oracle:thin:@192.168.0.1:mxb' info='{user=carnegie, password=carnegie}' ...
    [460] Successfully logged in
    then in dubugger I see it calls ApplicationPoolImp class doFailover method and alwaus execute disconnect(appModule, true, cookie) method.
    I do not know why it disconnection itself from the database.
    // Store the passivation id on the application module cookie so that
    // we know the last passivation id.
    cookie.setPassivationId(passivationId);
    // After passivating the application module attempt to clean up any
    // records associated with previously passivated state. State may not be
    // removed if the VM instance has died (pass a previous state to this
    // method? Add logic to the application registry to handle this?).
    doPersistenceOperation(REMOVE_STATE, appModule, prevPassivationId, cookie);
    if (!wasConnected)
    // Always retain the state.
    disconnect(appModule, true, cookie);
    Final debug statements I got:
    [486] DefaultConnectionStrategy is disconnecting an application module connection
    [490] ViewObject close prepared statements...
    [491] ViewObject close prepared statements...
    [492] ViewObject close prepared statements...
    [493] ViewObject close prepared statements...
    [494] ViewObject close prepared statements...
    [495] ViewObject close prepared statements...
    [496] *** closing jdbc connection now **** (oracle.jdbc.driver.OracleConnection@ed)
    My problem - why it disconnection itself from the database after successfull connection? I want to use this connection for duration of the session.

    hi DAguirre
    I have found the class "oracle.jbo.http.HttpSessionCookieFactory" in these JAR files:
    <your-jdevstudio10133-dir>\BC4J\jlib\bc4jhtml.jar
    <your-jdevstudio10133-dir>\BC4J\lib\adfmweb.jar
    You could try to add one of these JAR files to your classpath.
    regards
    Jan Vervecken

  • Information needed on BC4J

    We have a swing based application with BC4J deployed on Oracle 8i as CORBA server objects. We face a peculiar problem: whenever any method in the ApplicationModule throws an exception (a JboException) no further transactions can be made. Any further call to the ApplicationModule's methods results in an Exception with a message:"peer disconnected socket". what could be the problem?
    Also I would like to know what are "hooks" and "pass-through sql" in the BC4J context.

    Yes, the socket gets disconnected when a server exception occurs, but I wrap a JboException around it and throw it. e.g. when i open two instances of my application and lock a row from one instance and try to lock the same row from the other instance, an exception is thrown. the code in the application module is as follows:
    public void lockRow(String appModName, String ViewObjectName, Key key) {
    try
    oracle.jbo.ApplicationModule am = findApplicationModule(appModName);
    ViewObject vo = am.findViewObject(ViewObjectName);
    ViewRowImpl vi = (ViewRowImpl)vo.getRow(key);
    vi.lock();
    }catch(Exception ex)
    throw new JboException (ex);
    When the above code throws the exception, the socket gets disconnected for that instance of the application.
    Can u please tell me if there is any problem with the code or my exception handling?
    Also, which trace files should I look into? Do I have to enable the trace?
    null

  • Oracle lite webtogo BC4J

    hi....
    i have installed oracle lite webtogo BC4J.I have developed an application using jdeveloper JSF ADF BC techology and deployed it on to the mobile server.Now when i use mobile client web server and open this application.Can i use it in disconnected mode.i.e can i use the application in offline mode????

    Marcel,
    You are correct, Webtogo does not support JSF. JSP/Servlets/Struts/Tiles are the only things supported. Also correct that it is not a J2EE container, but why would you require enterprise components in a disconnected mode?
    I read over the ADF/BC4J tutorial and it doesn't mention any additional install that would have to happen. I would think that the JARs would be downloaded to the client accordingly.
    For your JDBC connection you can use either the Webtogo driver or the Polite driver. Your application, once deployed should be using the Webtogo driver.
    // Using the webtogo driver
    public Connection getConnection()
       Class.forName("oracle.lite.web.WTGJdbcDriver");
       conn = DriverManager.getConnection("jdbc:oracle:webtogo");
       return conn;
    // Using the polite driver
    public Connection getConnection()
       Class.forName("oracle.lite.poljdbc.POLJDBCDriver");
       conn = DriverManager.getConnection("jdbc:polite:USERID_dbdsn");
       return conn;
    }

  • Critical Issue - Locking Error - Stateless BC4J Application

    Hi,
    We are using "Stateless" mode in our BC4J project. Our View form done with Datawebbeans, Edit Form and Submit Edit Form done with Datatags. We are using Jdeveloper 3.2.
    In multi-user environment, we are noticing that if two users open the same record at the same time, for editing, it is allowing both the users to edit the same record. We expect the second user to get an error message something like "Row Has been Changed - Re-query to see the change". But its not the case.
    This is a very critical issue for us and any help from JDEV team is appreciated.
    Thank you in advance
    Virinchi
    null

    The following information from Jdeveloper 3.1 Help (User Guides - Developing Business Components - Understanding Transactions - About Application Modules and Transactions) might be useful:
    Client applications connect to databases and manage transactions by using the oracle.jbo.Transaction interface. Some useful methods of the Transaction interface with regard to Application Modules are:
    commit - Commit the transaction; saves all changes to the database. If the database connection is established, the transaction is implicitly started.
    connect - Attempt to establish a connection to the given database URL.
    disconnect - Disconnect the server from the database.
    **getLockingMode** - Get the preferred locking mode for this transaction. Currently the locking mode defaults to LOCK_PESSIMISTIC.
    rollback - Rollback the transaction; discard all changes.
    setLockingMode - Set the preferred locking mode for this transaction. Changing the locking mode affects only subsequent locks that are placed
    If you have an Application Module and DataSource defined with Data Tags like this:
    <%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>
    <jbo:ApplicationModule configname="dbproject3.Dbproject3Module.Dbproject3ModuleLocal"
    id="Dbproject3Module" username="db" password="project" />
    <jbo:DataSource id="ds" appid="Dbproject3Module" viewobject="BlChangesView" >
    </jbo:DataSource>
    Then you can access the Application Module, using Java Code like this:
    jsp:useBean class="oracle.jbo.html.databeans.RowsetNavigator" id="rsn" scope="page" >
    <%
    rsn.setReleaseApplicationResources(false);
    rsn.initialize(pageContext,"JSPFrame_dbproject3_Dbproject3Module.BlChangesView");
    oracle.jbo.Row row = rsn.getRowSet().last();
    oracle.jbo.domain.Number num = ((oracle.jbo.domain.Number)row.getAttribute("ChangeCode"));
    ccode = num.intValue();
    out.println("<h2>Change Code, by webbean is: " + ccode);
    %>
    </jsp:useBean>
    Use:
    ApplicationModule am =rsn.getRowSet().getApplicationModule()
    then get the transacton with
    am.getTransaction()
    Hope this helps.
    null

  • Bc4j, jsp, oracle9ias appl - inreasing database connections

    Hi,
    I have a BC4J application developed in jdev 3.1, front end is jsps. the application is deployed on oracle9ias. The application is in statleful mode.
    As application users connect to the application, the number of database sessions keeps on increasing, and not freed even when the browser is closed and the http session ends.
    How can we release these sessions from the database (so that v$session does not show them anymore).
    Aparna.

    By default BC4J uses a connection pool to reuse JDBC connections. Once an application module is disconnected the JDBC connection is rolled back and then returned to the connection pool instead of being closed. This is why the sessions continue to appear in the v$session table.
    Please see the BC4J connection pooling documentation for more information about configuring the JDBC connection pool. You may be interested in setting a max JDBC connection pool size.
    .

  • Sites using BC4J???

    Hi,
    I would like to know if there are any commercial sites, or any live sites existing on the web, which are developed using BC4J.
    Thanks,
    Amit
    null

    Steven,
    Initially, we're seeing 3-10 seconds on a high end machine (PIII-866, 256MB), and near instantaneous after the first time. ( Depends upon how much you've put in your show() and how much memory you have ).
    I "preserve" the commonly used frames by not disposing (uh...=null'ing.. see earlier post on this issue) them, but reuse the objects and clean things up in a show().
    On LOW end client machines (PI-133, 64MB)... the frames may take 30-45 seconds ( or more ), the first time... and 5-20 seconds thereafter, depending upon the complexity.
    The most complex frame has 5 tabbed panes and probably 80-100 Infoswing textfields, comboboxes, textareas and checkboxes. It also has a detail grid control, and probably 60-70 buttons. And a slew of pull down menus. It ain't my pappy's idea of a simple "frame". That single frame probably replaces 7 "frames" in our old X-Windows application.
    NOTE: If you simply make frames invisible for re-use, your application WILL slow signficantly on low end machines because BC4J will try to keep all those controls on all those invisible frames up to date. This can be further aggravated by any rowMove or transaction listeners you may have implemented for the frame! So you have a trade-off on low end machines of slow re-instantiation of a frame when they need it... or fast re-instantiation but slowness for all ongoing activities!
    Hmmm... I suppose I could put checks that avoids "updates" in my listeners if the frame is now shown... but is there a way to do this for the BC4J automatic stuff?
    grin The users were warned a year ago, when they chose an application over JSPs (for ease of use and power of functionality.) We actually met the target I forecast... 2 minutes to startup, 30 seconds to swap frames initially, and 5-10 seconds to move between records ( Under HotSpot 1.3 ). But actually USING it under those conditions is different than agreeing to those performance expections in the design stage!
    Since these are heads down multi-shift technicians/engineers who use the application continually through the day and evening, the idea is to keep the application up ( or minimized ) for the entire day or week.
    We have decided to upgrade ALL our PI-133mhz/64MB machines, as they are effectively obsolete and this application pushed 'em over the edge. ( They actually have SMS, Outlook, AntiVirus, Oracle ERP apps ( GUI and Character mode ) up all at the same time on that configuration! They usually shut down Outlook or ERP to get into other apps... otherwise they went into "spin cycle" on their disk ( swapfile thrashing under W95/98) )
    We're going to a min config on the client of 866mhz/128MB machines. This will be necessary anyway as we are going to Oracle Apps 11i along with a new Java based PDM system on top of my application, in the next 6-9 months. My app was just the first to expose the need for beefier PCs than Grandma uses to buy things on Ebay. On second thought, Grandma has a beefier PC so she can refresh every second to get that bid in 2 seconds before closing.
    We are running into a larger than expected number of crashes of the JVMs on the client side. I'm currently testing Hotspot 1.3, Hotspot 1.3.1 (beta) and OJVM on various clients ( W95R1, W98, NT4.0SP6 and W2K ) and will report any results ( or bug patches ) I get in the near future on this board.
    Some of the crashes of the Hotspot 1.3 are already documented on the java.sun.com site by other folk.
    BTW - The back end server. I'm piggybacking on the Oracle ERP's HP hp-ux N-class 8 cpu server with an EMC disk array. You know, the kind they have on Galaxy class starships. My app/database fits into a tiny corner of that critter. No problems on the server side.
    whew Long, rather disconnected report... we should probably start a different thread on "Client Performance" if we continue....

  • What should happen during BC4J LOGOUT?

    We have our custom pool, which takes database username, password, and URL from the login page and creates it if its valid. Like that I created 2 pools which will be accessed by all the JSPs.
    We are currently using "RESERVED" mode.
    During the logout process, I want to know what steps do I need to take. Like application module disconnect, pool.remove etc.
    Can someone from Jdev team help us on this issue.
    Virinchi

    The logout page should probably release the reserved application
    module instance to the pool. If you are using the BC4J datatags
    this can be accomplished with the following line in your logout
    jsp:
    <jbo:ReleasePageResourcesTag releasemode="Stateless" />
    This will allow the application pool to properly "reset" the
    application module instance for reuse by other sessions. An
    application module "reset" will include the following:
    1. Rolling back the database session
    2. Clearing the BC4J transaction caches (entity and rowset)
    3. Releasing the application module's JDBC connection to the
    JDBC connection pool for reuse by other application modules.

Maybe you are looking for