"Sharing" a stateful session bean between two servlets, beans

Hello!
I just started to learn some java ee programming and was wondering how i would share one stateful session bean between two servlets.
I created the bean with @Stateful.
I tried to inject the stateful bean in both servlets by @EJB and i can manipulate the object, but each servlet seems to have its own object.
The bean has a remote interface that it implements.
What i also tried was to add the mappedName to the @Stateful expression. Something like: @Stateful(mappedName="name") and to use the bean by @EJB(mappedName="name") but it had no effect.
Im using glassfish 2.1 with netbeans 6.7.1 as my environment (standard settings)
dummy question, but i googled like hours and couldnt find anything : \
hope someone can help and sorry for my bad english
greets and thanks

Hi there!
I think you are searching for something like an application wide singleton. There is the possibility to define such one in the Glassfish admin console.
Hope this helps!

Similar Messages

  • How exchange messages between two user-bean instances?

    Hi,
    I would like to let several user to log-in my web site (I'm using tomcat) and then let them exchange some messages until they are logged-in. Is there a way using JSF?
    I was thinking about implementing a list of messages inside each user-bean. The user should know that other users are logged-in, that could be listed in a table, and click on its name. I would like that the click action create an item in the list valiable of the selected user. Is that possible using JSF? I didn't find any of such kind of communication between two user-bean instances.
    Do you have any hints? Is that the right way or is there other possibilities?
    Thanks

    You could get hold of a map of sessions in the application scope. Make use of HttpSessionListener to add/remove sessions to/from the map.
    JSF is just another component based MVC framework on top of JSP/Servlet. Everything which you can do in JSP/Servlet is just still possible. You only need to understand how JSF works under the hood.

  • LOOKUP OF beans between two jar files

    How to lookup beans between two jar file
    I have two jar files named as ejb1.jar , ejb2.jar .
    both the <ejb-name> are same..
    InitialContext ctx = new InitialContext();
    Object te = ctx.lookup("test");
    if i want to lookup for 2nd jar (ejb2.jar)which has the same <ejb-name> how to do..
    helpp !!!!!!!
    prakash

    Hi,
    No it would not be possible to differentiate the data just by using the dump files. You need to import these dump files in the database and then you can compare it for any difference.
    Regards
    Anurag

  • Communications between two Backing beans

    Hi all,
    Currently I am working in an application which contains two pages. For eg page1.jsp and and page2.jsp which contains separate backing beans and JSP pages.Here I have included page2.jsp with page1.jsp using jsp:include which will be shown in a rich:modalpanel.This rich model panel will be rendered only when a button is clicked, say choose button.
    page1.jsp
    <h:form>
    // page1 jsp codes written using JSF
    </h:form>
    <<rich:modalPanel id="lPanelId" autosized="true" top="20px" left="90px" moveable="true" styleClass="rich-modalpanel rich-mpnl_panel">
                    <jsp:include page="/page2.jsp"/> // Include page2.jsp using a modal panel
                           </rich:modalPanel> I have used two seperate forms for each page.Though I have used jsp:include the forms of two pages(page1 and page2) are submitted when clicked the link of page1. So If I change anything in page1 for example if I selected a check box and when I clicked the choose button in page 1 inorder to include page2.jsp in a modal panel. If the same check box takes place in Page2.jsp means it should also be selected but I cant able to communicate between the two backing beans.because the page1 and page2 constructors are called when the page 1 is loaded.So I cannot communicate between page1 and page2 after the choose button action.
    Please anyone out there give me some valuable inputs on this regardings.
    Thanks in Advance

    chrisjohn wrote:
    Hi everybody,
    I have used <jsp:include> tag in a jsf page to include another page(which comes in a modal panel).I would like to know how to pass values from the first backing bean to second backing bean without any button action or Html form.please give some valuable inputs on this regarding.
    Thanks in AdvanceJust access the backing bean the usual way. It is also available there in the included page.

  • Problem with a 1:M relationship between two entity beans

    I am having trouble trying to implement a 1:M relationship between two EJB2.0 entity beans using and EJBQL query. I have an ApplicantEJB, which contains a collection of phone numbers. The applicant table in the database has one primary key, applicant_id. The applicant_phones database table has a compound primary key--applicant_id and phone_type_id--so I have implemented a custom PK class to represent this, PhonePK. I have implemented a findByNameAndPhone method in my ejb-jar.xml file with the following syntax:
    SELECT object(a) FROM applicants a, applicant_phones p where a.applicantID = p.applicantID and a.name = ?1 and p.phoneNumber = ?2
    If I deploy this, Orion/OC4J translates the query in the orion-ejb-jar.xml with an incorrect reference to the applicant_phones.applicant_id column:
    SELECT a.applicant_id FROM applicants a , applicant_phones p WHERE ((a.applicant_id = p.applicantID ) AND (a.name = ?) AND (p.phone_number = ? ))
    I must have something wrong with the ApplicantEJB and PhoneEJB primary key mappings in my orion-ejb-jar.xml file, but I have tried many different combinations of values and keep getting them overwritten by the container with each deployment. Why is Orion/OC4J defaulting the applicant_id reference to the ob[i]Long postings are being truncated to ~1 kB at this time.

    I have posted excerpts from my orion-ejb-jar.xml file in this posting: Problem mapping a 1:M relationship between two entity EJBs w/ a compound PK
    Sorry for the duplicate postings, but I was getting errors on the submission.
    April

  • DB connection between Two servlets

    Hi,
    I have Two servlets, servlet1,servlet2.
    In servlet1, I have written Connection Pooling using java class and In the INIT method I'm writing the database connection,
    My Question is, How to use the same DB connection in servlet2 ?
    here is my code (some portion) :
    public class abc_internal extends HttpServlet
    { private ConnectionPool pool;
    Statement stmt = null;
    Statement stmt1 = null;
    Statement stmt2 = null;
    ResultSet abc = null;
    ResultSet Name_Header = null;
    private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
    public void init(ServletConfig config) throws ServletException
    try
    pool = new ConnectionPool("oracle.jdbc.driver.OracleDriver","jdbc:oracle:thin:@IPADDRESS:1526:DB NAME","USERNAME","PASSWORD",5);
    }catch(Exception e)
    throw new UnavailableException("Couldn't create Connection Pool.....");
    PLEASE Help me...
    Thanks in advance.

    Thanks for the reply... I'm new to Java...I would appreciate, if you can show me as a example for the above code...
    Thanks.

  • Sharing a Time Machine backup between two Macs

    Hi
    So I was running my music production software on a first gen Mac Mini.  I would store all of my project files on an external drive and backup that external drive to a second external drive using Time Machine.  I had Time Machine set so that it excluded everything on the Mac Mini except my original external drive.
    Now I've stepped up to the latest and the greatest Macbook Pro 15 inch.  I'm running the same music production software on it and loading up all my files from the same external drive.  When I go to back it up with Time Machine, it wants to start a separate backup for the Macbook Pro, even though it is only backing up the same stuff from the Mac Mini.  The thing is that there aren't any system specific files being backed up, just my project files.  For the life of me I can't get it to continue the original backup.  I plan on using both Macs for music production and plan on using the same drive for both.  I would like to back up every time I finish a session on either computer.
    Is there anyway I can get Time Machine on each computer just continue one backup??
    I know I can access the backup from each computer by "Browsing Other Time Machine Disks", but I want to backup, not restore.
    If not, is there any other software you can recommend?  Although I would hate to lose the backups that I already do have...
    Thanks!
    jg

    That's probably a good option for you. It's not easy to keep a 3 way sync.
    If you really want to keep certain files synced on your Mac Mini, you might want to look at ChronoSync. It appears it's a good backup-sync program. Don't know if will keep synced between the 2 computers and external drive without a little manuel effort, but would be easy to sync at least 2 devices, such as MacBook to Mac Mini, or MacBook to external.
    If you don't need to keep synced files, then best option is to do a full TM backup of both computers. Since you have 2 externals, use one for each. You can still use TM to access files if you need, and if you have a hard drive failure, it's an easy replace drive and restore the whole computer from TM.
    And don't overlook the option of File Sharing between the 2 computers to access each others files or a shared folder. That's a real easy way just to copy a few files when you need them.
    Anyway, Good Luck and Happy Holidays

  • Sharing iPhoto library over network between two Macs

    I would like to edit/create albums via sharing.
    I can easily share photos between my two Macs via sharing, but I can't move photos between albums, can't create new albums, etc. (I would like to be able to use my laptop in our home network to modify the albums on the PowerMac in the basement.)
    I don't want to move files from one computer to another; via sharing, I essentially want to be able to modify the host library's albums. I don't want to edit the photos as much as I want to move them. Is this possible?

    Hi there,
    There are two ways that I have tried to share a Library. The first method was to delete the empty library on my laptop and start iPhoto. The application could not find the library and asked me where it was. I linked it to the library on the other computer over the network. This method works but can be very slow when editing or scrolling (especially when using AirPort). It is also safer to only have one iPhoto accessing one library at a time.
    The other way that I have been able to relibaly access and edit an iPhoto library on another mac was by using Virtual Network Computing (VNC). Essentially it provides the user the ability to see and controll another computer on the network from their machine. It does work and is alot faster than the first method but the downsides are that the host computer cannot be used at the same time and VNC software does not resize the desktop when, for example, accessing a 20" screen from a 12" laptop. This means that you have to resize the iPhoto window to fit on the smaller screen.
    For the host computer (server) I used Real VNC and for the network client I used Chicken of the VNC.
    The software works well and is usefull to access emails on the computer in the office from the living room. I have to say that I have stopped using these methods as they both tend to hogg the network and other users in the family are stuck for long periods of time trying to load a web page.
    Hope this helps,
    Dan
    iMac G5   Mac OS X (10.4.7)  

  • Is there any way to shared Lync SIP address space between two organizations for long term coexistence as in the email world?

    -EnabledSharedAddressSpace is this an option is this only for Lync hybrid in office 365

    Hi mombu,
    Sharing of sip domain is not possible in Lync.
    The DNS record for automatic sign in can only point to the Edge server of one Lync environment.
    If user who is from different environment tries to login to Lync externally using automatic sign in, they will be directed to the Edge mentioned in the DNS record and 
    will get a 404 error because Lync server does not recongnize the user and will not be able to login to Lync.
    Possible solution:
    Change sip address of the users of one Lync environment and configure federation between the two sip domains.
    Change will require change of sip address of users.
    Change of certificate for Edge and reverse proxy.
    Change of SRV records.
    Contacts needed to be removed and added with correct sip address.
    Meeting needs to be rescheduled .
    Central forest solution:
    Create a forest trust between the two forests.
    Use Lync server of one environment.
    Configure Lync for a central forest topology
    https://technet.microsoft.com/en-us/library/gg398173.aspx
    by creating contacts for each user from the other domain and enable the contact for Lync.
    All users will have the same sip domain and can login using their login credentials but will be hosted on the Lync server in one forest.
    Best regards,
    Eric

  • Sharing an external hard drive between two macs

    Could someone please give me step-by-step instructions on how I can share an external hard drive between my powerpc(running 10.4.11) and my macbook air(running 10.5.6)? I would like to do this with out any external software.

    Anthony1900 wrote:
    Could someone please give me step-by-step instructions on how I can share an external hard drive between my powerpc(running 10.4.11) and my macbook air(running 10.5.6)? I would like to do this with out any external software.
    Simply connect the drive to one of the two computers and there you are!
    Use your network and turn on file sharing. It's that simple.

  • Session Tracking between two tomcat instances

    Hi.
    Am using two different tomcat instances. i want to pass a username from one context to another thru jsp/servlet. can anybody help me without the knowledge of cookies...
    for ex:
    webapps
    - app1
    - app2
    i want to pass username from app1 to app2.
    thanks

    Yep,
    In the servlet on ServerA have setSession and getSession methods.
    When you create the session and when you add to it, call setSession:
    setSession(session);This is what the setSession method looks like
    public void setSession(HttpSession session)
      this.session = session;
    }When servletA calls servletB, pass an instance of servletA to it.
    ServletB b = new ServletB(servletA);servletB's contructor:
    public ServletB(servletA)
      this.servletA = servletA;
    }Now you can call ServletA's getSession method from ServletB:
    session = servletA.getSession();and this is what ServletA's getSession looks like:
    public HttpSession getSession()
      return session;
    }

  • Sharing a single itunes library between two computers - must be possible!

    Hi there,
    This is probably a commonly asked question, but I cannot find a step by step guide to doing it (if indeed it is possible).
    I have got a copy of itunes running on my media computer/server in my living room. What I want is to connect my laptop over the network and share this library - the effect being that it is like I am using the original computer.
    In essence I want to be able to add muscic, edit tracks, update my ipod from either computer and the changes be made in respect of both computers. I suspect that this is done by making sure that the laptop uses the same database information as that created by my main computer but am not really sure where to start.
    Could anyone perhaps give me a step by step guide as to how to do this - a single database that can be used by two computers each running itunes. One thing I am pretty sure is not possible is to for two people to be using itunes at the same time, so I would ahve to avoid this.
    Thanks very much.

    Ah. Sorry about that, I guess I skimmed over the add music part. Correct, in that the home sharing wouldn't allow you to add music to the media server library. The only thing that I can think of that would give you what you want is to use a shared folder on the network and then map both of the iTunes to that folder. At least that way music would go into the same folder. The only question is about the library on the other computer, if it would get updated when you use the other to add music.

  • Shared variable does not work between two computers

    I am using LabVIEW 8 on Windows XP computers.
    1. On one computer I have created two projects, writeProject and readProject.
    2.  In the writeProject I have a shared variable, writeData, which is "network-published" double. In this project I have a writeData.vi which in while loop assigns a random value to the writeData variable.
    3. In the readProject I have a shared variable, readData, which is "network-published" double and is bound to the writeData variable.  This is on the same computer as the writeProject.
    4. I run both the writeData.vi and the readData.vi and all works fine.
    5. Now, I create a readProject on a diferent computer.  Perform all the steps as described above and also in tools/shared variable/register computer, I have entered the IP address of the target computer on which the writeData shared variable exists.
    6. Binding the readData variable fails in the following way.  When I browse for the source, in the "Select Source Item" dialog, I see <IP> <Populating Node...>, where <IP> is the IP address of the source computer (on which exists the writeData shared variable).  A very long time later it is still "Populating Node...".  Neddless to say, this readData.vi does not work!
    What am I doing wrong?  Or, perhapse what else do I need to do to make it work?

    Hi,
    I would suggest checking out the two KnowledgeBases I have linked below for common issues with Network Shared Variables. Let me know the results. Thanks!
    Troubleshooting Network-Published Shared Variables
    Why Are My Network Shared Variables Taking Very Long to Initialize?
    Stephanie

  • Sharing the same Aperture Library between two Mac's?

    gents does any of you manage to share the same Aperture Library between your iMAC and a MacBook?
    How can I do it without risking to lose anything or to jeopardize the integrity of my library backup?
    the idea is to work on Projects while I am on the move and placing them back into my Main Library sitting on my iMAC at home...
    Thx!
    P

    For each project you want to work on, CTRL + Click the project and "Export -> Project as new library". These new temporary libraries can be moved to your MacBook for working on.
    When you come back, import the libraries back to your main Aperture Library with "File -> Import -> Library" and choose to merge your changes. The changes you made will be added to your main library. The temporary libraries can then be deleted.
    Deleting them avoids the temptation of working on them later, possibly creating conflicts. It best to export new copies from your main library each time you work away so you know you have current up to date versions.
    -Najinsky

  • Communicate between two backing beans

    Hi !
    How can I communicate between backing beens ?
    I would like to put data from Bean1 to Bean2.
    This is my code in Bean1, I try this:
    Bean2 b = new Bean2();
    //... b settings...
    //Map map = facesContext.getExternalContext().getRequestMap();
    //map.put("Bean2", b);
    HttpServletRequest request = (HttpServletRequest)facesContext.getExternalContext().getRequest();
    request.setAttribute("Bean2", b);
    So I put Bean2 instance in request, but JSF created new instance :(
    How can I solve this problem ?

    This article might give you some new insights: http://balusc.xs4all.nl/srv/dev-jep-com.html

Maybe you are looking for

  • Is there a way to get back all my purchased music if my hard drive crashed and I did not back it up on any external hard drive?

    My computer crashed a couple of weeks ago and I have just redownloaded iTunes. I was hoping someone would be able to answer the question I have posted and give me instructions as to how to redownload if at all possible the music that I purchased. Tha

  • I-tunes and Quicktime  make a fatal error on Vista ?!

    Hi i'm italian ... i don't write a good english but i try too explain my problem... i have a laptop HP pavilion dv6000 with windows vista... i 2 week ago buy a ipod touch 2g ... i try to install itunes ... i download it from apple.it. during the inst

  • File gateway.cfg not under $SIEBEL_ROOT\gtwysrvr\bin, why?

    Hi all, I noticed that the file gateway.cfg is not under $SIEBEL_ROOT\gtwysrvr\bin. No gateway.cfg is found anywhere in my Siebel directory. When I try to connect to the Siebel Gateway Name Server while running the Server Configuration Wizard it says

  • Barcode scan on WPF agentry client

    Hello to all, I use a barcode scan field type on window screen for WPF agentry client. When I try on our tablet device, user input is not enable but the barcode scan does not work fine. It seems that the field does not recognize the scanning. In part

  • Disable Status Manager Approval

    I Have the Task Status Manager Approval set to disabled but the person who published the project is seeing task approvals in the Approval Center.  Is this the designed behavior? The behavior I want is when someone submits their timesheet, I want it t