???  PortableRemoteObject.narrow()  ???  totally confusing

Hi,
I tried to execute the J2ee tutorial example (ConverterApplication) bean...
I got succeed in doing that...
But while writing the ApplicationClient code i used
PortableRemoteObject.narrow() to get the HomeObject's reference... I know that there is some RMI-IIOP and CORBA stuff involved in that..
But my client is a pure java client not a CORBA client ...so i tried removing this
PortableRemoteObject.narrow() line and i directly typecated the HomeObject...
It is also working ....
So whats the whole purpose of writing PortableRemoteObject.narrow() for a java client ?? Becoz we know that our client is in Java and EJB is also written in java

http://www.jguru.com/faq/view.jsp?EID=734137
http://www.theserverside.com/discussions/thread.tss?thread_id=29200
Richard.

Similar Messages

  • Confusion in PortableRemoteObject.narrow() method

    In EJB 1.0 reference of home object is obtained through external casting as HelloHome home = (HelloHome)ctx.lookup("HelloHome")
    My question is that since IIOP has not been designed for Java, but for generic languages, and this means that there are some limitations. Some languages, in fact, do not have the concept of casting.
    Still why we have to cast the Object if we use PortableRemoteObject.narrow method for obtaining the home interface reference in EJB2.0.
    HelloHome home = (HelloHome)javax.rmi.PortableRemoteObject.narrow(object, HelloHome.class)

    If the client is built using Java, you can not explicitly cast from the Naming.lookup() function. Instead, you must use lookup() to return a generic java.lang.Object, and then cast to the specific object type with the PortableRemoteObject.Narrow(objectReference, interfaceName) method.

  • HT1848 Hi! I am new to i-phone and have a 3gs. I need to update software as itunes will not let me purchase without one. When I go to update it says that there are purchases that have not been downloaded into my library! Am totally confused! Help!!

    Hi!
    Am totally new to iphone and have a 3gs. Am trying to upodate software as in the itunes store it says that I need to to purchase. When I try to update a message says that there are purchases that hav not been down loaded to my library? As far as I know I haven't purchased anything from itunes as it would not let me until i upgraded! Totally confused would it be anything to do with purchases made on my computer through e-bay? Please help me someone as am terrified to upgrade until I know what this message means.
    Would really appreciate any help please.
    Many thanks
    p.s How do you know what operating system you are on?

    http://support.apple.com/kb/HT4972

  • PortableRemoteObject.narrow

    Why is it necessary to use and cast the result of this method call, which appears to return the same object as was passed as the first argument? In other words, why do this:
    Object myObj = ctx.lookup(MYHOME);
    MyHome myHome = (MyHome)
    PortableRemoteObject.narrow(myObj, MyHome.class);
    MyEjb myEjb = myHome.create();
    -in code that must know each EJB, when you can do this:
    //In a generic HomeFactory class
    Object myObj = ctx.lookup(MYHOME);
    Class beanHome = Class.forName(MYHOME);
    PortableRemoteObject.narrow(myObj, beanHome);
    return myObj
    //In some other class
    MyHome myHome = (MyHome) HomeFactory.getHome(MYHOME);
    MyEjb = myHome.create();
    I left out the try-catch blocks and all of that for compactness. The reason I ask is because a generic Home Factory can store EJBHome objects in a collection, testing them first and returning them without creating the actual remote reference, so it does not need to know the specific EJB, allowing the specific client code to cast the generic Object to the specific EJBHome object.
    A Sun-certified instructor once told me that it was absolutely necessary to use the Object returned from the narrow method because it performed some essential RMI activity on the object, but I have never had a problem using it the second way I describe above in the HomeFactory. Also, I have never been able to find any documentation to substantiate his claim. Any thoughts as to the necessity of using the object returned from the narrow method? It appears to be the exact same object that is passed in to the method, and likely un-changed at that.

    The narrow method is there to allow an implementation to do some extra work or return a different object if it needs to. It appears that your implementation does not need to do these things so it just returns the object that was passed. If you take your shortcut, you will limit yourself to running only on your current implementation. If you try to switch implementations or even upgrade to a later version it might break. If you follow the correct method the your code will be portable.

  • JNDI in ActiveX : javax.rmi.PortableRemoteObject.narrow() can't work ?

    Hi All,
    I got a big head ache of this problem for several days, much appreciated if
    I can get help from you.
    The problem is, I wrote an EJB and already deployed it into Weblogic5.1. I
    also wrote a java EJB client to access this EJB. Everything seemed ok at
    this moment.
    The problem occured after i convert this EJB client to ActiveX and test it
    with Microsoft ActiveX Control Test Container. I log each step in the
    ActiveX, and find the problem is caused by
    javax.rmi.PortableRemoteObject.narrow(). Below is my source code and log
    information. My environment is Server side(weblogic5.1),Client side(java
    run-time3.1 with plug-in).
    Source code:
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFacto
    ry");
    env.put(Context.PROVIDER_URL,"t3://"+ip+":"+port);
    try{
    Log("Init jndi ");
    InitialContext ctx = new InitialContext(env);
    Log("Search Home ");
    Object obj = ctx.lookup("ServiceManagerHome");
    Log("home is "+obj);
    Log("narrow from "+obj.getClass().getName());
    Log("narrow to "+ServiceManagerHome.class.getName());
    obj = PortableRemoteObject.narrow(obj,ServiceManagerHome.class);
    Log("narrow home is "+obj);
    serviceHome = (ServiceManagerHome)obj;
    Log("cast home"+serviceHome);
    serviceManager = serviceHome.create();
    Log("Create EJB bean "+serviceManager);
    } catch (Exception e){
    Log("Err-"+e);
    Log("Err-"+e.getLocalizedMessage());
    Log("Err-"+e.getMessage());
    Log information for ActiveX:
    Init jndi
    Search Home
    home is ServiceManagerHome [
    -4611900794319518045S155.161.96.26:[7001,7001,7002,7002,7001,-1]/259]
    narrow from rm.service.ejbimpl.ServiceManagerBeanHomeImpl_ServiceStub
    narrow to crm.service.ejbimpl.ServiceManagerHome
    Err-java.lang.ClassCastException
    Err-null
    Err-null
    Log information for java EJB Client:
    Init jndi
    Search Home
    home is
    crm.service.ejbimpl.ServiceManagerBeanHomeImpl_ServiceStub@-4611900794319518
    045S155.161.96.26:[7001,7001,7002,7002,7001,-1] ServiceManagerHome [
    -4611900794319518045S155.161.96.26:[7001,7001,7002,7002,7001,-1]/259
    narrow from crm.service.ejbimpl.ServiceManagerBeanHomeImpl_ServiceStub
    narrow to crm.service.ejbimpl.ServiceManagerHome
    narrow home
    crm.service.ejbimpl.ServiceManagerBeanHomeImpl_ServiceStub@-4611900794319518
    045S155.161.96.26:[7001,7001,7002,7002,7001,-1] ServiceManagerHome [
    -4611900794319518045S155.161.96.26:[7001,7001,7002,7002,7001,-1]/259]
    cast
    homecrm.service.ejbimpl.ServiceManagerBeanHomeImpl_ServiceStub@-461190079431
    9518045S155.161.96.26:[7001,7001,7002,7002,7001,-1] ServiceManagerHome [
    -4611900794319518045S155.161.96.26:[7001,7001,7002,7002,7001,-1]/259
    Create serviceManager
    crm.service.ejbimpl.ServiceManagerBeanEOImpl_ServiceStub@-461190079431951804
    5S155.161.96.26:[7001,7001,7002,7002,7001,-1] ServiceManagerHome_EO [
    -4611900794319518045S155.161.96.26:[7001,7001,7002,7002,7001,-1]/258

    Contact support.
    Yuan Ming Lei wrote:
    Hi All,
    I got a big head ache of this problem for several days, much appreciated if
    I can get help from you.
    The problem is, I wrote an EJB and already deployed it into Weblogic5.1. I
    also wrote a java EJB client to access this EJB. Everything seemed ok at
    this moment.
    The problem occured after i convert this EJB client to ActiveX and test it
    with Microsoft ActiveX Control Test Container. I log each step in the
    ActiveX, and find the problem is caused by
    javax.rmi.PortableRemoteObject.narrow(). Below is my source code and log
    information. My environment is Server side(weblogic5.1),Client side(java
    run-time3.1 with plug-in).
    Source code:
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFacto
    ry");
    env.put(Context.PROVIDER_URL,"t3://"+ip+":"+port);
    try{
    Log("Init jndi ");
    InitialContext ctx = new InitialContext(env);
    Log("Search Home ");
    Object obj = ctx.lookup("ServiceManagerHome");
    Log("home is "+obj);
    Log("narrow from "+obj.getClass().getName());
    Log("narrow to "+ServiceManagerHome.class.getName());
    obj = PortableRemoteObject.narrow(obj,ServiceManagerHome.class);
    Log("narrow home is "+obj);
    serviceHome = (ServiceManagerHome)obj;
    Log("cast home"+serviceHome);
    serviceManager = serviceHome.create();
    Log("Create EJB bean "+serviceManager);
    } catch (Exception e){
    Log("Err-"+e);
    Log("Err-"+e.getLocalizedMessage());
    Log("Err-"+e.getMessage());
    Log information for ActiveX:
    Init jndi
    Search Home
    home is ServiceManagerHome [
    -4611900794319518045S155.161.96.26:[7001,7001,7002,7002,7001,-1]/259]
    narrow from rm.service.ejbimpl.ServiceManagerBeanHomeImpl_ServiceStub
    narrow to crm.service.ejbimpl.ServiceManagerHome
    Err-java.lang.ClassCastException
    Err-null
    Err-null
    Log information for java EJB Client:
    Init jndi
    Search Home
    home is
    crm.service.ejbimpl.ServiceManagerBeanHomeImpl_ServiceStub@-4611900794319518
    045S155.161.96.26:[7001,7001,7002,7002,7001,-1] ServiceManagerHome [
    -4611900794319518045S155.161.96.26:[7001,7001,7002,7002,7001,-1]/259
    narrow from crm.service.ejbimpl.ServiceManagerBeanHomeImpl_ServiceStub
    narrow to crm.service.ejbimpl.ServiceManagerHome
    narrow home
    crm.service.ejbimpl.ServiceManagerBeanHomeImpl_ServiceStub@-4611900794319518
    045S155.161.96.26:[7001,7001,7002,7002,7001,-1] ServiceManagerHome [
    -4611900794319518045S155.161.96.26:[7001,7001,7002,7002,7001,-1]/259]
    cast
    homecrm.service.ejbimpl.ServiceManagerBeanHomeImpl_ServiceStub@-461190079431
    9518045S155.161.96.26:[7001,7001,7002,7002,7001,-1] ServiceManagerHome [
    -4611900794319518045S155.161.96.26:[7001,7001,7002,7002,7001,-1]/259
    Create serviceManager
    crm.service.ejbimpl.ServiceManagerBeanEOImpl_ServiceStub@-461190079431951804
    5S155.161.96.26:[7001,7001,7002,7002,7001,-1] ServiceManagerHome_EO [
    -4611900794319518045S155.161.96.26:[7001,7001,7002,7002,7001,-1]/258

  • Spry Accordion Menu Tab Link css - totally confused

    Thanks folks from an l-plater but I've totally confused myself trying to work this out and I'm hoping some fresh eyes will see the answer clear as day.  I've created a spry accordion menu with links in the actual panel tabs.  Menu and links all working fine - problem is in css styling, particularly panel tab link open and hover states which should be blue text over green background, same as non-link panel tabs.  You'll see from code that I've tried a few styles but can't get this to work.  I'm thinking I've totally overdone it and some styles are overriding others and solution is a simple deletion of some unnecessary or conflicting styles.
    Thanks so much in advance for your help - I just can't see for looking any more though I'm sure it can't be hard.
    <div id="sidebar1">
    <div id="Accordion1" class="Accordion">
      <div class="AccordionPanel">
        <div class="AccordionPanelTab"><a href="Index.html" onclick="window.location = this.href">Home</a></div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab">Photo Gallery</div>
        <div class="AccordionPanelContent">
        <ul>
        <li><a href="PhotoGallery.html">Gallery 1</a></li>
        </ul>
        </div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab">Unit Newsletters</div>
        <div class="AccordionPanelContent">
        <ul>
        <li><a href="Newsletter.html">February 2010</a></li>
        </ul>
        </div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab"><a href="Sponsors.html" onclick="window.location = this.href">Sponsors</a></div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab"><a href="Merchandise.html" onclick="window.location = this.href">Merchandise</a></div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab"><a href="Links.html" onclick="window.location = this.href">Links</a></div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab"><a href="Events.html" onclick="window.location = this.href">Events</a></div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab">Forms</div>
        <div class="AccordionPanelContent">
        <ul>
        <li><a href="">Joining Instructions</a></li>
        <li><a href="">Enrolment</a></li>
        <li><a href="">Next of Kin</a></li>
        <li><a href="">Volunteer Blue Card</a></li>
        </ul>
        </div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab"><a href="Contact.html" onclick="window.location = this.href">Contact</a></div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab"><a href="LogIn.html" onclick="window.location = this.href">Log In</a></div>
        <div class="AccordionPanelContent">
        <ul>
        <li><a href="WhatsOn.html">Whats On</a></li>
        <li><a href="PSG.html">Parent Support Group</a></li>
        </ul>
        </div>
        </div>
      </div>
    </div>
    .AccordionPanel {
    margin: 0px;
    padding: 0px;
    .AccordionPanelTab {
    background-color: #036;
    border-bottom: 1px #93b747 solid;
    margin: 0px;
    padding-left: 10px;
    padding-top: 2px;
    padding-bottom: 2px;
    font-size: 12px;
    cursor: pointer;
    -moz-user-select: none;
    -khtml-user-select: none;
    text-decoration: none;
    .AccordionPanelTabOpen {
    color: #036;
    background-color: #93b747;
    display: block;
    text-decoration: none;
    .AccordionPanelTabHover {
    color: #036;
    background-color: #93b747;
    text-decoration: none;
    border-bottom: 1px solid #036;
    display: block;
    .AccordionPanelTab a {
    color: #93b747;
    margin: 0px;
    font-size: 12px;
    cursor: pointer;
    -moz-user-select: none;
    -khtml-user-select: none;
    text-decoration: none;
    display: block;
    .AccordionPanelTab a.open {
    font-color: #036;
    color: #036;
    background-color: #93b747;
    text-decoration: none;
    display: block;
    .AccordionPanelTab a.active {
    color: #036;
    background-color: #93b747;
    display: block;
    text-decoration: none;
    .AccordionPanelTab a.hover {
    color: #036;
    background-color: #93b747;
    font-weight: bold;
    text-decoration: none;
    display: block;
    .AccordionPanelTab a.close {
    color: #93b747;
    background-color: #036;
    text-decoration: none;
    display: block;
    .AccordionPanelContent {
    margin: 0px;
    padding-left: 10px;
    padding-top: 2px;
    padding-bottom: 12px;
    background: #fff;
    font-size: 12px;
    color: #036;
    font-weight: 500;
    .AccordionPanelContent ul li {
    margin-left: -40px;
    padding-top: 2px;
    padding-bottom: 2px;
    background: #fff;
    font-size: 12px;
    color: #036;
    font-weight: 500;
    text-decoration: none;
    list-style-type:none;
    list-style:none;
    .AccordionPanelContent ul li a:link {
    color: #036;
    text-decoration: none;
    list-style-type:none;
    list-style:none;
    .AccordionPanelContent ul li a:hover {
    color: #036;
    font-weight: bold;
    text-decoration: none;
    .AccordionPanelContent ul li a:visited {
    color: #036;
    text-decoration: none;
    .AccordionPanelOpen .AccordionPanelTab {
    color: #036;
    background: #93b747;
    border-bottom: 1px solid #036;
    .AccordionPanelOpen .AccordionPanelTab.a {
    color: #036;
    background: #93b747;
    border-bottom: 1px solid #036;
    .AccordionPanelOpen .AccordionPanelTabHover {
    color: #036;
    font-weight: bold;
    .AccordionPanelOpen.a .AccordionPanelTabHover.a {
    color: #036;
    font-weight: 600;
    .AccordionFocused .AccordionPanelTab {
    color: #036;
    font-weight: 600;
    a.AccordionFocused .AccordionPanelTab {
    color: #036;
    font-weight: 600;
    .AccordionFocused .AccordionPanelOpen .AccordionPanelTab {
    color: #036;
    font-weight: 600;
    a.AccordionFocused .AccordionPanelOpen .AccordionPanelTab {
    color: #036;
    font-weight: 600;

    Yes Beth, you're right and I've corrected my css - I think - problem with AccordionPanelTab link open and hover states still happening so css still wrong.  I've uploaded site so you can see what's happening (www.11acu.org).  All tab states should be as per Photo Gallery, Newsletters and Forms.  Hover state in tab links seem okay until mouse moves away from "a href" block - rest of tab area not working so its like the two styles, ie "AccordionPanelTab" and "AccordionPanelTab a:hover" are both working at the same time but I only want the latter to work.  Now I've probably got you confused as well! lol Apologies!  Recreated css for tab links below.  Html same as in original post.  Any help much appreciated.
    .AccordionPanelTab {
    color: #93b747;
    background-color: #036;
    border-bottom: solid 1px #93b747;
    margin: 0px;
    padding-left: 10px;
    padding-top: 2px;
    padding-bottom: 2px;
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
    -moz-user-select: none;
    -khtml-user-select: none;
    .AccordionPanelTab a {
    color: #93b747;
    background-color: #036;
    margin: 0px;
    padding-left: -10px;
    padding-top: -2px;
    padding-bottom: -2px;
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
    -moz-user-select: none;
    -khtml-user-select: none;
    display: block;
    .AccordionPanelTab a:link {
    color: #93b747;
    background-color: #036;
    margin: 0px;
    padding-left: -10px;
    padding-top: -2px;
    padding-bottom: -2px;
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
    -moz-user-select: none;
    -khtml-user-select: none;
    display: block;
    .AccordionPanelTab a:hover {
    color: #036;
    background-color: #93b747;
    margin: 0px;
    padding-left: -10px;
    padding-top: -2px;
    padding-bottom: -2px;
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
    -moz-user-select: none;
    -khtml-user-select: none;
    display: block;
    .AccordionPanelTab a:active {
    color: #036;
    background-color: #93b747;
    margin: 0px;
    padding-left: -10px;
    padding-top: -2px;
    padding-bottom: -2px;
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
    -moz-user-select: none;
    -khtml-user-select: none;
    display: block;
    .AccordionPanelOpen .AccordionPanelTab {
    color: #036;
    background-color: #93b747;
    border-bottom: solid 1px #036;
    text-decoration: none;
    .AccordionPanelTabHover {
    color: #036;
    background-color: #93b747;
    text-decoration: none;
    border-bottom: solid 1px #036;
    .AccordionPanelOpen .AccordionPanelTabHover {
    color: #036;
    background-color: #93b747;
    text-decoration: none;
    font-weight: bold;
    .AccordionFocused .AccordionPanelTab {
    color: #93b747;
    background-color: #036;
    text-decoration: none;
    .AccordionFocused .AccordionPanelOpen .AccordionPanelTab {
    color: #036;
    background-color: #93b747;
    border-bottom: solid 1px #036;
    text-decoration: none;

  • Help !! ios 6,iphone,Two ipods & and ipad totally confused !!

    Please can someone help?
    I have an iphone 4 and an ipad, both my boys have an ipod and everything runs under my apple account.
    My first problem is that neither of the children can face time or message. Have set them both up with gmail accounts but neither ipod will accept the associated passwords despite being re set to ensure they are correct.
    They cant receive messages from me, which is what i wanted for them, do i need to give them each an apple id? and if so how do i regulate their app store purchases?
    and when they are given an app store voucher, whos id does it go on?
    My second problem is that since upgrading to ios6 one of the boys is getting all my text messages showing up on his ipod and the other still cant open his messages.
    I have messed around with the settings on both ipods but to no avial and I am now totally confused.
    All I want is for someone to explain how the boys can face time/message, how my messages stop from appearing on their ipods and as for my ipad well i give up!!
    please surely it cant be this difficult?

    You have to set them each up with their own Apple ID, then log out from your Apple ID on their devices and log in with theirs. Make sure that Facetime and Messages are set to receive calls/messages on their Apple IDs, not yours.

  • Bind by position? I got totally confused

    is it default that the parameters in the .net codes are binded to that in the pl/sql codes by position? i get totally confused.
    very simple codes in the pl/sql are like this:
    ===========================
    FUNCTION create_saint(saint_name IN VARCHAR2,saint_ct IN VARCHAR2)
    RETURN VARCHAR2
    ===========================
    and "oracom" is a OracleCommand calling the function, when i add the parameters like this:
    ===================================
    oracom.Parameters.Add("saint_name",OracleDbType.Varchar2,"aaa");
    oracom.Parameters.Add("saint_ct",OracleDbType.Varchar2,"bbb");
    ===================================
    i woule like the parameter "saint_name" is "aaa" and "saint_ct" is "bbb" if they are binded by position. but error occurs and when i traced the execution of the pl/sql code, i found that the parameter "saint_name" was "bbb" and "saint_ct" was null.
    shouldn't they be binded by position? and when i used the
    "oracom.BindByName = true;"
    the two parameters were just binded correctly.
    so i just wonder when and how the parameters are binded by position.

    Hello,
    Yes, parameters are bound by position by default when using ODP.NET - this is controlled by the BindByName property which defaults to false. If you want to use bind by name, just set this property to true as you've shown.
    Since you are using a FUNCTION I would guess that you did not bind the function return value first, which is required. ODP.NET will generate code similar to this:
    begin
      :1 := function_name(:2, :3, :4);
    end;Hope that helps,
    Mark

  • HomeInterface.class in PortableRemoteObject.narrow

    Hi
    I understand we do a JNDI look up to get the stub (HomeInterface object) and then narrow it down to ensure the object becomes RMI/IIOP compliant and it is of HomeInterface type, the following code snippet does what I have hence stated
    Context cx = new InitialContext();
    Object obj = cx.lookup("java:comp/env/beanString");
    HomeInterface hI = PortableRemoteObject.narrow(obj, HomeInterface.class) // NOW hI is the STUB object
    I am aware the Home interface will reside in the server side only, the object (obj) that is being returned is of type HomeInterface but then as we are not sure of its RMI/IIOP complaincy we narrow down the object to the Homeinterface type, as the code of HomeInterface resides in the server side how does this snippet (narrowing code) that resides in the client side identify and narrow down, the object returned, to the respective Home Interface type?
    The analogy to this I could think of is ordinary type casting while we pick a object from ArrayList, as all that reside in collection is of type Object we are to typecast to the respective Object type, but here the actual object resides in the JVM so I could understand how this casting happens, but what is the case with PortableRemoteObject.narrow as the Home Interface code resides in the remote server?
    Kindly reply

    Dont you know the concept of "client.jar" ??
    well, the following reside at server side:
    remote interface,
    home interface,
    bean implementation class.
    the following must reside at client side. These are packaged in a jar taht is typically called client.jar:
    remote interface
    home interface
    Check the classpath of your client. I am sure these two interfaces are there in it. Otherwise there will be some exception.
    Note that the system is sensitive to difference in the versions of home/remote. ie. if these are differet, serializationException may be thrown.
    Hope that helps.
    regards

  • [b]Periodic[/b] error using PortableRemoteObject.narrow

    I am trying to access a session bean on an oracle9ias(903) running on a windows 2000 server.
    Well I am actually accessing several beans, but on some of the beans the code works and on some it don't even though the code is alike. There is no execptions thrown but the LabelTypeDAOHome is null and I get a NPE when calling create on it.
    public static Context getInitialContext() throws NamingException, MissingResourceException
    Hashtable env = new Hashtable();
    String init = getResourceBundle().getString("INITIAL_CONTEXT_FACTORY");
    env.put(Context.INITIAL_CONTEXT_FACTORY,init);
    String principle = getResourceBundle().getString("SECURITY_PRINCIPAL");
    env.put(Context.SECURITY_PRINCIPAL,principle);
    String credential = getResourceBundle().getString("SECURITY_CREDENTIALS");
    env.put(Context.SECURITY_CREDENTIALS,credential);
    String url = getResourceBundle().getString("PROVIDER_URL");
    env.put(Context.PROVIDER_URL,url);
    env.put("dedicated.rmicontext","true"); // vigtig ifm web access!
    return new InitialContext(env);
    private LabelTypeDAO getLabeltypeDAO() throws NamingException, RemoteException {
    LabelTypeDAO labeltypeDAO = null;
    if (context == null) {
    context = getInitialContext();
    if (labeltypeDAOHome == null) {
    LabelTypeDAOHome labeltypeDAOHome = (LabelTypeDAOHome)PortableRemoteObject.narrow(context.lookup("LabelTypeDAO"), LabelTypeDAOHome.class);
    try {
    labeltypeDAO = labeltypeDAOHome.create();
    } catch(Exception ce) {
    throw new RemoteException("Could not create LabelTypeDAO.", ce);
    return labeltypeDAO;
    The funny part is that it doesn't happen on all the sessionbeans.
    Could it have something to do with what happens on deployment (e.g internal wrapping).
    There is no exception thrown untill I call labeltypeDAO = labeltypeDAOHome.create();
    This code is in a java class instantiated in a jsp page.

    Found it. It was my own stupid mistake. I had 2 references to the same variable name, one to an instance variable and one to a local variable and I ofcourse referenced the wrong one.
    Bad lars
    Bad lars
    Bad lars

  • How to solve PortableRemoteObject.narrow exception

    Hi ,
    I am getting portableRemoteObject exception... when i tried to narrow the stub with home class.
    Please find my code:
    Object objRef = ctx.lookup("java:comp/env/ejb/ejbSchedularBean"
    TaskHandlerHome home = (TaskHandlerHome) javax.rmi.PortableRemoteObject.narrow(objRef,TaskHandlerHome.class);
    Please help me to solve.
    cannot cast class com.ibm.websphere.schedular._TaskHandlerHome_Stub to interface com.ibm.websphere.scheduler.TaskHandlerHome
         at com.ibm.rmi.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:396)
         at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:156)
         at com.ibm.websphere.schedular.CallBeanTask.getBeanClassInstance(CallBeanTask.java:66)
         at com.sched.servlet.SchedulerServlet.init(SchedulerServlet.java:25)
         at javax.servlet.GenericServlet.init(GenericServlet.java:256)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:185)
         at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.init(ServletWrapper.java:316)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:1119)
         at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:149)
         at com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor.createServletWrapper(WebExtensionProcessor.java:99)
         at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:742)
         at com.ibm.ws.webcontainer.webapp.WebApp.initializeTargetMappings(WebApp.java:422)
         at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:275)
         at com.ibm.ws.wswebcontainer.webapp.WebApp.initialize(WebApp.java:272)
         at com.ibm.ws.wswebcontainer.webapp.WebGroup.addWebApplication(WebGroup.java:88)
         at com.ibm.ws.wswebcontainer.VirtualHost.addWebApplication(VirtualHost.java:157)
         at com.ibm.ws.wswebcontainer.WebContainer.addWebApp(WebContainer.java:655)
         at com.ibm.ws.wswebcontainer.WebContainer.addWebApplication(WebContainer.java:608)
         at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:333)
    Regards.
    sur

    I have created a simple applet.
    import java.lang.*;
    import java.awt.*;
    public class jawtex3 extends java.applet.Applet
    public void init()
    add(new Button("One"));
    add(new Button("Two"));
    public Dimension preferredSize()
    return new Dimension(200, 100);
    public static void main(String [] args)
    Frame f = new Frame(" jawtex3");
    jawtex3 ex = new jawtex3();
    ex.init();
    f.add("Center", ex);
    f.pack();
    f.show();
    In this no compilation errors.
    I am getting runtime exception.as Exception in thread "main"java.lang.NoClassDefFound Error: jawtex
    reply me soon.
    thankyou.

  • Java.lang.ClassCastException PortableRemoteObject.narrow(PortableRemoteObje

    Hi,
    I have a problem with a JNDI -lookup() using the CORBA namig system.
    After looking up: System.out.println( lookup("jndi-name") );
    I get an IOR: IOR:0000000000000053524d493a...............
    ok
    then I print out the name and the package of this object:
    Object o = lookup("jndi-name");
    System.out.println("name of o : " + o.getClass().getName());
    System.out.println("package of o : " + o.getClass().getPackage());
    and get:
    name of o : com.sun.corba.ee.impl.corba.CORBAObjectImpl
    package of o : package com.sun.corba.ee.impl.corba
    I expected the type of a Home-Interface, so that i could narrow the object o:
    PortableRemoteObject.narrow( o , classname);
    and the result is a:
    java.lang.ClassCastException
    at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
    at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)........
    What's wrong

    The most likely reason is that the stubs for that home interface are not being found. Double-check your classpath to make sure they are available to the code at runtime.
    -ken

  • ClassCastException while PortableRemoteObject.narrow

    Hello,
    I am getting the ClassCastException when I am narrowing the looked up home object.
    Here is the exception:
    java.lang.ClassCastException
         at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
         at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
         at samples.ejb.client.HelloClient.main(HelloClient.java:50)
    Here is the code :
    try {
    System.out.println("Looking up greeter bean home interface");
    String JNDIName = "HelloGreet";
    System.out.println("Looking up: " + JNDIName);
    Object objref = initContext.lookup(JNDIName);
    System.out.println("Object from the look up -->"+objref);
    home = (HelloHome)javax.rmi.PortableRemoteObject.narrow(objref, HelloHome.class);
    any help appreciated. Thanks in advance
    With Regards,
    J. P. Naidu

    Hi Pullaiah,
    I've same problem with Sun ONE AS (notice that I encounter same problem on J2EE Reference Implementation too).I looked up for a solution everywhere but I did't find it and I'd be very happy if someone could post one.
    Thanks ,
    Fil

  • EjbHome = (EJBHome) PortableRemoteObject.narrow(homeObject, EJBHome.class);

    please explain the below given code , It is used in servicelocator (J2EE Pattern), basically to find the EjB Home
    ejbHome = (EJBHome) PortableRemoteObject.narrow(homeObject, EJBHome.class);

    If we plain old cast, we are assuming that the server is using the regular old RMI (which assumes that the server objects are always java objects.
    RMI/IIOP allows connecting RMI objects to non-Java objects regardless of the implementation language (for interface to any native legacy code). So, in such cases (where client and server are separated by a network), one should use the
    PortableRemoteObject.narrow(), which assumes that the objects that we are talking to are not always java objects.
    The plain old cast will work when we use local home and component interfaces as both client and server run on the same JVM.
    Rishi

  • Javax.rmi.portableRemoteObject.narrow

    Hi
    Pls tell me why we narrow the instance of the object we looked up,
    before type casting it to a home referance by using javax.rmi.portableRemoteObject.narrow(Object,Home.class)

    In the early days of EJB this call was required to ensure portability due to some intracacies of how
    RMI-IIOP and CORBA ORBs are implemented. Some implementations are able to directly return
    the correctly typed object from the lookup, but in others the extra PortableRemoteObject.narrow
    call is necessary, so always using it ensures portability.
    Starting in Java EE 5, PortableRemoteObject.narrow is not needed if the code is either accessing
    a Remote 3.0 Business Interface or if the code is accessing a 2.x style Home object using
    @EJB or the new EJBContext.lookup method.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • I am getting error while accesssing Oracle database

    i am trying to learn by playing around with ' MORTGAGE LOAN APPLICATION. in database i have taken oracle. when i try to fire following query: select * from customer where custId={$ /process_data/@custId $} i am getting following error: Exception: Int

  • CameraRaw V6.7 in Elements-10 Issue

    After updating CameraRaw V6.6 in Elements-10 to CameraRaw V6.7, CameraRaw is missing on the plug-in list and it can't open any NEF files.  What to do?

  • CDR Problems in OSX 10.2.8

    Hey all, I've been trying to back up a ton of work at work onto 700 mb 80 min memorex cdr's. At first i was trying to use disk copy to make .dmg's of the folders and then burn the image to disc but it kept telling me that the disc did not have enough

  • Applicatio​n windows too big

    The screen size of the desk top is fine. Every application you open - IE - WORD - EXCEL etc... is too big on the screen. How do you make the information smaller in windows 7 ??

  • Newest movie purchase won't play/sync on iPod3rdGen

    I just downloaded a movie that came out today. My ipod refuses to play it - iTunes won't even transfer it to back it up. When I downloaded trailers of this movie on my ipod in the past it said they couldn't be played, but I figured it was a glitch. E