Bean connections in session

If I have two managed bean objects (Bean1 and Bean2), both in the session, how does one refer to the other? Say a method in Bean1 wants to reference a setter in Bean2 -- I don't want to initialize a new Bean2, but I want to use the Bean2 object already in the session. How is this done in the bean?

You can use the value buinding. For example:
FacesContext fc = FacesContext.getCurrentInstance();
Bean2 foo = (Bean2) fc.getApplication().createValueBinding("#{Bean2}").getValue(fc);if the Bean2 does not exist, it will be created, otherwize, the existing one will be used.

Similar Messages

  • Session bean connecting a data source

    Hi there,
    I'm trying to make a session bean connect to a DataSource used by my Entity Beans. I'm using JBuilder5 and Borland Application Server.
    Here is the code in my SessionBean:
    InitialContext ic = new InitialContext();
    DataSource datasource = (DataSource)ic.lookup("java:comp/env/jdbc/DataSource");
    System.out.println("Datasource=" + datasource.toString());
    Connection dbConnection = datasource.getConnection();
    Statement stmt = dbConnection.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT ID FROM PUBLICATION");
    rs.next();
    System.out.println(rs.getString("ID"));
    I have already put a reference to this DataSource in the Deployment Descriptor but I get the following error message:
    [Microsoft][ODBC Driver Manager] Data
    source name not found and no default driver specified
    But with the CMP Entity Beans the DataSource works.
    I would appreciatte any help. Thanks in advance.
    Nei.

    Hi GHz,
    I have a method in my Session bean QuerySessionBean called showData() that have the code I typed before. Sorry, but what do tou mean when you say that I must excute the query inside the session bean? I'm testing the method in a client using queryHome.showData().
    Thanks for answering,
    Nei

  • Error(2): Unable to find class for bean: connection defined by tag...

    I created a project, and a JavaBean that connects to the database and I want to use it in a JSP page that exists in my project.
    Bean:
    package BeerPackage;
    import java.sql.*;
    public class ConnectionBean
    JSP:
    <%@ page import="BeerPackage.*" contentType="text/html;charset=windows-1252"%>
    <jsp:useBean id="connection" class="ConnectionBean" scope="session"/>
    Then I get the error:
    Error(2): Unable to find class for bean: connection defined by tag with class: ConnectionBean
    When I try to build the JSP
    Any ideas?

    Seems even though I have an import, I still have to specify the package name in front of the useBean.
    What am I missing here?

  • Multiple instances of the same bean class in session?

    I�m trying to think of a way to have multiple instances of the same bean class in session scope using JSF. For example, let�s say that I have two <h:dataTable>s on the same page. They both use the backing bean called genericBean. Now, the content for genericBean will be different for each <h:dataTable>. In fact, the data source that backs genericBean is not known until runtime. It could be a database, web service, etc.
    What I would like is for when JSF needs access genericBean instead of looking for the value with key �genericBean� in the session map it looks for �genericBean_[some runtime ID]�. I could specify this id in EL on a custom component, as a request parameter or whatever.
    I think that I need the bean to be in session scope because the tables are complex and I want them to be editable.
    I have some ideas about how I can do this but I was wondering if someone has already solved this problem or if there is a standard way to do this using tools like Shale, etc.
    Thanks,
    Randy

    Well, I came up with an interesting solution to this so I thought that I would post it here.
    I have a page that looks like this.
    <html>
    <head>
    <title>My Page</title>
    </head>
    <body>
    <f:view>
    <f:subview id="component1">
    <jsp:include page="component.jsp">
    <jsp:param name="id" value="a" />
    </jsp:include>
    </f:subview>
    <hr>
    <f:subview id="component2">
    <jsp:include page="component.jsp">
    <jsp:param name="id" value="b" />
    </jsp:include>
    </f:subview>
    </f:view>
    </body>
    </html>
    And component.jsp looke like this.
    <f:verbatim>
    <p>
    <h1>Component
    </f:verbatim>
    <h:outputText value=" #{param.id}" />
    <f:verbatim>
    </h1>
    </p>
    </f:verbatim>
    <h:form>
    <h:outputText value="#{component.id}" />
    <h:outputText value="#{component.value}" />
    <h:commandButton value="increment" action="#{component.increment}" />
    <h:commandButton value="decrement" action="#{component.decrement}" />
    <f:verbatim>
    <input type="hidden" name="id"
    value="</f:verbatim><h:outputText value="#{param.id}"/><f:verbatim>" />
    </f:verbatim>
    </h:form>
    The idea is that I want component.jsp to be initialized differently based on the id param. The component managed bean is configured to be in session scope but I want the component instance for id a and id b to be different instances in session scope. Therefore, I added a custom variable resolver to handle this.
    public Object resolveVariable(FacesContext context, String name) {
    // This id will be different for the different subviews.
    HttpServletRequest request = (HttpServletRequest) context.getExternalContext() .getRequest();
    String id = request.getParameter("id");
    // If there is an id in the request then check if this is a bean that can have multiple
    // instances in session scope.
    if ((id != null) && (id.length() > 0)) {
    ExternalContext ec = context.getExternalContext();
    // Build the new name for the key of this bean
    String newName = name + "_" + id;
    Object value = null;
    // See if the bean instance already esists.
    if ((null == (value = ec.getRequestMap().get(newName))) &&
    (null == (value = ec.getSessionMap().get(newName))) &&
    (null == (value = ec.getApplicationMap().get(newName)))) {
         // We could not find the bean instance in scope so create the bean
         // using the standard variable resolver.
    value = original.resolveVariable(context, name);
    // Now check if the bean implements that page component interface. If it is
    // a page component then we want to rename the key to access this bean so
    // that the instance is only used when the id is provided in the request.
    // For example, if there are two components (a and b) we will have in session scope
    // component_a and component_b. The will each point to a unique instance of the
    // Component bean class.
    if (value instanceof PageComponent) {
    // Try to get the value again
    if (null != (value = ec.getRequestMap().get(name))) {
         // Initialize the bean using the id
    ((PageComponent) value).initInstance(id);
    ec.getRequestMap().remove(name);
    ec.getRequestMap().put(newName, value);
    } else if (null != (value = ec.getSessionMap().get(name))) {
    ((PageComponent) value).initInstance(id);
    ec.getSessionMap().remove(name);
    ec.getSessionMap().put(newName, value);
    } else if (null != (value = ec.getApplicationMap().get(name))) {
    ((PageComponent) value).initInstance(id);
    ec.getApplicationMap().remove(name);
    ec.getApplicationMap().put(newName, value);
    return value;
    return original.resolveVariable(context, name);
    }

  • Beans connectivity fails in CR Developer

    Hi,
    I hope this is the right place to ask. We are currently testing CR 12 with Java beans as a data source, but somehow it won't work. I did set up the Java connectivity like it was described in "crxi_java_bean_connectivity.pdf", i.e. set the classpath and created a class that provides a java.sql.ResultSet from a static method.
    When I try to add the bean connectivity in CR Developer by entering "com.example.sub.pckg.MyClass" in the wizard, CR adds the class as a data source but it doesn't find the ResultSet providing method.
    Removing the package/path yields the following error:
    Failed to open the connection. Details: Unexpected error
    Logon failed.
    And it doesn't show the name of my connector class in the dropdown box of the wizard in the first place. What may have been gone wrong? Perhaps it's a bug? Any help is appreciated.
    Kind regards, P. Müller.

    I've seen this sometimes happen if there are other classes in the javabeans classpath folder that do not involve returning back resultsets.  What appears to happen is that Crystal Reports goes through all the jars / classes in that folder, and if it runs into something it doesn't understand, it doesn't process the rest of them (This is what appears to happen).
    The solution has been to remove all other classes and jars except for the specific class that returns back the resultset.
    a programmer learning programming from perl is like a chemisty student learning the definition of "exothermic" with dynamite

  • Crystal report Java Beans Connectivity

    Hi
    My name is Bach Ong. I.m currently migrating Crystal reports 10 to Crystal reports 2008 using Java Beans Connectivity. Using ResultSet as dataset. all results are return alright, EXCEPT for string type fields. The data for STRING type fields are some how suppressed. But if i executed the beans within eclipse the the string field is populated with data.
    can someone assist me with this issue.
    Thanks
    Bach Ong

    Some suggestions I would give for this are:
    1. It may be a fault with the data itself.  Specifically, if you have a string field that contains invalid or null data (Instead of an empty string), it may be causing an error to be thrown when the report engine tries to process the string fields - and it thus fails on all string fields.
    So please try this with some data where all fields contain valid non-null, non-empty data and see if it works.
    2. One of the difficulties with javabeans is that they don't give proper error messages.  However, there is a way to kick off the javabean java process in the crystal report designer which allows you to debug your javabean inside the report designer.  I have attached a sample that shows how to do that - and that should get you the real error message of what is going wrong.
    Note: Due to the way these forums work - it will only let me attach a file if it is named with the .txt extension.  You will need to extract the txt file and then rename it to .zip (annoying I know).
    Shawn

  • Java bean connectivity -

    Hi,
    There are some issues while I am using webservice connection from crystal report.(I am using webservice with ws security but my cr doesn't support this. This create problem while I am calling cr from my java application).
    I tried Java bean connectivity .. but facing some problems - I would like to write a java bean which will retrieve data from my webservice and need to return to cr. Webservice return data as "soap xml", how can I convert this to resultset. Can I add my data directly to the xml before passing to the cr? Or can I use any other return type from my java bean.
    Could I provide a struts application url(action url) as a datasorce to the cr? If so how can I achieve this and what should be the return type.  Please advise the better datasource connection to resolve this issue?
    I want to call the report from java application and need to deploy the same in the Crystal enterprise server
    Thanks in advance
    Thomas

    Please re-post if this is still an issue or purchase a case and have a dedicated support engineer work with your directly

  • XFDesktop not running, FAILED TO CONNECT TO SESSION MANAGER [SOLVED]

    Hi all, new to the arch forums, I've recently installed arch with xfce4, and I've been having trouble changing the desktop background as the GUI for it will flash up then close instantly. I tried to reload xfdesktop with xfdesktop --reload, this returns "xfdesktop is not running". Running $ sudo xfdesktop returns:
    (xfdesktop:5211): GLib-WARNING **: (gerror.c:381):g_error_new_valist: runtime check failed: (domain != 0)
    Failed to connect to session manager: Failed to connect to the session manager: SESSION_MANAGER environment variable not defined
    xfdesktop: cairo-scaled-font.c:459: _cairo_scaled_glyph_page_destroy: Assertion `!scaled_font->cache_frozen' failed.
    Also, when I look in xfce4-session-settings, all xfce applications are running but xfdesktop isn't there.
    Thanks in advance
    Last edited by portalin (2015-01-11 15:12:36)

    Trilby wrote:
    portalin wrote:Running $ sudo xfdesktop returns ...
    Prepending sudo to random commands will eventually break your system.  Don't do it.
    In this case it simply prevents it from working as the session manager is running for your user not for the root user, so this command has nothing to connect to.  Remove 'sudo'.
    If I run just $ xfdesktop I then get the same error
    (xfdesktop:2166): GLib-GObject-CRITICAL **: g_value_get_uint: assertion 'G_VALUE_HOLDS_UINT (value)' failed
    xfdesktop: cairo-scaled-font.c:459: _cairo_scaled_glyph_page_destroy: Assertion `!scaled_font->cache_frozen' failed.
    Aborted (core dumped)

  • Request and session issues-how to remove a bean from a session

    Hi
    I am implementing copy and move functionality in my application. I need some info to complete that.
    The copy functionality is like this.....From a summary page which consists a Datatable and checkbox...
    I will select a checkbox beside as a copying reference..and click on next..
    In the next page I will get a copying reference bean and a drop down select list box consists of 1-10, I will select some value and click on next. then in the next page, I will get selected no of rows of that copying reference. then when I click on finsh , it will add into database...
    And the next page will open showing .....status of inserting into database..
    the action method I am calling is....
    public String saveCopyingRoutes()
    log.info( "Into saveCopyingRoutes method" );
    String returnStr = UIConstants.RETSTR_SUCCESS;
    // : Get all the rows
    // Read each row and insert each row into database under a particular
    // gateway end point.
    int numRows = table.getRows();
    log.debug( "no of rows-->" + numRows );
    for (int rowIndex=0;rowIndex<numRows;rowIndex++)
    log.debug("value of rowIndex-->"+rowIndex);
    RoutingEntry routingEntry = (RoutingEntry) FacesContext.getCurrentInstance()
    .getExternalContext().getSessionMap().get( "RoutingEntry" );
    try
    // -Need to query using RoutingEntryMgerImpl() class
    new RoutingEntryMgerImpl().addRoutingEntry( routingEntry );
    message = " Verifying Copy sheet " + rowIndex + ".....\n"+
    " Successfully verified datafill in copy sheet" rowIndex".....\n"+
    "Adding copy sheet "+rowIndex+"to the database...\n"
    + " Successfully added copy sheet" rowIndex"to database.....";
    messageList.add( message );
    log.debug("*********************"+messageList.size());
    log.debug("message----->"+message);
    log.debug("*********************");
    catch (NrsProvisionException pe)
    catch (Exception e)
    message = "Unsuccessfully added copy sheet "+rowIndex+"to the database";
    //Show the corresponding error....
    // Throwing generic exception ...?
    e.printStackTrace();
    log.info( "saveCopyingRoutes method return value: " + returnStr );
    return returnStr;
    now the bean is in session scope , let me know how to remove from the session, is there any better way to implement this functionality...

    Read the instructions.

  • Increasing max-streaming-connections-per-session has slow acknowledge response?

    Our application is a Flex GUI with a WebLogic Server (BlaseDS) on a private network.  We were originally using IE 6, but have upgraded to IE 8.
    I am trying to use publish/subscribe messaging to monitor lengthy processes on the server and received incremental data.  With 1 such process everything works fine.  But we want to allow the user to subscribe to more than 1 message destination.  So I increased the "max-streaming-connections-per-session" (default is 1) in the services-config.xml file
         <channel-definition id="process-notification-streaming-amf"
              class="mx.messaging.channels.StreamingAMFChannel">
              <endpoint url=https://{server.name}:{server.port}/{context.root}/messagebroker/streamingnotificationamf"
              class="flex.messaging.endpoints.StreamingAMFEndpoint"/>
              <properties>
                   <user-agent-settings>
                        <user-agent match-on="MSIE" kickstart-bytes="2048"
                             max-streaming-connections-per-session="3" />
                   </user-agent-settings>
              </properties>
         </channel-definition>
    If we leave max-streaming-connections-per-session as the default value of 1 and try to subscribe to another message destination we get an error indicating limit has been reached:
         [BlaseDS]Endpoint with id 'process-notification-streaming-amf' cannot grant streaming connection to FlexClient with id '7FFC82DE-etc ' because max-streaming-connections-per-session limit of '1' has been reached.
         We upgraded to IE8 as documentation indicates IE8 allows for an increase of max-streaming-connections-per-session, where IE 6 is limited to 1.  But increasing max-streaming-connections-per-session does not quite solve the problem.  We have 3 consumers; consumer1, consumer2, consumer3.  For each of these consumers, we add event listeners for MessageAckEvent.ACKNOWLEDGE and MessageEvent.MESSAGE.
         We call consumer1.subscribe().  When we receive the acknowledge message, we call consumer2.subscribe() (likewise with consumer3)
         The problem is it takes over 2 minutes to receive the acknowledge message from the call to consumer1.subscribe().  (With max-streaming-connections-per-session set to 1, the acknowledge message is received in a few seconds.)
         So, increasing max-streaming-connections-per-session removes the error about reaching a limit, but it appears to come with a cost of a big delay in a long delay on the call to subscribe?  Or is there something we are missing?

    I guess I will answer my own question.  Hopefully this will be useful to someone else in the future...
    The problem was coming from IE being limited to 1 connection by the registry.  The solution can be found at:
    http://support.microsoft.com/kb/282402
    I manually performed the steps to update the registry, though microsoft provides a "Fix It"; MicrosoftFixit50098.msi
    One other key element was to make sure to have kickstart-bytes="2048".

  • Max streaming connections per session error

    I have a flex application that uses messaging with a streaming AMF connection, falling back to polling. When the max number of streaming connections on the server is reached, it does fall back to polling (at least it prints the max-streaming-clients error but the client connects, so I assume it is falling back - how can I tell?). However, occasionally the streaming connection will not initialize and it does not fall back - no messages are received on the client. The following error is logged on the server:
    [EMST]09/25/2008 13:43:18.231 [ERROR] Endpoint with id 'my-streaming-amf' cannot grant streaming connection to FlexClient with id 'D5B8E3A1-1A1C-063E-84A6-6A743A1E4EE0' because max-streaming-connections-per-session limit of '1' has been reached.
    This would make sense if the issue was caused by trying to initialize the streaming connection in two tabs of a browser, but I am only trying to initialize in one tab. Closing the browser (and thus destroying the session) does not fix it. The only solution I've found is to reboot the client machine. This has happened in both FireFox 3.0.2 and IE 7.
    (1) What could cause the client to get in this state?
    (2) When it happens, why doesn't it fall back to polling? Is the fallback only for when the server max connections is reached? When the streaming connection doesn't initialize, no messages are received.
    (3) Is there a way to explicitly close the streaming connection on the client so we can fix this without rebooting?
    Thanks!

    Hi Mary. If you turn on Debug level logging on the client and the server you should be able to tell if you have fallen back to a polling channel after the attempt to connect over the streaming channel has been rejected. In the client log, you will see the flex application sending poll requests to the server at the polling interval configured in the channel and in the server log you should see that the server is receiving these requests.
    The behaviour you are seeing seems very strange to me. The reason we have the max-streaming-connections-per-session limit on the server is because most browsers limit the number of active connections that can be made to a server from a single session. In IE for example, this is 2. What happens in most cases when the browser's connection limit is reached is that new connections are put on hold until one of the existing connections closes. This would cause your flex application to hang with no errors being reported on the client or the server. This is why we need the max-streaming-connections-per-session setting on the server. This prevents more than one persistent connection from being made from the same session, so the browser should never reach it's max connections per server limit and lock up.
    It looks like you are somehow getting the browser to lock up even though the server is only limiting you to one streaming connection per session. It may be possible to do this if you reload the flex application in the browser (by doing a page refresh) in which case the browser could possibly briefly leave the streaming connection open in the background and when you tried to create a new streaming connection, the browser's connection limit to the server would have been reached and the application could hang. When the application hangs are you reloading the swf/page in the browser?
    I really don't know why closing the browser wouldn't fix the problem. You're right that closing the browser should end the session. If you launch a new browser and load the swf do you get the same "cannot grant streaming connection" error on the server or is the browser just locked up, ie. no error is received on the client and the server?
    You're not using a proxy server or anything like that are you that might be holding a connection open to the server?
    -Alex

  • Max-streaming-connections-per-session limit

    Hello,
    i'm trying BlazeDS with Air app.
    I set blazeDs on a Jboss Server with JMS adapter.
    I configure it with a streamingAMF channel.
    In user agent configuration i put msie, firefox value to 10 for the max-streaming-connections-per-session limit param.
    In Air client configuration i instantiate a producer and a consumer on the same streaming AMF channel.
    After the consumer.subscribe() i launch the producer.connect() on the server i get this error :
    14:25:20,015 INFO [STDOUT] [BlazeDS] Endpoint with id 'my-streaming-amf' cannot grant streaming connection to FlexClient with id '497031A2-7B0D-019A-0E1D-7622A-A631D28' because max-streaming-connections-per-session limit of '1' has been reached.
    Is it a limitation of use of blazeDs with Air app ?

    First, if you change the limit to 10, then it should be 10 and not 1. If you still see 1, then please log a bug.
    Second, you really want this limit to be 1 in IE and 4 in Firefox 2. But there's no reason to have more than 1 streaming connection from the server to the client unless you need to talk to two different endpoints.

  • Viewing Software Demostration in Connect Pro Session

    I'm planning to demonstrate a software application and I'd like to do so
    in a Connect Pro session but am not sure how to do it. The Connect Pro
    session appears as a window on my desktop and the software application
    will appear as another window. Is it possible for me to share the software
    window with session participants?

    This is done though Screen Sharing. The Connect application will minimize to your system tray, and your desktop will be seen in the Share Pod of all the other attendees. Just use your computer as you normally would. When you are finished, you can either select the Connect meeting room from your system tray and press the large Stop Sharing button in the share pod, or select the small Connect icon in your application bar (right or left click) and choose "Stop Sharing".

  • Difference Between Connect,Create Session

    Hi,
    What is the difference between connect , create session ?
    Regards,

    But i grant the user connect but when i try to logon by the user i got error you don't have right to create session?I don't know what you have.
    I don't know what you do.
    I don't know what you see.
    It is really, Really, REALLY difficult to fix a problem that can not be seen.
    use COPY & PASTE so we can see what you do & how Oracle responds.
    Oracle is too dumb to lie about what is wrong.

  • GnomeUI-WARNING While connecting to session manager:Authentication Rejected

    Hi:
    I was running Oracle eBusiness Suite R1211 on Enterprise Linux 5.3.
    When I try to run HelloWorld on OA Framework tutorial I got the following error
    (Gecko:6415): GnomeUI-WARNING **: While connecting to session manager: Authentication Rejected
    Does any one has idea how to resolve the problem?
    Please help
    sem

    Check the DBC file is updated one & are the connection is working or not.
    Thanks
    --Anil                                                                                                                                                                                       

Maybe you are looking for

  • Make to Order Scenario problem

    i want to configure a make-To-Order Scenario i have create an item category  ZTAK  (for Make to order items) ... and assigned it to my sales document type and the Material item category in sales view 2 is 0001 (Make to order) when creating the sales

  • IPod Touch - Unable to restore!

    I have a 32 GB 1st Gen iPod Touch that I bought in the restore mode, thinking I'd be able to fix it easily. Well, clearly that is not the case! I do not know the history of the ipod - if the previous owner tried to jailbreak it or what - although I a

  • Worried about T61 Shipping..​. Share your *US* Experience​s?

    I've been reading the other thread about the T61 shipping and am definitely NOT pleased with other people's experience. It must be a pain to go through, sorry for those that went through it. I just wanted other experiences, as far as those who live i

  • Problem passing texts into sap-script

    Dear Experts, I have a requirement, where I have to pass some text-lines from my selection-screen of the driver-program to the sap-script,i.e. whatever I write in those text fields that should be displayed(printed) on the specified place of my script

  • Icons in Oracle Forms 10g (10.1.2.0.0)

    Hi, How can I center my icons in a toolbar canvas. I'm migrating from Forms version 5 to Oracle 10g and have converted the icons from *.ico files to *.gif files. Any help will be appreciated. :@)))