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

    PortableRemoteObject.narrow() returns null

      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

          Problem solved.

          For those who are interested:
          http://www.ime.usp.br/~reverbel/SMA/maillist/msg00059.html
          Even if I don't speak Fench? Spanish? DontKnow?, it says:

          <trans-attribute>Required</trans-attribute>
          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
            markash

            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);
            System.out.println(home);

            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:
            IOR:000000000000003D524D493A636F6D2E6369626563732E6272732E746573742E696E74657266616365732E54657374486F6D653A30303030303030303030303030303030000000000000000200000000000000C0000102000000000E3139322E3136382E302E313235000DC80000001E4A426F73732F454A42486F6D652625656A622625546573742FACED0005700000000000050000000000000008000000004A414300000000010000001C00000000000100010000000105010001000101090000000105010001000000190000002B0000000000000023687474703A2F2F6D61726B613A383038332F576562434C5B656A622F546573745D2F00000000002000000004000000000000001F000000040000000300000001000000540000000000000003000000190000002B0000000000000023687474703A2F2F6D61726B613A383038332F576562434C5B656A622F546573745D2F00000000002000000004000000000000001F0000000400000003
            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.

            Regards,
            Mark P Ashworth

            • 3. Re: PortableRemoteObject.narrow() returns null
              gbardou

              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
              F72793A312E300000000000000002000000000000006C000102000000000E31302E3135312E33332E313137000DC8000000154A426F73732F49522F53746174656C657373456A620000000
              00000020000000000000008000000004A414300000000010000001C00000000000100010000000105010001000101090000000105010001000000010000002C00000000000000010000000
              10000001C00000000000100010000000105010001000101090000000105010001
              12:26:51,671 INFO [StatelessEjb] EJBHome reference for StatelessEjb:
              IOR:000000000000003D524D493A6F72672E73657373696F6E2E696E74657266616365732E53746174656C657373456A62486F6D653A303030303030303030303030303030300000000000
              00000200000000000000B3000102000000000E31302E3135312E33332E313137000DC8000000214A426F73732F454A42486F6D65262553746174656C657373456A622FACED000570000000
              000000030000000000000008000000004A414300000000010000001C000000000001000100000001050100010001010900000001050100010000001900000033000000000000002B687474
              703A2F2F414F465231313432363A383038332F576562434C5B53746174656C657373456A625D2F000000000001000000670000000000000002000000010000001C00000000000100010000
              0001050100010001010900000001050100010000001900000033000000000000002B687474703A2F2F414F465231313432363A383038332F576562434C5B53746174656C657373456A625D
              2F00
              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
              oucheJBossEdfTest_ejb.jar
              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
              303030303030303030000000000000000200000000000000B3000102000000000E31302E3135312E33332E313137000DC8000000214A426F73732F454A42486F6D65262553746174656C65
              7373456A622FACED000570000000000000030000000000000008000000004A414300000000010000001C000000000001000100000001050100010001010900000001050100010000001900
              000033000000000000002B687474703A2F2F414F465231313432363A383038332F576562434C5B53746174656C657373456A625D2F00000000000100000067000000000000000200000001
              0000001C000000000001000100000001050100010001010900000001050100010000001900000033000000000000002B687474703A2F2F414F465231313432363A383038332F576562434C
              5B53746174656C657373456A625D2F00
              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.

              Regards,

              Gilles.

              • 4. Re: PortableRemoteObject.narrow() returns null
                mmusgrov

                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
                  mmusgrov

                  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
                    mmusgrov

                    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:

                     

                              <invoker-bindings>

                                  <invoker>

                                      <invoker-proxy-binding-name>iiop</invoker-proxy-binding-name>

                                  </invoker>

                              </invoker-bindings>

                    • 7. Re: PortableRemoteObject.narrow() returns null
                      mmusgrov

                      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
                        bclara

                        Mike,

                         

                        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
                          mmusgrov

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

                          • 10. Re: PortableRemoteObject.narrow() returns null
                            bclara

                            Here is post

                            https://community.jboss.org/message/625672

                             

                            Mike, Can you take a look here and see if you can help

                            https://community.jboss.org/message/766765#766765