10 Replies Latest reply on Oct 22, 2012 3:34 PM by Brian Lara

    PortableRemoteObject.narrow() returns null

    one_special_user Newbie

      Hello, I fairly assume this problem is related to my other topic "RMI-IIOP":

      I've deployed a Stateless SessionBean using IIOP bound to JNDI "mytest/MyBean" (even verified by JNDIView).
      I've implemented a C#-Client, on which I can look it up and access it, no problem.

      But with a Java-Client things just won't work.
      I can look it up and get an instance of "org.omg.stub.javax.ejb._EJBHome_Stub" returned. But PortableRemoteObject.narrow( obj, MyBeanHome.class ) 'ing the reference to my Home-Interface "MyBeanHome" returns NULL, so i always get a NullPointerException when calling home.create(). I've included the jbossall-client.jar to classpath.

      Nevertheless, compared to other source-examples it seems to me there's no mistake:

      public static void main(String[] args) throws Throwable {
       props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
       props.put(Context.PROVIDER_URL, "jnp://localhost:1099" );
       props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );
       Context ctx = new InitialContext( props );
       System.out.println( "Got InitialContext!" );
       String jndi = "mytest/MyBean";
       Object obj_ref = ctx.lookup( jndi );
       System.out.println( "Got Reference for : " + jndi );
       System.out.println( "Class : " + obj_ref.getClass() );
       MyBeanHome home = (MyBeanHome)PortableRemoteObject.narrow( obj_ref, MyBeanHome.class );
       MyBean mybean = home.create();
       System.out.println( "Got MyBean: " + mybean.getTime() );

      Same, i cannot access MyBean from another SessionBean - same result: PortableRemoteObject.narrow() returns NULL.

      The problem persists on JBoss 4.0.0, 4.0.3 and 4.0.4.
      JDK: 1.5.0
      I'm using the "all" - profile (since IIOP-support and -all- services are included)
      The only thing i've modified is, that i've commented out "<jnp-context>iiop</jnp-context>" in the IIOP-invoker-proxy-binding - Section in StandardJBoss.xml

      I can't figure out it must be that a problem since I think it is common that EJBs are ACCESSIBLE by clients or other EJBs ;-)

      Any hint is warmly appreciated!

        • 1. Re: PortableRemoteObject.narrow() returns null
          one_special_user Newbie

          Problem solved.

          For those who are interested:
          Even if I don't speak Fench? Spanish? DontKnow?, it says:

          Has to be updated to <trans-attribute>RequiresNew</trans-attribute> in ejb-jar.xml,
          which is the initial origin of my error mentioned above.
          And as I already thougt, my "RMI-IIOP" - Issue was solved as well ;-)

          Just post here for more details.

          • 2. Re: PortableRemoteObject.narrow() returns null
            Mark P Ashworth Newbie

            Good Day,

            Does anyone know how to fix this problem of the PortableRemoteObject.narrow() from returning null when using the Corba IIOP transport?

            I have commented out the CorbaTransactionService mbean from the iiop-service.xml but still it does not work.
            Hashtable<String, String> env = new Hashtable<String, String>();
            env.put("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
            env.put(Context.PROVIDER_URL, "corbaloc::marka:3528/JBoss/Naming/root");

            InitialContext context = new InitialContext(env);
            Object ref = context.lookup("ejb/Test");
            TestHome home = (TestHome) PortableRemoteObject.narrow(ref, TestHome.class);

            I am using 4.0.4 GA and the all server configuration.

            12:29:07,446 INFO [EjbModule] Deploying Test
            12:29:08,102 INFO [ejb/Test] EJBHome reference for ejb/Test:
            12:29:08,133 INFO [ejb/Test] Home IOR for Test bound to iiop/ejb/Test in JNP naming service
            12:29:08,321 INFO [ejb/Test] Home IOR for Test bound to ejb/Test in CORBA naming service
            12:29:08,414 INFO [ProxyFactory] Bound EJB Home 'Test' to jndi 'ejb/Test'
            12:29:08,414 INFO [EJBDeployer] Deployed: file:/D:/programs/jboss-4.0.4.GA/server/all/deploy/TestEJB.jar/

            Not sure how to proceed.

            As a side note, if anyone knows how to get Kerberos, GSS and CSIv2 working in the JBoss/IIOP.

            Mark P Ashworth

            • 3. Re: PortableRemoteObject.narrow() returns null
              Gilles Bardouillet Newbie

              Hi all,

              I got exactly the same issue with JBoss 4.0.3SP1 or 4.0.4 with JDK 1.5.

              Here are my info logs :
              12:26:51,125 INFO [EjbModule] Deploying StatelessEjb
              12:26:51,593 INFO [StatelessEjb] CORBA interface repository for StatelessEjb: IOR:000000000000002149444C3A6F6D672E6F72672F434F5242412F5265706F7369746
              12:26:51,671 INFO [StatelessEjb] EJBHome reference for StatelessEjb:
              12:26:51,687 INFO [StatelessEjb] Home IOR for StatelessEjb bound to iiop/StatelessEjb in JNP naming service
              12:26:51,734 INFO [naming] re-Bound name: StatelessEjb
              12:26:51,734 INFO [StatelessEjb] Home IOR for StatelessEjb bound to StatelessEjb in CORBA naming service
              12:26:51,765 INFO [EJBDeployer] Deployed: file:/D:/Logiciels/jboss/jboss-3.2.5DGI/server/all/tmp/deploy/tmp32240SoucheJBossEdfTest.ear-contents/jar/S
              12:26:51,781 INFO [TomcatDeployer] deploy, ctxPath=/xxxxx, warUrl=file:/xxxxxx.ear-contents/war/xxxxx.war/
              12:26:51,921 INFO [EARDeployer] Started J2EE application: file:/xxxxx.ear
              12:27:11,718 INFO [interceptors] InterceptorManager started with 0 SIs, 0 CIs and 2 IORIs
              12:27:11,734 INFO [STDOUT] StatelessEjb
              12:27:11,750 INFO [STDOUT] org.jacorb.orb.Reference [interface java.rmi.Remote]
              12:27:11,750 INFO [STDOUT] IOR:000000000000003D524D493A6F72672E73657373696F6E2E696E74657266616365732E53746174656C657373456A62486F6D653A30303030303030
              12:27:11,750 INFO [STDOUT] null

              Can someone already fixed that ? how ?
              I have no exception, but my home is NULL after calling narrow.



              • 4. Re: PortableRemoteObject.narrow() returns null
                Michael Musgrove Master

                Does the following work:


                props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");

                props.put(Context.PROVIDER_URL, localhost:1099/NameService);

                • 5. Re: PortableRemoteObject.narrow() returns null
                  Michael Musgrove Master

                  Brian Lara wrote:


                  This will not help as I have to use IIOP for distributed transactions and not JRMP.

                  My EJB client is in separate EAR and separate server from one running EJB and there will be distributed transaction.

                  Of course you are correct, i gave you the settings for a local transaction. How about:


                  properties.put(Context.PROVIDER_URL, "corbaloc:marka:3528/NameService

                  properties.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.iiop.naming:org.jboss.naming.client:org.jnp.interfaces");

                  properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");

                  properties.put(Context.OBJECT_FACTORIES, "org.jboss.tm.iiop.client.IIOPClientUserTransactionObjectFactory");

                  • 6. Re: PortableRemoteObject.narrow() returns null
                    Michael Musgrove Master

                    Just guessing here but are you using the iiop invoker when creating the home and remote interfaces - ie do you have a jboss.xml packaged with your ejb containing the following in the <session> element:







                    • 7. Re: PortableRemoteObject.narrow() returns null
                      Michael Musgrove Master

                      Then I am running out of suggestions. Is it possible for you to create a simple test case so that I investigate your issue further.

                      • 8. Re: PortableRemoteObject.narrow() returns null
                        Brian Lara Newbie



                        Finally able to resolve this and saw this was already answered in other posts for this issue. We need to specify JVM security policy for this and it worked after that. Will delete all my posts so that guys are not confused when solution was already given.

                        • 9. Re: PortableRemoteObject.narrow() returns null
                          Michael Musgrove Master

                          Good news, I am pleased you can make progress now. Perhaps you could add a link to the post that resolved your issue.