How to cast back and use a retrieved Session Bean reference in a servlet?

Please help!
1. I invoke a Session Bean from a servlet :
travelagent = home.create();
2. I store the travelagent reference in the HTTP Session :
session.setAttribute( "travelagent" , travelagent );------------------------------------------------------------------------------------------------------------------
Now, in another servlet, I have to retrieve the reference to the EJB from the HTTPSession.
I then have to use this reference to call a business method in the EJB Session Bean.
I have tried two ways to retrieve the reference and cast it before calling the business method. I get errors in both forms of casting.
The Values you will see below in the code:
EJB Remote Interface : TravelAgent (TravelAgent.java)
Business Method : listItineraries( )
Servlet which calls the above method : ListItinerary.java
Line 46 of ListItinerary.java : ArrayList itineraries = traveler.listItineraries();------------------------------------------------------------------------------------------------------------------
The two ways along with the error I get on the servlet page in the browser are :
(A)
TravelAgent traveler = (TravelAgent)session.getAttribute("travelagent");The error I get is :
java.rmi.NoSuchObjectException: CORBA OBJECT_NOT_EXIST 9998 Maybe; nested exception is:
     org.omg.CORBA.OBJECT_NOT_EXIST: vmcid: 0x2000 minor code: 1806 completed: Maybe
com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:208)
     com.sun.corba.ee.impl.javax.rmi.CORBA.Util.wrapException(Util.java:591)
     javax.rmi.CORBA.Util.wrapException(Util.java:277)
     source.traveler.ejb._TravelAgent_Stub.listItineraries(Unknown Source)
     source.traveler.servlet.ListItinerary.processRequest(ListItinerary.java:46)
(B)
TravelAgent traveler  =
(TravelAgent)PortableRemoteObject.narrow(session.getAttribute("travelagent"), TravelAgent.class);The error I get is :
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
     java.rmi.RemoteException
     com.sun.corba.ee.impl.javax.rmi.CORBA.Util.wrapException(Util.java:597)
     javax.rmi.CORBA.Util.wrapException(Util.java:277)
     source.traveler.ejb._TravelAgent_Stub.listItineraries(Unknown Source)
     source.traveler.servlet.ListItinerary.processRequest(ListItinerary.java:46)
Could someone advice on how to retrieve and cast the EJBObject's reference from the servlet so that I may use it to call the business method?
Thanks!

Thanks guys! It worked.
1.. I should have used the handle. Got to coding without going deep in the concepts.
2.. I dont know if I could have used the EJB Reference directly (instead of the handle).
3.. The error was due to me not mapping the servlets with the EJBs that they could use. I continued to get the same error even after using the handle. Once I put the mapping to the EJBs correctly, everything fell in place.
Thanks a lot!
Henry

Similar Messages

  • Retrieving Session bean object in a Servlet from FacesContext Object

    Hi,
    I added code in a servlet to retrieve Session bean object from the Faces Context object. I don't know what the problem was, but when I am accessing the application from two different machines and I am trying to retrieve the value from the session object in the servelet it is giving the value what I set into the session bean on one machine browser into another machine browser. Just I want to know the code which I had included in the servlet is correct or not.
    This is the code I am using in my servelt:
    1) To get the Faces context object
    protected FacesContext getFacesContext(HttpServletRequest request, HttpServletResponse response) {
         FacesContext facesContext = FacesContext.getCurrentInstance();
         if (facesContext == null) {
              //System.out.println("Current context was null...creating one now");
              FacesContextFactory contextFactory =
                   (FacesContextFactory)FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
              LifecycleFactory lifecycleFactory =
                   (LifecycleFactory)FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
              Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
              facesContext =
                   contextFactory.getFacesContext(request.getSession().getServletContext(), request, response, lifecycle);
              //Set using our inner class
              InnerFacesContext.setFacesContextAsCurrentInstance(facesContext);
              //set a new viewRoot, otherwise context.getViewRoot returns null
              UIViewRoot view = facesContext.getApplication().getViewHandler().createView(facesContext, "ContextName");
              facesContext.setViewRoot(view);
         return facesContext;
    2) Code to get the session bean:
    Utils utilsBean = (Utils) getFacesContext(request, response).getApplication().getVariableResolver().resolveVariable (getFacesContext(request, response), "utils");
    Edited by: Ramesh_Pappala on Nov 8, 2007 9:25 AM

    Ramesh_Pappala wrote:
    Hi Raymond,
    Thank you for the reply and can you please send the code No, I cannot do that.
    what you are talking about to get the bean from session through servelet session map so that I can use that one check whether it is working fine in my application or not.
    Thanks.

  • If i buy iphone 5 from the usa can i take it back and use it with my UK O2 sim card and how much will a 16gb iphone 5 cost

    Hi,
    if i buy iphone 5 from the usa can i take it back and use it with my UK O2 sim card and also how much will a 16gb iphone 5 cost in the usa?
    thanks
    Andy

    hi there,
    you could buy it somewhere in Europe. I know Apple sells them unlocked here in Germany and if I am not mistaken also (among others) in France and Italy.
    Yet, as Peter wrote, the warranty can become a problem. Not sure whether a one country only rule goes for the European Community as well though.
    As for the price, the 16 GB model costs 679,- € (equals roughly 550 £). Currently there is an average delivery time of 4 to 5 weeks.
    LTE connections will not work with Orange or Vodafone. Only EE is about to offer a compatible LTE network. DC-HSPA and regular HSPA+ will work fine.
    regards, Chris

  • When I have video clips on my timeline, they do not play in the monitor screen. I hear the sound track but can not see the image. To test if my new files are somehow the problem, I went back and used video files that I used successfully a year ago, and th

    When I have video clips on my timeline, they do not play in the monitor screen. I hear the sound track but can not see the image. To test if my new files are somehow the problem, I went back and used video files that I used successfully a year ago, and they no longer play in the monitor window. I hear the sound track, but do not see any video. Have I changed some setting that controls video playback in the monitor window?

    Randy Ruttger
    Thanks for the follow up.
    Missing in this equation were the version of Premiere Elements that you were using and the computer operating system on which it was running. But...
    The deed is done. But.....Until now and after you went ahead and moved to version 12, we now learn what version of Premiere Elements you were using. We still do not know the computer operating system involved.
    You just said Premiere Elements 10. Premiere Elements 10 is hit by a serious known display issue if the computer uses a NVIDIA GeForce video card/graphics card. In this issue, the only remedy is to roll back the driver version to about May 2013. The description of the problem and how to do the roll back are described in one of the Announcements at the top of this forum. What video card/graphics card does your computer use?
    On another front, Adobe will be releasing a new version of Premiere Elements any day now. No one but Adobe knows the feature set for the new version. That type of information is announced at the moment of release of the new version.
    So the remedy to the problem that you presented in this thread could have been...
    1. Rolling back the NVIDIA GeForce driver version to about May 2013 if possible (Windows 8 or 8.1 64 bit, may not be possible)
    2. Move to another version of Premiere Elements (which you did)
    I offer the above for consideration so that you can review your decisions. We are pleased to learn that Premiere Elements 12/12.1 works for you.
    Please do not hesitate to ask questions and ask for clarifications, but remember that the answers are in the details.
    Best wishes,
    ATR

  • How can I access and use the alphabetical keyboard of the phone ?

    How can I access and use the alphabetical keyboard of the phone ? I cannot find the answer in the manual of use.  Thanks for your help !

    Recently I was abroad and tried to contact my voicemail to check my messages. I was asked to enter a password and did not know how to use the letters below the figures on the keyboard.  I had to give up and wait until I was back in my country (no password is then needed).

  • Hi there, I updated to ML about 3 weeks ago I can not get in to my apps to download it again as when it was installing the first time I decided to skip the part where it said do i want to do the iTunes and iCloud thing. any sugentions how to go back and

    Hi there, I updated to ML about 3 weeks ago I can not get in to my pps to download it again as when it was installing the first time I decided to skip the part where it said do i want to do the iTunes and iCloud thing. any suggentions how to go back and change that part or do I have to download it again.
    Thanks
    GeeRic

    To set up iCloud, open System Preferences > iCloud, and follow its steps to use iCloud

  • How to set-up and use FAMILY Sharing

    Can someone please explain to me in detail how to set-up and use FAMILY Sharing, none of the information I have so far found in the documentation helps at all, in fact it puts you in a constant loop giving the same information over and over again
    We have quite a few devices from ipads, iphones and ipods and I need to set-up Family Sharing.
    We have our main Apple ID which is linked to our Payment method, I have now got my son a new iPad, I have created his Apple ID and set-up a link via FAMILY Sharing to our main Apple ID.
    From what I read we should be able to share our purchased Apps between family members.
    So I figured I would be able to get the Apps now via iTunes that are part of the FAMILY Sharing, however when I go into ITunes (latest version downloaded yesterday) I can only see the Home sharing menu item not FAMILY Sharing, so I cannot work out in Itunes how to get Apps that are FAMILY shared.  So ok I will try and get Apps directly via the Ipad using the App Store.  To test it is working I look for a known paid for App, I then go to download it and it is now asking me to pay for it again. 
    Can someone please explain to me in detail how FAMILY Sharing is supposed to work and how I get it to work please.
    Thanks for your help
    Greg

    Hey GregWr,
    Thanks for the question. The following resources provides some of the best information regarding Family Sharing. Included, you’ll find information on making sure the accounts are set to "Share my purchases”, as well as information on downloading Family Member purchases from the iTunes Purchased section. Please note that some applications are not shareable.
    Sharing purchased content with Family Sharing - Apple Support
    http://support.apple.com/en-us/HT201085
    Which purchased content can I share using Family Sharing - Apple Support
    http://support.apple.com/en-us/HT203046
    If you don't see your family's shared content - Apple Support
    http://support.apple.com/en-us/HT201454
    Thanks,
    Matt M.

  • How do I access and use my Itunes library from a different/new computer?

    How do I access and use my Itunes library from a different/new computer?  My computer is no longer working, so I need to be able to access my library from my wife's computer.

    Your library will only be where you put it.  Copy everything from your backup copy of your old computer to the new one.
    You can redownload some itunes purchases in some countries:
    Download past purchases - Apple Support

  • How do I access and use my iTunes library on a different computer?

    How do I access and use my i Tunes library on a different computer?

    The iTunes library is only where the user puts it.  If desired to have on an additional computer, put it there by copying the ENTIRE iTunes folder from the existing computer to the new computer.

  • I want to buy photoshop creative cloud for teams, how users can install and use it?

    i want to buy photoshop creative cloud for teams, how users can install and use it?

    Cancel old and buy new is the only way I know, but you MAY be able to exchange
    Return, cancel, or exchange an Adobe order

  • How do I find and use the "Spotlight Effect" in PS6?

    How do I find and use the "Spotlight Effect" in PS6?  I was using it yesterday and now I can find it ... help!

    Hi,
    I'll start with the most basic qusetion if you have Spot selected from the dropdown in the Lighting Effects Properties.
    There are also some presets under Presets including a Default Setting.

  • I've bought an app called WhatsApp but I was not told that app doesn't work for ipod. So I would like to know how to turn back and get my money back.

    I've bought an app called WhatsApp but I was not told that app doesn't work for ipod. So I would like to know how to turn back and get my money back.

    Did you fail to look at the requirements before purchasing?
    All sales are final.  You can try contacting itunes support and asking for an exception

  • I have moved from a G5 Powermac to an Intel Mac Pro and am porting over Items from a Backup HDD. How can I access and use drawings and documents created on the PC computer on the Intel computer ?

    I have moved from a G5 Powermac to an Intel Mac Pro and selectively porting over items from a backup hard drive.
    How can I access and use documents and drawings created on the PC based computer ?

    Clarisworks, you need Appleworks, which will only work with Mac OS X10.6.8 or earlier.  See this tip if you must go newer.  Mac Pros with newer hardware configuration than July 20, 2011 can't use Mac OS X 10.6.8 or earlier without this tip and then it would be Mac OS X Server.  I'm not sure if the new black Mac Pro supports that configuration or not.
    iPhoto, there is an iPhoto for all versions of Mac OS X.
    iTunes, there is an iTunes for all versions of Mac OS X.  Note with iTunes versions 11 and later, which are needed for syncing with iOS 7 or or later, you will lose coverflow, if you liked that feature.  Sadly you can't run an older version of iTunes from within Mac OS X 10.9 or later.
    Sketchup: http://help.sketchup.com/en/article/60107 shows the versions that will work with intermediate Mac OS X versions, and this shows the latest version: http://help.sketchup.com/en/article/36208 be sure to click on the operating system you choose to use.
    GIF - Viewing GIFs Apple's Preview can do that.  Editing them, I like http://www.lemkesoft.com/ Graphicconverter.
    DMG is able to be opened by all versions of Mac OS X.  This are just "disk images" which store programs on a virtual disk that will open when double clicked.    Frequently you'll find the installer of the said program inside.  To find out if the program itself is compatible with 10.7 through 10.9, see http://www.roaringapps.com/
    Otherwise see the resources on:
    https://discussions.apple.com/docs/DOC-2455
    If you end up deciding to stick with Snow Leopard.

  • How to set up and use AirPlay

    How to set up and use AirPlay

    Welcome to the Apple Community.
    AirPlay; When watching suitable content on the iPad, tap the screen to bring up the controls, tap the AirPlay icon and select the Apple TV. The content will then stream to the Apple TV.
    Mirroring; Double tap the home screen button, swipe the application panel to the right, tap the AirPlay icon and choose the Apple TV. The iPad screen will then be streamed to the Apple TV.

  • Re: How do you create and use "common" type classes?

    Hi,
    You have 2 potential solutions in your case :
    1- Sub-class TextNullable class of Framework and add your methods in the
    sub-class.
    This is the way Domain class work. Only Nullable classes are sub-classable.
    This is usefull for Data Dictionary.
    The code will be located in any partition that uses or references the supplier
    plan.
    2- Put your add on code on a specific class and instanciate it in your user
    classes (client or server).
    You could also use interface for a better conception if needed. The code will
    also be in any partition that uses or references the supplier plan where your
    add on class is located.
    If you don't want that code to be on each partition, you could use libraries :
    configure as library the utility plan where is your add-on class.
    You can find an example of the second case (using a QuickSort class,
    GenericArray add-on) with the "QuickSort & List" sample on my personal site
    http://perso.club-internet.fr/dnguyen/
    Hope this helps,
    Daniel Nguyen
    Freelance Forte Consultant
    http://perso.club-internet.fr/dnguyen/
    Robinson, Richard a écrit:
    I'm relatively new to forte and I'd like to know how can you handle utility
    type classes that you want to use through out your application? Ideally
    what I want is a static class with static methods.
    Let's say that I have a StringUtil class that has a bunch of methods for
    manipulating strings.
    My problem is that we have code that runs on the client and code that runs
    on the server. Both areas could use the StringUtil class, but from what I
    understand, I have to create StringUtil in a plan and then create a server
    object of type StringUtil. The server object will eventually get assigned
    to a partition. That's not good since I really want the server object to
    physically reside at the server end and at the client end. (Actually, I
    don't want a server object, I just want to invoke a static method of a
    static class).
    Any clues on how to solve this problem would be appreciated.
    Also, what is the url at Sage-it that has a summary of all emails that have
    been posted to [email protected]? Perhaps this question has been
    answered previously.
    Thanks in advance
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>-
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Hi Richard,
    Your question about "utility classes" brings up a number of issues, all of
    which are important to long-term success with Forte.
    There is no such thing as a static method (method that is associated with a
    class but without an implicit object reference - this/self/me "pointer") in
    TOOL, nor is there such thing as a global method (method not associated
    with a class at all). This is in contrast to C++, which has both, and
    Java, which has static methods, but not global classes. Frequently, Forte
    developers will write code like this:
    result, num : double;
    // get initial value for num....
    tmpDoubleData : DoubleData = new;
    tmpDoubleData.DoubleValue = num;
    result = tmpDoubleData.Sqrt().DoubleValue;
    tmpDoubleData = NIL; // send a hint to the garbage collector
    in places where a C++ programmer would write:
    double result, num;
    // get initial value for num....
    result = Math::Sqrt(num);
    or a Java programmer would write:
    double result, num;
    // get initial value for num....
    result = Math.sqrt(num);
    The result of this is that you end up allocating an extra object now and
    then. In practice, this is not a big deal memory-wise. If you have a
    server that is getting a lot of hits, or if you are doing some intense
    processing, then you could pre-allocate and reuse the data object. Note
    that optimization has its own issues, so you should start by allocating
    only when you need the object.
    If you are looking for a StringUtil class, then you will want to use an
    instance of TextData or TextNullable. If you are looking to add methods,
    you could subclass from TextNullable, and add methods. Note that you will
    still have to instantiate an object and call methods on that object.
    The next issue you raise is where the object resides. As long as you do
    not have an anchored object, you will always have a copy of an object on a
    partition. If you do not pass the object in a call to another partition,
    the object never leaves. If you pass the object to another partition, then
    the other partition will have its own copy of the object. This means that
    the client and the server will have their own copies, which is the effect
    you are looking for.
    Some developers new to Forte will try to get around the lack of global
    methods in TOOL by creating a user-visible service object and then calling
    methods on it. If you have a general utility, like string handling, this
    is a bad idea, since a service object can reside only on a single
    partition.
    Summary:
    * You may find everything you want in TextData.
    * Unless you anchor the object, the instance will reside where you
    intuitively expect it.
    * To patch over the lack of static methods in TOOL, simply allocate an
    instance when required.
    Feel free to email me if you have more questions on this.
    At the bottom of each message that goes through the mailing list server,
    the address for the list archive is printed:
    http://pinehurst.sageit.com/listarchive/.
    Good Luck,
    CSB
    -----Original Message-----
    From: Robinson, Richard
    Sent: Tuesday, March 02, 1999 5:44 PM
    To: '[email protected]'
    Subject: How do you create and use "common" type classes?
    I'm relatively new to forte and I'd like to know how can you handle utility
    type classes that you want to use through out your application? Ideally
    what I want is a static class with static methods.
    Let's say that I have a StringUtil class that has a bunch of methods for
    manipulating strings.
    My problem is that we have code that runs on the client and code that runs
    on the server. Both areas could use the StringUtil class, but from what I
    understand, I have to create StringUtil in a plan and then create a server
    object of type StringUtil. The server object will eventually get assigned
    to a partition. That's not good since I really want the server object to
    physically reside at the server end and at the client end. (Actually, I
    don't want a server object, I just want to invoke a static method of a
    static class).
    Any clues on how to solve this problem would be appreciated.
    Also, what is the url at Sage-it that has a summary of all emails that have
    been posted to [email protected]? Perhaps this question has been
    answered previously.
    Thanks in advance

Maybe you are looking for

  • Can I send a gmail with attachment, possibly photo?

    I wanted to send a gmail with aatachment being photo saved to gallery.

  • Error in counting.

    Hi, I am using the measure buffered period vi from LV 6.0 to measure the time averaged period of a square wave. I am using the signal as the gate and the internal clock as the timebase with a frequency of 100KHz. The problem i am having is that the V

  • Live type does not appear in hard drive

    I'm in the middle of reinstalling Live Type on my computer. I deleted it earlier today, trashing everything that had "Live Type" in its name, and have tried reinstalling the software from the original discs. I have two discs ("Live Type Data" 1 of 2

  • Sparratic and random tween instances in library?

    Out of all the many animations I have, I've recently discovered dozens of tween instances in my library bits and pieces of animations and snippets of tweens randomly from my animations. why is this happening, how can I stop it and most importantly ho

  • Synchronization continued

    Now I get other errors when clicking Synchronize in the table context menu.  A path issue ???? Error initializing Event log details :com.sap.sdb.tools.ui.syncman.SyncManUIPlugin.initConMetaData(SyncManUIPlugin.java:307] java.lang.NullPointerException