7 Replies Latest reply on Jun 14, 2013 12:47 PM by tnas

    CorbaNamingService for EJB3 in AS trunk

    jhalliday

      So I'm trying to write a RMI/IIOP client for an EJB that's deployed in JBossAS. I'm using META-INF/jboss.xml to enable the iiop invoker and that bit works seems to work fine.


      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss PUBLIC
       "-//JBoss//DTD JBOSS 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
      
      <jboss>
       <enterprise-beans>
       <session>
       <ejb-name>StatelessBean</ejb-name>
       <jndi-name>StatelessBean</jndi-name>
       <configuration-name>Standard Stateless SessionBean</configuration-name>
       <invoker-bindings>
       <invoker>
       <invoker-proxy-binding-name>iiop</invoker-proxy-binding-name>
       </invoker>
       </invoker-bindings>
       </session>
       </enterprise-beans>
       <resource-managers />
      </jboss>
      


      Then in the client I try to get a CORBA stub thusly:

      Properties p = new Properties();
      p.put(InitialContext.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
      p.put(InitialContext.PROVIDER_URL, "corbaloc::172.16.130.100:3528/JBoss/Naming/root");
      
      InitialContext ctx = new InitialContext(p);
      MyRemote bean = (MyRemote) ctx.lookup("StatelessBean");
      


      which blows up:


      [java] javax.naming.NameNotFoundException [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
      


      so I use the JMX to do a list() on the jboss:service=CorbaNaming, which I'm assuming should dump out the contents of the name space. It's empty.

      So, question: how do I get the bean into the name server? I'm pretty sure it 'just worked' under 4.2. Is this broken in 5.0 or did I miss a step?

      Thanks


        • 1. Re: CorbaNamingService for EJB3 in AS trunk
          jhalliday

          So mixing EJB3 with jboss.xml configuration is a mistake. Looks like the proper way to do this is to throw out the xml (sweet!) and use e.g.

          @Stateless
          @Remote(MyRemote.class)
          @RemoteBinding(factory= RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
          

          on the bean impl class

          • 2. Re: CorbaNamingService for EJB3 in AS trunk
            pelam888

            Could you please provide some more information as to how you have managed to get your EJB3 bean accessible over IIOP. There seems to be very little complete documentation on how to expose EJB3.0 beans over IIOP in JBoss.

            I have the following:

            1. A simple Stateless Session Bean, IIOPInvokableBean ,

            @Stateless
            @Remote(IIOPInvokable.class)
            @RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
            public class IIOPInvokableBean implements IIOPInvokable {
            
             public void doSomething() {
             System.out.println("IIOPInvokableBean - Invoked doSomething() !");
             }
            
            public String getString() {
             System.out.println("IIOPInvokableBean - Invoked getString() !");
             return "HELLO!";
             }
            
            
            }
            


            2. Its remote interface...

            @Remote
            public interface IIOPInvokable extends EJBObject
            {
             public void doSomething();
             public String getString();
            }
            


            3. I have REMOVED the jboss.xml from the META-INF folder as you have advised

            4. When I deploy the bean to JBoss 5.0.0.Beta3 (and also Jboss 4.2.2), I am presented with the following exception...

            11:33:19,140 INFO [EJBContainer] STARTED EJB: IIOPInvokableEJB.IIOPInvokableBean ejbName: IIOPInvokableBean
            11:33:20,625 INFO [EJBContainer] STOPPED EJB: IIOPInvokableEJB.IIOPInvokableBean ejbName: IIOPInvokableBean
            11:33:20,625 ERROR [AbstractKernelController] Error installing to Start: name=jboss.j2ee:jar=IIOPInvokableEJBPOC.jar,name=IIOPInvokableBean,service=EJB3 state=Create
            java.lang.NullPointerException
             at org.jboss.ejb3.iiop.BeanCorbaServant.<init>(BeanCorbaServant.java:122)
             at org.jboss.ejb3.iiop.IORFactory.start(IORFactory.java:348)
            


            Am I missing something or doing something incorrectly? Your assistance is appreciated.


            • 3. Re: CorbaNamingService for EJB3 in AS trunk
              utiao

              Hi, do you resolve your problem? I am facing the same problem now.

              • 4. Re: CorbaNamingService for EJB3 in AS trunk
                tnas

                Me too.

                • 5. Re: CorbaNamingService for EJB3 in AS trunk
                  ymartin

                  Does this help ?

                  http://thetechtips.wordpress.com/2009/09/02/problems-with-ejb3-over-iiop-on-jboss/

                   

                  With EJB3, the jboss.xml schema has changed since 5.1 and "invoker-bindings" are no longer available.

                   

                  But I find no example with "remote-binding" in jboss.xml

                  • 6. Re: CorbaNamingService for EJB3 in AS trunk
                    ymartin
                    • 7. Re: CorbaNamingService for EJB3 in AS trunk
                      tnas

                      I've got success to call the EJB3 over IIOP as follow:

                       

                      Properties props = new Properties();

                      props.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jboss.iiop.naming.ORBInitialContextFactory");

                      pops.put(InitialContext.PROVIDER_URL, "corbaloc::localhost:3528/JBoss/Naming/root");

                       

                      InitialContext intCtx = new InitialContext(props);

                      Object obj = intCtx.lookup(JNDI_NAME);

                      IService admService = (IService) obj;      

                      MyTask task = admService.getMyTask("id_task");

                       

                      However, I'm not sure if my ejb3 is in fact exposed over IIOP. How can I verify this?