Storing Data in Application Module Session

I'd like to store information about the current user in the session of the application module. I've been examining the example in the ADF Guide for Forms Developers in Chapter 9, but would like to implement it in a more generic way, in an overridden ApplicationModuleImpl class similar to what is documented in Chapter 28.
What I'd like to accomplish is:
A generic setter method similar to:
public void setVariable(String name, String value) {
Hashtable userdata = getDBTransaction().getSession.getUserData();
if (userdata == null) {
userdata = new Hashtable();
userdata.put(name.toUpperCase(),value.toUpperCase());
and a getter method similar to
public String getVariable(String name) {
Hashtable userdata = getDBTransaction().getSession.getUserData();
//null handling omitted
return (userdata.get(name.toUpperCase()).toString());
I can test this with calls like:
setVariable("myName","myValue");
System.out.println("myName="+getVariable("myName"));
I don't get any errors, but the output is:
myName=
Apparently it isn't either storing the value, or it isn't retrieving it correctly. I have several questions about this:
1. What am I doing wrong here? It 'looks' like it should work, but isn't.
2. Is this an appropriate approach to this problem?
3. Will there need to be any special handling on passivation/activation? Or since it's data stored in the session, will the AM handle that for me?

In further testing I can see that data is getting stored in my hashtable, and if I retrieve it directly in the setVariable method, the retrieval works. What I've discovered though, is that the code:
getDBTransaction().getSession.getUserData();
is returning null, in both the getter and setter methods. I am testing this using the application module tester (right click on the AM, click test). Is this default behavior, i.e. should the above line of code return a null value when using the tester?
Relatedly, am I going to have to write a front-end for this to test against? (please say it isn't so!)

Similar Messages

  • Sharing data among Application Modules & Sessions

    Hi,
    I have small BC4J application, which has around 5-6 application modules. One of those application modules is the entry point i.e. the client will first invoke the start method in that application module. This entry point application module will further use other application modules.
    I am using the database tables heavily so I am thinking of caching the required data on the application server side.
    What is the best way of sharing this cache among all the AMs in one session and also among all the sessions?
    For sharing cache in single session, I think we can create the instance of cache in the entry point application module, and then pass it to the rest of the application modules. Please let me know if there is better way of doing this?
    Thanks.
    Nilesh

    Hi Frank,
    We (colleague of Nilesh) unfortunately can't wait for 11g esp. because you can't give a release date.
    The problem we are facing is that we see the same queries hitting the database over and over again. So caching these queries for a 'longer' period of time would save us a lot of round trips to the database.
    The data we want to cache is releasable stable, the data we select is separated from the data we insert. So we can store the data over a longer period of time.
    But as I understand it, there is no solution that would solve such a usecase? (Other then using a different framework/ building a custom solution)
    Message was edited by:
    Thijs Vonk

  • Sharing view objects across application modules

    Our application uses multiple application modules because of the complex functional requirements. We have come across sharing view objects among application modules. I want to understand the best practice, sharing view object instances across application modules. These view objects can be based on Entity Objects also.
    Please let me know if there any suggestions.
    Thanks,
    Satya

    Hi Satya,
    You won't be able to share view objects between application modules, but what you can do is to share the bind variables between application modules, if each of your module contains the 'common' view object.
    A solution for sharing data between application modules is provided on this blog: http://andrejusb.blogspot.co.uk/2012/05/solution-for-sharing-global-user-data.html
    You can use this approach to share bind variables between AM's and re-query the same data.
    Hope this helps,
    Florin Marcus
    www.redsamuraiconsulting.com

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

  • Single session for all Application Modules

    Hello,
    I've got an application that has several Application Modules. All these modules need some data that are set from time to time. I've written some code that calls getSession().getUserData().put("myData",myData). After this method was called in another Application Module i want to retrieve myData with getSession().getUserData().get("myData"). But the result depends if I use 2-tier or 3-tier. In 2-tie I get myData while in 3-tier I get null. My question is:
    Is there a Session object or any other data instance that could be accessed from all Application Modules for on application instance.
    E.g. I've got two user (A,B) who start my application. Through using my app several instance of Application Modules are created. All Application Modules that are created for the instance of User A should be able to share his user name and some other dynamic data while the Application Modules created for B should have no access to that data.
    Doe anybody know if static data of an Application Module are a possible solution?
    regards
    Joerg

    Hi Joerg,
    I am not 100% sure what you are trying to achieve, and with which version of JDeveloper/ ADF, technologies (JSP, Swing), etc, but I can tell you that I have been experimenting with single session accounts myself within a rich-client Swing environment, as I have experienced Oracle DBA guys who want to control user authentication via Oracle accounts (I have achieved this via the JCLoginDialog mechanism, and a bit of a hack)... Frank Nemphius (sp?) posted something about a white paper coming out on a related subject but I don't know where he is with that.
    Anyway, I managed to do it in a prototype by nesting several application modules within a Root Application Module that was essentially simply a Container for the other application modules. Using this mechanism I was able to bind my root application module to any panel I wanted and it would inherit the roots Session.
    ie. I used many application modules and it only used one Oracle Session.
    However, my reservations -
    1) This solution was not tested robustly!
    2) I doubt this would be ideal for a distributed app with thousands of users - My solution is for a very complex app, with a limited number of users.
    Finally, I cannot confirm this is a great solution - I can only tell you it worked in my prototype, and I am currently awaiting the ADF source - when my company and Oracle can decide what level of support we currently have and need!?!? - what exactly does being an "Oracle partner" mean??? Its all very boring and un-interesting to a Java person like me... ;-)
    Once I have the source I will look at how it actually works and perhaps be able to answer questions like this more definitively. Hmm - I wonder if I could get the Oracle JDBC driver source too?? .... Is it written in C or C++?? I know them too... ;-)
    Cheers........Dean

  • Application Module retrieves different data than direct DB query

    Hi,
    I am using JDeveloper 1.1.1.6
    I have a big headache trying to figure out why my application Module is retrieving different data than if I execute the query of my ViewObject directly to the data base. To prove me that I am not crazy I have created a non updateable view object based in this sql query
    select * from hr_lookups;
    The application module is connecting to the database using JDBC URL Connection localhost:1529/DB and user name apps. When I run the application module I can see rows and everything as expected.
    If I connect to the same database using the same username, when I execute select * from hr_lookups; I get no rows!!!!
    I don't know what else to do and I really will appreciate your help in this one.
    Kind Regards

    Hi Timo,
    Thank you for your reply. Yes, I can see the exact same query. In fact all the rows are the same except one column. One attribute which is coming from a stored procedure. By this I mean the view object has the following structure;
    select att1, att2, ... , mypackage.myprocedure(param1,param2) from tables where clauses;
    So att1, att2, etc are the same whether I run the appModule or I copy and paste the query in a SQL WorkSheet and run it. The only different is the results of mypackage.myprocedure(param1,param2). So I have created a new view object from SQL query;
    select mypackage.myprocedure(param1,param2) from dual. From application module it returns one value and directly from SQL WorkSheet returns different value...
    Im sorry if I am not understandable but I am really desperate. Might it be permission or something like that???
    Regards

  • Is it proper for an application module has 300 views in the data model?

    Based on my understanding, all view object instances are initialized at the same time as the application module.
    It follows that when an application module is associated with a user session, the queries of each view object in the data model are executed.
    ie. if the data model has 325 view object instances, 325 queries will be executed.
    This doesn't seem efficient:
    1. As each user session only need to access a subset of the view objects (for examples 35 views), the rest of view objects need not be instantiated for that session.
    2. Performance may be slow on executing all 325 queries at one time, even worse when some queries are complex queries.
    Am I correct on this?
    In this case, will it be better to instantiate the view objects using the view object definition at runtime instead of adding all of them to the application module at design time?

    No, that's not the default behaviour.
    Assuming you're talking JDev 11, the AM on it's General tab as a Tuning option where you can set the loading of the VOs to Lazy or Non-Lazy, Lazy is the default. In turn each VO on their General tab also has a Tuning option of similar nature.
    Online documentation says:
    Lazy LoadingSelect to choose lazy loading. In this case, the application module instance is created without any of its components. Your view object and nested application module instances will not load until the first time they are used. For example, when lazy loading is enabled, a view object is instantiated only when the application accesses it. This will make start-up time faster.
    Non-lazy Loading
    Select to choose non-lazy loading. Your view object and nested application module instances will load when the application starts up. For example, suppose the application module you are editing defines three view objects and two nested application modules (which appear in the Application Module Instance section of the Data Model page over the application module overview editor). When lazy loading is disabled, the application module instance is created together with all three view objects and both nested application modules.>
    So in essence as you describe for each session, if we're using the Lazy setting, even though you have 325 VOs within an AM, if the user within the session only visits 35 queries, only 35 queries should fire.
    Does this help?
    CM.

  • Using session data across applications and subdomains

    Is there a way to share session <b>data</b>
    across different CF applications? across different subdomains?
    The goal here is single source login that stores complex data
    in a re-useable session scope. The current installation uses wddx
    to serialize the data and drop it into a cookie. I am looking for
    alternatives to the WDDX method as it has been causing a number of
    errors.
    For example I have application "a" at appA.domain.com ~ a
    user logs in an a session is created [domain cookies are set].
    I would like the user to be able to go to both
    appA.domain.com/subapp [which has its own application.cfm] and
    reuse the session created at appA.domain.com.
    Similarly I would like the session created appA.domain.com to
    carry over to appB.domain.com [which would has its own
    application.cfm file].
    Thanks for any help.
    ~jason.

    That would be known as cros-site scripting and most browsers
    disable that now, as it is a security issue if an application can
    read cookies from a different site domain.
    Sites that use cross-site data have to either pass it at the
    time accessig the other domain (via URL) or use a single database
    to record and recall data between applications.
    Passport is a good example. Even though you can use Passport
    on any site that offers it, the site ultimately tranfers you to the
    Passport website momentarily to collect your login and then
    transfers you back to your site along wth the credentials in a URL
    variable so your own site can then record the cookie and state you
    are logged in. It doesn't actually read the Passport cookie from
    your own site.
    If you were to create a DB that applies to multiple sites,
    you could figure out a way to populate session variables on
    separate sites by quering the DB for the data if there is no data
    currently stored, or if it detects that the referer was a different
    URL prior to loading the current site. Once it queries the data it
    can store the data in a session variable.

  • Database sessions, Application Modules and Pools

    Hi,
    I have an ADF 10.1.3 application (ADF Faces on ADF BC) that uses JAAS to authenticate it's users. After the user has logged in I would like my session_user_info managed bean to query the database and retrieve all the user's details, for access throughout the user's session. Initially I wrote the following code to achieve this:
          ApplicationModule am = Configuration.createRootApplicationModule(applicationModuleName, applicationConfigName);
          ViewObject vo = am.findViewObject("CurrentUserView1") ;
          vo.setNamedWhereClauseParam("v_userName",userName);
          vo.executeQuery();
          if(vo.getRowCount() <= 0)
            user = null ;
          else
            user = (CurrentUserViewRowImpl) vo.first();
          Configuration.releaseRootApplicationModule(am, true); This works fine BUT because it's creating a new root ApplicationModule each time I end up with an excessive number of database connections after a very short space of time (the call to Configuration.releaseRootApplicationModule does not seem to be releasing the database connection, even though the application module is released). I also don't like this as it feels like I'm "breaking" the framework by making a direct call to the model layer.
    So the next thing I wanted to try was creating a DataControl (by dragging my CurrentUserView1 on to a jspx page, then deleting it to preserve the bindings) and make a call to that using something like this:
            /**** TODO GET BINDING TO CurrentUserView1 ******/
            OperationBinding operationBinding =
                bindings.getOperationBinding("ExecuteWithParams");
            JUCtrlAttrsBinding vUsername =
                (JUCtrlAttrsBinding)bindings.findNamedObject("v_userName");
            statusCode.setAttribute("v_userName", username);
            Object result = operationBinding.execute();
            if (operationBinding.getErrors().isEmpty()) {
               /***** TODO Cast this result object in to something useful *****/
                setUser(result)
            }But as you can see I still don't completely understand what I have to do here (and yes I have trawled the various guides and documentation - but I can't work out exactly what applies to me as this isn't a backing bean).
    If any of you Aces out there can give me some pointers it would be MUCH appreciated as I've beat my head against this for a week now!!
    Dave
    Edited by: Short Dave on Dec 1, 2008 2:52 PM

    John,
    It's been 2 months since I asked this question and in that time I have tried innumerable ways of getting my application and database pools to behave in such a way that doesn't end up filling my database with unclosed sessions. The situation I'd ideally like to achieve is this:
    Application Modules
    A pool of application modules minimum 5 maximum 150 with a "working set" of about 25 (the jbo.recyclethreshold setting)
    For application modules to timeout if they are inactive for > 120 seconds (so if somebody has left their browser open in the background I don't want them hogging my AMs)
    Database Connections +(I am using a JDBC data source to allow multiple applications to reuse my connection pool settings)+
    A pool of database connections minimum 5 maximum 150
    If a connection is inactive for > 300 seconds for that connection to be closed (i.e. if an AM has been returned to the pool, but is not re-used within 5 minutes then I'd like the connection closed)
    Obviously, for the purposes of testing, I don't want to try and manage 150 browser sessions to see if this setup works, so I have been trying to create a scaled-down version of my requirements:
    Application Modules
    A pool of application modules minimum 1 maximum 5 with a "working set" of 1 (the jbo.recyclethreshold setting)
    For application modules to timeout if they are inactive for > 30 seconds
    Database Connections
    A pool of database connections minimum 1 maximum 5
    If a connection is inactive for > 60 seconds for that connection to be closed
    My problem is that, despite all the API's, the ADF for 4GL guide, forum entries and Steve Muench's guide to AM Pooling I still can't get this relatively simple example to work.
    My bc4j.xcfg file looks like (assume all other settings are as default):
             <jbo.recyclethreshold>1</jbo.recyclethreshold>
             <jbo.ampool.maxavailablesize>5</jbo.ampool.maxavailablesize>
             <jbo.ampool.maxinactiveage>30000</jbo.ampool.maxinactiveage>
             <jbo.ampool.minavailablesize>1</jbo.ampool.minavailablesize>
             <ApplicationName>gpl.model.PreUserLoginModule</ApplicationName>
             <jbo.ampool.monitorsleepinterval>30000</jbo.ampool.monitorsleepinterval>My data-sources.xml file has the following entries for the connection used by that application module (assume all other settings are as default):
      <connection-pool name="jdev-connection-pool-gslportal_at_ppmsdb"
                       disable-server-connection-pooling="false"
                       validate-connection="false" inactivity-timeout="60"
                       max-connections="5" min-connections="1"
                       property-check-interval="30"
                       used-connection-wait-timeout="30">With this configuration I can open a maximum of 5 browsers and each one connects successfully. On opening the 6th I get an exception because no more connections are available (as expected). My problem is that if I wait for 5 minutes I'd expect that
    a) 4 of the inactive application modules should be released (with one left available as per the min setting)
    b) The database connections of the 4 inactive application modules should be released as per the "inactivity" and "used-connection-wait" timeouts on the data-source
    c) I'd now expect the 6th browser to be able to connect because of the "freed up" resources
    From what I can make out none of these things happens. Even if I close the original 5 browsers, the 6th still cannot connect.
    I have noticed that if I set the "time-to-live-timeout" for the datasource then this will close the connection after the given period of time, but regardless of whether or not the connection was in use and in doing so renders the application module held in the pool as useless. (So if any of my original 5 sessions attempt to re-use the application module with the closed database connection, a "Closed Connection" SQLException is raised).
    I do appreciate this topic has been given LOTS of forum discussion already - but I really have done my research and am still none the wiser. Any help or guidance will be much appreciated.
    Kind Regards
    Dave

  • Sharing a BC4J application module amongst sessions

    Is there any method of sharing an application module amongst many sessions. Take BC4J/JSP on a single web server. We have a considerable amount of static lookup data that rarely changes and it seems daft to have to store this in the entity/view cache for every application module (one per active session).
    If we have a 100 sessions running I don't won't to store the lookup data 100 times. The smaller the session memory footprint the better.
    Anyone got any ideas?

    Hi,
    In 9.0.5 there is a property, "jbo.ampool.isuseexclusive", that may be used to configure this behaviour for an ApplicationPool.
    The summary is that when this property is false SessionCookie.useApplicationModule requests do not return an ApplicationModule that is reserved exclusively for that SessionCookie. Instead the AMs in the "intial pool" are shared by all SessionCookies that are using that pool.
    The reason that this is not formally documented is that it will not work with the declarative binding layer.
    Though BC4J itself is designed to be threadsafe you could still get race conditions on the default iterators. Imagine two threads that are looping through the rows of the default RSI of a deptVO in an unsynchronized block and, consequently, interleaving next calls.
    This is not an issue for programmatic clients as long as each thread of control instantiates their own RSI for access, simply does not use RowSetIterators, or implements synchronized, re-entrant use of an RSI.
    Please see the documentation for examples of developing a programmatic client that uses the pool APIs directly.
    Hope this helps,
    JR

  • How to separate application module instance per user session?

    Hi.
    How do you separate application module instances per session or per user? I am creating a web application and has created a simple filter that implements Filter.
    Thanks in advance.

    Hi Frank. Thank you for the reply.
    I tried using two browsers. The behavior of each page is very much different when being opened individually. Its like the two pages is sharing the same iterator / data and / or entity object. These two pages were opened to see if one is dependent upon the other. But when I test the same scenario on a different computer, everything works out fine.
    Is there a way for me to verify if the sessions are different? and if they are different, is there a way to verify if the application module created a new instance for the other session?

  • Why files in Lightroom mobile and files in the creative cloud not the same? idea-  one place(stored date) for all application ??????

    Why files in Lightroom mobile and files in the creative cloud not the same? idea- one place(stored date) for all application ??????

    Lightroom Mobile is not a cloud storage service. You shouldn't treat it as a way of backing up your files. You are merely storing Smart Previews of your files in the cloud space, high-quality JPEGs of your files regardless of their original format on your desktop. The point is that they are there so you can continue editing them in a Lightroom-like environment even while away from your desktop/laptop computer. The files in Lightroom Mobile can only be used in Lightroom Mobile.
    This is very different from what is offered by the Creative Cloud storage, which can be used to synchronize your files between any device (that can support the individual files).
    The vast difference in how each service works and its intended use is why they are separate.

  • Passivation of Application Module before session timeout

    Hi,
    JDeveloper : Studio Edition Version 11.1.2.3.0
    Oracle 11g Database
    WLS - 10.3.5
    I have an application (ADF BC and ADF Faces) built with jsff fragment and I have set user session time out in 4 hours.
    After some time (even before 1 hour of inactivity) I receive following error and unable to work on the page. I have to log out and login again to proceed.
    After approx 20 minutes of inactivity I can see the following log messages:
    <LoopDiagnostic> <dump> [12212] variables variables passivated >>> enterScheduledTimeSheet1_tsDate=2013-05-02
    <LoopDiagnostic> <dump> [12213] variableIterator variables passivated >>> TrackQueryPerformed def
    <LoopDiagnostic> <dump> [12214] variableIterator variables passivated >>> TrackQueryPerformed def
    <LoopDiagnostic> <dump> [12215] variableIterator variables passivated >>> TrackQueryPerformed def
    <LoopDiagnostic> <dump> [12216] variableIterator variables passivated >>> TrackQueryPerformed def
    <LoopDiagnostic> <dump> [12217] variableIterator variables passivated >>> TrackQueryPerformed def
    <DCUtil> <findSpelObject> [12218] DCUtil, returning:oracle.jbo.uicli.binding.JUFormBinding, for com_core_fragments_timesheet2ListingPageDef_com_core_task_flows_timesheet_task_flow_xml_timesheet_task_flow
    <JUCtrlHierNodeBinding> <release> [12219] released: ROOT node binding:noCtrl_oracle_adfinternal_view_faces_model_binding_FacesCtrlHierNodeBinding_587, value:TimesheetProjectsVO1Iterator
    <JUCtrlHierNodeBinding> <release> [12220] released: ROOT node binding:noCtrl_oracle_adfinternal_view_faces_model_binding_FacesCtrlHierNodeBinding_588, value:TimeTakenList1Iterator
    <JUCtrlHierNodeBinding> <release> [12221] released: ROOT node binding:noCtrl_oracle_adfinternal_view_faces_model_binding_FacesCtrlHierNodeBinding_590, value:TbaaTimesheetDailyentryView1Iterator
    <DCIteratorBinding> <releaseDataInternal> [12222] Releasing iterator binding:variables
    <DCIteratorBinding> <releaseDataInternal> [12422] Releasing iterator binding:allClients1Iterator1
    <DCIteratorBinding> <releaseDataInternal> [12423] Releasing iterator binding:allClients1Iterator2
    <ApplicationPoolImpl> <resourceStateChanged> [12424] ApplicationPoolImpl.resourceStateChanged wasn't release related. No notify invoked.
    <ApplicationModuleImpl> <resetState> [12425] Resetting AM=Root
    Is there any way to keep the session alive and keep the application state alive till session times out (4 hours in this case).
    Do I need to setup any other parameters etc.
    Thanks in advance.

    You should read http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcstatemgmt.htm#sm0318 and http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcampool.htm#sm0299 as these parameters control when the application module gets passivated.
    However, if you see this kind of problem it points to a general problem with activation/passivation in your application modules. I strongly recommend that you test your application with application module polling turned off. Then the application module is passivated after each request and errors in this region should pop up even on the developer pc.
    For more info read http://tompeez.wordpress.com/2011/07/08/jdev-always-test-your-app-with-applicationmodule-pooling-turned-off/
    Timo

  • One application module with 3 differente data base connections

    I have 3 different servers for data base connections. The main is "sys", the second "stanby" and the third: "bdbatch". In the old application,that i m re programating, uses a properties to read the connection. If the main is not available then goes to the stanby an then to the third. With this new application with adf i have to do the same. So how can i configure the application module to do this? do i have to make extra code? or just configure an xml file??

    i faced this problem before in Dynamic JDBC Credentials topic solution provided by Steve Muench (to make your AM Databse Connection to be dynamic as you need).
    http://smuenchadf.samplecode.oracle.com/samples/11gDynamicCredentials.zip
    Note : Example Contains the Full JDBC Connection String in dynamic way
    i finished this solution in my App and Successed.
    Thanks

  • ADF Libary Issue - Application Module disappear from data control

    Hi All,
    I am facing an issue while adding an Application module to an ADF project as an ADF libray.
    I have two applications - ADF Application1 with Model1 project having an Application module AM1, ADF Application2 with Model2 project having an Application Module AM2
    I have created an ADF library jar file of Model1 project.
    When I add it to Model2 project, the Application Module AM2 of Model2 disappears and Application Module AM1 from the library appears in data control.
    Please suggest what could be wrong.
    Regards,
    Rekha

    Hi,
    verify that both application modules don't share the same ID in their databindings.cpx file. Which release version of JDeveloper 11g are you on ?
    Frank

Maybe you are looking for