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

Similar Messages

  • ClassCastException with PortableRemoteObject.narrow call

    I want to call an ejb component located on a different machine and I can not get it to work. So I tried to deploy it under my version of jboss and try to invoke it. I was able to call it but when I added Context.PROVIDER_URL to my properties I get a classCastException.
    String host = "jnp://localhost:1099";
    props.setProperty(Context.PROVIDER_URL, host);
    I started getting the following exception
    2006-11-03 10:17:18,319 ERROR [STDERR] java.lang.ClassCastException
    2006-11-03 10:17:18,319 ERROR [STDERR]      at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narr
    ow(PortableRemoteObject.java:229)
    2006-11-03 10:17:18,319 ERROR [STDERR]      at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObjec
    t.java:137)
    As soon as I uncomment that props.setProperty(Context.PROVIDER_URL, host);
    line everything works fine.
    I have seen this type of exception before when I tried invoking the ejb on a different computer as well. When I inspect the object with reflection I see that it found the right interface.
    This is my code again:
    Properties props = new Properties();
    props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.security.jndi.JndiLoginInitialContextFactory");
    props.setProperty(Context.SECURITY_PRINCIPAL, "admin");
    props.setProperty(Context.SECURITY_CREDENTIALS, "admin");
    props.put(javax.naming.Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
    String host = "jnp://localhost:1099";
    props.setProperty(Context.PROVIDER_URL, host);
    ctx = new InitialContext( props );
    Object object = ctx.lookup( "ejb/com/blah/Manager" );
    ManagerRemoteHome home = (ManagerRemoteHome)PortableRemoteObject.narrow ( object, ManagerRemoteHome.class);
    ManagerRemote manager = home.create();
    Thanks

    1099 is the RMI/JRMP Registry. You are using RMI/IIOP. Is this port number really correct?

  • ClassCastException in PortableRemoteObject.narrow inside Weblogic

    Hello,
    I'm trying to invoke EJB residing on WLS 6.1 SP2 server from EJB on another exacly
    the same server.
    Properties properties = new Properties();
    properties.put(javax.naming.Context.PROVIDER_URL, "t3://host:7001");
    properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    ivjInitContext = new InitialContext(properties);
    Object homeObject = ivjInitContext.lookup("jndiName");
    BeanHome home = (BeanHome)PortableRemoteObject.narrow(homeObject,BeanHome.class);
    And I get java.lang.ClassCastException: $Proxy74
    on narrow line.
    Everything works fine when I invoke the same code from regular java application
    instead of EJB.Is it the ClassLoader problem ?
    Does any workaround exists ?
    Thank you.

    How are you generating your stubs? i.e. are you using the -iiop option? if so
    then you would need to call the EJB in question using iiop://host:7001. So you
    can either take out the iiop option and recompile the stubs or change the call
    to iiop but then you would also need to replace this line: properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    with this (javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.cosnaming.CNCtxFactory");
    hope this helps!
    -geoff.
    "Elena Neroslavskaya" <[email protected]> wrote:
    >
    Hello,
    I'm trying to invoke EJB residing on WLS 6.1 SP2 server from EJB on another
    exacly
    the same server.
    Properties properties = new Properties();
    properties.put(javax.naming.Context.PROVIDER_URL, "t3://host:7001");
    properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    ivjInitContext = new InitialContext(properties);
    Object homeObject = ivjInitContext.lookup("jndiName");
    BeanHome home = (BeanHome)PortableRemoteObject.narrow(homeObject,BeanHome.class);
    And I get java.lang.ClassCastException: $Proxy74
    on narrow line.
    Everything works fine when I invoke the same code from regular java application
    instead of EJB.Is it the ClassLoader problem ?
    Does any workaround exists ?
    Thank you.

  • Classcastexception on portableremoteobject narrow

    I was successfully connecting to an EJB on my WebLogic server from a Java
    IDL client using the iiop protocol, cosnaming initialcontextfactory. I'm at
    a loss as to what is different now that is causing this to fail. I'm sure
    it has something to do with how I'm generating the stubs and/or the
    client/server classpath, but can't see what I'm doing wrong now. My steps
    are as follows.
    1) Create the EJB jar (call it jar1) using weblogic.ejbc
    2) Run jar1 through weblogic.ejbc using -idl -iiop, creating jar2
    3) Deploy jar2 in the java client's classpath
    I get the initial context fine, but when I get to this line:
    _home = (myHome)(PortableRemoteObject.narrow(ctx, myHome.class));
    I get the following error:
    java.lang.ClassCastException
    at
    com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemo
    teObject.java:296)
    Can anyone give me some assistance?
    Thx!
    Sandy Barletta

    Ok, here's what's going on here. The problem happens when I use
    com.sun.jndi.cosnaming.CNCtxFactory as my initial context factory. After the
    lookup of the home interface, what I get back in my context object if I call
    getClass().getName() is the following:
    com.sun.jndi.cosnaming.CNCtx
    The class cast exception occurs when I try to narrow this to my home
    interface.
    If I use weblogic.jndi.WLInitialContextFactory instead of
    com.sun.jndi.cosnaming.CNCtxFactory, what I get back in my context object if
    I call getClass().getName() is
    com.sun.corba.se.internal.iiop.CDRInputStream$1 and the narrow succeeds.
    What gives? Do I have to use the weblogic context factory? I was hoping to
    avoid the need for weblogic packages on the client. Also, our whole reason
    for using IIOP was to avoid compatibility problems between weblogic servers
    running at different version levels. If I have to use the weblogic context
    factory, and we have a weblogic client running at a different version from
    the server, will there be problem?
    Sandy Barletta
    "Sandy Barletta" <[email protected]> wrote in message
    news:[email protected]...
    I was successfully connecting to an EJB on my WebLogic server from a Java
    IDL client using the iiop protocol, cosnaming initialcontextfactory. I'mat
    a loss as to what is different now that is causing this to fail. I'm sure
    it has something to do with how I'm generating the stubs and/or the
    client/server classpath, but can't see what I'm doing wrong now. My steps
    are as follows.
    1) Create the EJB jar (call it jar1) using weblogic.ejbc
    2) Run jar1 through weblogic.ejbc using -idl -iiop, creating jar2
    3) Deploy jar2 in the java client's classpath
    I get the initial context fine, but when I get to this line:
    _home = (myHome)(PortableRemoteObject.narrow(ctx, myHome.class));
    I get the following error:
    java.lang.ClassCastException
    at
    com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemo
    teObject.java:296)
    Can anyone give me some assistance?
    Thx!
    Sandy Barletta

  • PortableRemoteObject.narrow throws ClassCastException

    Hi Friends,
    I am trying to access home interface of a stateless session EJB from an Applet running in JRE 1.3.1 in IE. My EJB is running in WebLogic Server 6.1. I am getting a cast error while narrowing the remote home interface. My server and client are running on the same machine though they are in different JVMs. I was able to access this remote home interface in a simple test program running from command line.
    This session bean accesses other entity beans deployed in the same WebLogic server, if that has anything to do with it.
    Following is the error callstack:
    java.lang.ClassCastException
         at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:296)
         at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
    Any help in resolving this issue will be greatly appreciated.
    Thanks,
    Krishna.

    Hello
    I have same problem in Java Web Start.
    This Situation is same.
    I report the result of my investigation.
    I'm having a problem in lookup remote object when using JWS.
    My application runs normally in Java Application without JWS.
    I'm using BEA WebLogic Server 6.1.
    My application acts in EJB client application.
    But my application runs normally in WebLogic Server 6.0 and JWS.
    When I cast remote object to my interface, I encountered this kind of error.
    java.lang.ClassCastException
    at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow
    at javax.rmi.PortableRemoteObject.narrow
    While using WebLogic Server 6.0, I include stub classes in my jar file.
    But in WebLogic Server 6.1, ejbc does not generate stub classes.
    WebLogic uses Dynamic proxy technology in JDK 1.3 for this purpose.
    So, EJB client conflict with sand box security policy...
    When I add the following line to javaws.policy file,
    my application runs without problem.
    permission java.io.SerializablePermission "enableSubstitution";
    Is everyone suffering from this kind of problem?
    Is this problem improved in the future?
    I need more information about this problem.
    I am not sure, this is specification.
    Thanks in advance
    Hiroki

  • Sun One EJB problem - PortableRemoteObject.narrow ClassCastException...

    Hi all,
    I'm using Sun One app server 7 for the first time and am having a bit of difficulty. I have deployed a very simple EAR containing one stateless session bean just to test it. The ear appears to have deployed correctly but PortableRemoteObject.narrow is throwing a ClassCastException when trying to do a remote lookup on the bean.
    I'm using the following env settings...
    initialContextFactory = com.sun.enterprise.naming.SerialInitContextFactory
    providerUrl = iiop://127.0.0.1:3700The lookup appears to work okay - this line of code executes successfully
    Object objref = initialContext.lookup(jndiHomeName);...objref appears to initalise succesfully (if I toString() it I get an iiop stream of some sort). However, it is the next line that is failing...
    Object obj = PortableRemoteObject.narrow(objref, homeClass);...this is the exception I get...
    java.lang.ClassCastException
         at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
         at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
         at com.scorlog.ServiceLocator.getRemoteHome(ServiceLocator.java:145)Furthermore, when PortableRemoteObject.narrow() executes, I get the following console exception on the server...
    com.sun.corba.ee.internal.core.DuplicateServiceContext
            at com.sun.corba.ee.internal.core.ServiceContexts.put(ServiceContexts.java:208)
            at com.sun.corba.ee.internal.iiop.ServerRequestImpl.getServiceContextsForReply(ServerRequestImpl.java:258)
            at com.sun.corba.ee.internal.iiop.ServerRequestImpl.createResponse(ServerRequestImpl.java:89)
            at com.sun.corba.ee.internal.POA.SubcontractResponseHandler.createReply(SubcontractResponseHandler.java:50)
            at org.omg.CosNaming.NamingContextExtPOA._invoke(NamingContextExtPOA.java:377)
            at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatchToServant(GenericPOAServerSC.java:569)
            at com.sun.corba.ee.internal.POA.GenericPOAServerSC.internalDispatch(GenericPOAServerSC.java:211)
            at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatch(GenericPOAServerSC.java:113)
            at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:275)
            at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProcessor.java:83)
            at com.iplanet.ias.corba.ee.internal.iiop.ServicableWrapper.service(ServicableWrapper.java:25)
            at com.iplanet.ias.util.threadpool.FastThreadPool$ThreadPoolThread.run(FastThreadPool.java:288)
            at java.lang.Thread.run(Thread.java:534)
    FINE: No SAS context element found in service context listI have seen the forum that other users have had similar problems and the suggestion was that the client can't see the ejb stubs. I don't think this is the problem in my case as I deployed the same ear on weblogic 7 (obviously substituting sun-ejb-jar.xml for a weblogic-ejb-jar.xml) and successfully executed the same client code for the remote lookup.
    My feeling is that the problem revolves around the JNDI binding. Could it be the case that even though the object is binding properly, the app server doesn't realise it is an ejb and not a jdbc/jms/mail object? The documentation gives details on looking up a JDBC, javamail, URL, JMS resource (http://docs.sun.com/source/817-2177/djjndi.html) but not ejb so I could be doing something simple wrong here...
    My sun-ejb-jar.xml is as follows....
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- Generated by XDoclet -->
    <sun-ejb-jar>
        <enterprise-beans>
            <ejb>
                <ejb-name>SBTest</ejb-name>
                <jndi-name>ejb/SBTestBean</jndi-name>
            </ejb>
        </enterprise-beans>
    </sun-ejb-jar>However, I noticed on another thread, a user had some additional elements under their <ejb> tag like this...
    <?xml version="1.0" encoding="UTF-8"?>
    <sun-ejb-jar>
      <enterprise-beans>
        <name>Ejb1</name>
        <ejb>
          <ejb-name>HelloBean</ejb-name>
          <jndi-name>HelloBean</jndi-name>
          <ejb-ref>
            <ejb-ref-name>ejb/helloBean</ejb-ref-name>
            <jndi-name>HelloBean</jndi-name>
          </ejb-ref>
        </ejb>
      </enterprise-beans>
    </sun-ejb-jar>However, when I tried to add and <ejb-ref> element to my xml doc the ear failed to deploy. This is the error I get in the admin console...
    Error
    Deployment Error -- Error while running ejbc -- Fatal Error from EJB Compiler -- --
    Failed to load deployment descriptor for: testApp cause: Error converting J2EE-
    specific ejb xml to object representation: testApp.jar app_testApp Generated by
    XDoclet This bean has no ejb reference by the name of [ejb/SBtest]
    ejb/SBTestSBTestThis problem is eating up my time and being made all the more frustrating by the fact that a) it deploys on weblogic and b) the documentation is terrible. Even the sample application that comes with sun one only provides the .class files for the code that does the ejb look up and not the .java so you can't see how they hell they do it!
    Unfortunately I am tied to using Sun One so I really need to solve this problem fast. If anyone can provide any help I'd greatly appreciate it.
    Cheers,
    John :)

    I am having the same problem after upgrading to Sun One from iplanet. Any clue?

  • 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 narrow an EJV using RMI-IIOP

    Hi,
    I'm trying to deploy an EJB on weblogic 6.1 SP4 on an AIX system, and a client
    (JSP) running on weblogic 6.1 SP4 on a SUN system. And, the dialog between EJB
    and servlet has to use RMI-IIOP (due to exploitation constraints).
    I receive this exception when getting the reference of the EJB's home :
    java.lang.ClassCastException: Cannot narrow remote object to ejbMweb.TstEjbMwebHome
    at weblogic.iiop.PortableRemoteObjectDelegateImpl.narrow(PortableRemoteObjectDelegateImpl.java:124)
    at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:132)
    at cliEjbMweb.cliTstMweb.narrow(cliTstMweb.java:133)
    at cliEjbMweb.cliTstMweb.getHome(cliTstMweb.java:31)
    at cliEjbMweb.cliTstMweb.testBean1(cliTstMweb.java:53)
    at jsp_servlet.__index._jspService(__index.java:91)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:262)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:321)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:198)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2637)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2359)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    The same test using t3 is running OK (there is no problem of classpath).
    Can you hel me ?
    Thank you !
    Marc

    "Marc" <[email protected]> writes:
    It can't download the stub, you need to set an appropriate security
    manager for the RMIClassLoader to work, or make sure the stubs are on
    the client.
    andy
    Hi,
    I'm trying to deploy an EJB on weblogic 6.1 SP4 on an AIX system, and a client
    (JSP) running on weblogic 6.1 SP4 on a SUN system. And, the dialog between EJB
    and servlet has to use RMI-IIOP (due to exploitation constraints).
    I receive this exception when getting the reference of the EJB's home :
    java.lang.ClassCastException: Cannot narrow remote object to ejbMweb.TstEjbMwebHome
    at weblogic.iiop.PortableRemoteObjectDelegateImpl.narrow(PortableRemoteObjectDelegateImpl.java:124)
    at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:132)
    at cliEjbMweb.cliTstMweb.narrow(cliTstMweb.java:133)
    at cliEjbMweb.cliTstMweb.getHome(cliTstMweb.java:31)
    at cliEjbMweb.cliTstMweb.testBean1(cliTstMweb.java:53)
    at jsp_servlet.__index._jspService(__index.java:91)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:262)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:321)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:198)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2637)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2359)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    The same test using t3 is running OK (there is no problem of classpath).
    Can you hel me ?
    Thank you !
    Marc

  • ClassCastException While Narrowing

    Hi,
    I have my application deployed as EAR file, with a WAR and two JAR for the statelesss session beans. On Server start up I call a servlet (in the WAR), which invokes the EJB deployed in one of the JAR file. At that instance it is giving the following Error:
    Exception :Cannot narrow remote object to au.com.three.hutchison.hss.ejb.staticinfo.StaticInfoHome
    java.lang.ClassCastException: Cannot narrow remote object to au.com.three.hutchison.hss.ejb.staticinfo.StaticInfoHome
         at weblogic.iiop.PortableRemoteObjectDelegateImpl.narrow(PortableRemoteObjectDelegateImpl.java:242)
         at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
         at au.com.three.hutchison.hss.service.HSSServiceFactory.narrow(Unknown Source)
         at au.com.three.hutchison.hss.service.HSSServiceFactory.lookupHome(Unknown Source)
         at au.com.three.hutchison.hss.service.HSSServiceFactory.getRemote(Unknown Source)
         at au.com.three.hutchison.init.InitConfigInfoServlet.init(Unknown Source)
         at weblogic.servlet.internal.ServletStubImpl$ServletInitAction.run(ServletStubImpl.java:1070)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
         at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:893)
         at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:842)
         at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:782)
         at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:3236)
    The same code used to work fine before, but I had some class loader issues to resolve which i set the 'prefer-web-inf-classes' to true in the weblogic.xml of the WAR. However after that I started getting the ClassCastException problem..
    Any Help Would be Hghly Appreciated
    Thanks
    Nitin

    here's the weblogic-application.xml that i have used to specify different classloaders
    <!DOCTYPE weblogic-application PUBLIC '-//BEA Systems, Inc.//DTD WebLogic Application 8.1.0//EN' 'http://www.bea.com/servers/wls810/dtd/weblogic-application_2_0.dtd'>
    <weblogic-application>
         <classloader-structure>
              <module-ref>
                   <module-uri>hssWebApp.war</module-uri>
              </module-ref>
              <module-ref>
                   <module-uri>StaticInfoBean/StaticInfoBean.jar</module-uri>
              </module-ref>
              <module-ref>
                   <module-uri>HSSGWSBean/HSSGWSBean.jar</module-uri>
              </module-ref>
         </classloader-structure>
    </weblogic-application>

  • ClassCastException while using session bean in OC4J

    I am facing the same problem while deploying a stateless session bean in Oracle 9i AS 1.0.2.2.1. The details are given below.
    The following code snippet is used in the client to prepare for the lookup:
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "welcome");
    //the following line can also have the actual machine name instead of "localhost"
    env.put(Context.PROVIDER_URL, "ormi://localhost:23893/myejbs");
    Context ctx = new InitialContext(env);
    System.out.println("Getting Home....");
    Object obj=ctx.lookup("Grouping");
    System.out.println("Home Object Is : "+obj);
    GroupingHome groupingHome = (GroupingHome)obj;
    System.out.println("Got Home");
    Grouping grouping = groupingHome.create( );
    graphs=grouping.<mehtods>();
    I've edited the config/server.xml file to have the following line:
    <application name="myejbs" path="C:\oracle\ora102\j2ee\home\applications\classes\myejbs" auto-start="true" />
    which points to the directory where the class files reside
    I've also change the port in the config/rmi.xml file to 23893.
    Now... the problem that I am facing is - while I am running a client from outside the server JVM i.e standalone client... which uses the Grouping interfaces, it works fine. giving me the desired result. But the moment I place the code in a service client deployed in the server or a jsp, I get a ClassCastException for GroupingHome whereas the SOP that I have given after lookup shows that I have found - "Grouping EJBHome". The funny thisng is that bith the working client and the JSP are using sme set of interface class files - Grouping.class (Remote) and GroupingHome.class.
    Where am I going wrong?? If anybody knows, or Giri has found an answer to his query... please post a reply.
    Thanks.
    PS: I've tried new InitialContext(); solution but it didn't work. I have also narrowed the home object with javax.rmi.PortableRemoteObject.narrow(obj,GroupingHome.class) but to no avail :(.

    Hi Gauarv,
    Did you not see my reply in the following post?
    Re: 502 service temporarily unavailable
    If I'm not mistaken, this is exactly the same question as you asked
    there.
    By the way, is there some reason you are still using OC4J version
    1.0.2.2? Is there something stopping you from upgrading to the later
    versions (9.0.2 and 9.0.3)?
    Good Luck,
    Avi.

  • ClassCastException - While type casting Home object after EJB JNDI Lookup

    Sun One Application Server throws a ClassCastException when I try to type cast Home object to it's respective interface type.
    Here is the code ---
    ==============================================
    Object obj = PortableRemoteObject.narrow( context.lookup( jndiName ), homeClass);
    System.out.println("Remote Object - obj : "+obj);
    if (obj != null) {
       System.out.println("obj.getClass().getName() : "+obj.getClass().getName());
       System.out.println("obj.getClass().getSuperclass() : "+obj.getClass().getSuperclass());
       Class[] interfaces = obj.getClass().getInterfaces();
       if (interfaces != null) {
          for (int count = 0; count < interfaces.length; count++) {
             System.out.println("interfaces[ " + count + " ].getName() : " + interfaces[ count ].getName());
    }==============================================
    The class name is dislpayed as the Stub class name.
    While displaying the interfaces, the Home Interface name is displayed.
    But later when I try to type cast it into Home Interface type, it throws a ClassCastException.
    Can somebody please check this?

    Please post the stack trace. Also, take a look at our EJB FAQ to make sure you're doing the
    recommended lookup :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html

  • ClassCastException while getting EJBRemote

    Hi,
    I am getting a ClassCastException while trying to get the EJBRemote (SessionRemote) of a stateless session bean in oc4j 10.1.2
    Object lookupObject = CEJBContext.getHome(loc_s_lookupName);
    Class lookupClass = lookupObject.getClass();
    lookupObject = PortableRemoteObject.narrow(lookupObject, lookupClass);
    Method method = lookupClass.getMethod("create", null);
    SessionRemote remote = (SessionRemote)method.invoke(lookupObject, null);
    Any help will be appreciated.

    The application is packaged into a EAR with a web module and the ejb module.
    This error is coming while either casting the home or the remote ejb.
    I am getting the system log related to the error
    08/06/23 17:26:31 RequestHandler:1CCC01
    08/06/23 17:26:31 RequestHandler:1RoutingProcessFacade
    08/06/23 17:26:32 Error exporting object RoutingProcessFacade EJBHometo POA: Error initializing POAs : Unable to create POA
    08/06/23 17:26:32 RequestHandler:1
    08/06/23 17:26:32 RequestHandler:2
    08/06/23 17:26:32 RequestHandler:3
    08/06/23 17:26:32 lookupObject:RoutingProcessFacade EJBHome
    08/06/23 17:26:32 RequestHandler:4
    08/06/23 17:26:32 Error exporting object RoutingProcessFacade stateless sessionto POA: Error initializing POAs : Unable to create POA
    08/06/23 17:26:32 __Proxy1
    The stack trace is also attached
    08/06/23 17:26:32 java.lang.ClassCastException
    08/06/23 17:26:32      at com.ejb.util.RequestHandler.executeRequest(RequestHandler.java:45)
    08/06/23 17:26:32      at com.ccc.action.HoldThread.run(HoldThread.java:43)
    08/06/23 17:26:32      at java.lang.Thread.run(Thread.java:534)
    08/06/23 17:26:32 java.lang.NullPointerException
    08/06/23 17:26:32      at com.ccc.action.HoldThread.run(HoldThread.java:50)
    08/06/23 17:26:32      at java.lang.Thread.run(Thread.java:534)
    Can please anyone help. This is urgent.
    Regards
    Gautam

  • 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

  • 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

  • PortableRemoteObject.narrow(...) error , why?

    when I execute
    PortableRemoteObject.narrow(objred, SBeanHome.class);
    the system throw an exception
    java.lang.ClassCastException: $Proxy78
    Please help me!
    (my application server is weblogic 6.1)

    Object obj = (MyHomeInterface) ctx.lookup("Invoice.MyHomeInterface");
         MyHomeInterface home = (MyHomeInterface) PortableRemoteObject.narrow(obj, MyHomeInterface.class);
    use this code instead.
    i hope that this will solve your problem change the code according to your classes.

Maybe you are looking for

  • Can multiple TV be used?

    Can more than one TV be used on one home network? I'm thinking of buying one for each TV in the house. Thanks.

  • Printing a PDF with Separations

    MAC OS 10.6.8 I have a simple illustrator file I'm trying to print to PDF with separations. The file is black with a spot color. When I select the Acrobat 7.0 for the printer it keeps looking for an actual printer. What am I missing here?

  • Retaining the Color of the row when it is refreshed in Javascript

    Hi, I have a checkbox when it is checked it will highlight the row with the color. When it is unchecked the color will go off. This is happening fine. But the problem i have is that when i refresh the page or goes to some other page and come back the

  • Increased Shared Pool size longer hot backup time?

    Hello, I have hot backup that usually took 2 hours to complete. Then we had to increase Shared pool size from 280Mb to 380Mb due to some performance issue. One week after increase of size the hot backup is taking 4 hours to complete. Since there was

  • Remote Control settings for Markers

    The user manual for Studio Pro 4 states that Remote Control settings for Markers will override all other settings while that part of the track or story plays. This however, is not the case- In my project the track & story settings for Remote Control>