6 Replies Latest reply on Nov 24, 2003 4:14 AM by duong79

    IIOP Stateful SessionBean

    smike_lv


      The config. doesnt exist in JBoss 3.2.1.


      <configuration-name>IIOP Stateful SessionBean</configuration-name>


      What to use instead of it ?

        • 1. Re: IIOP Stateful SessionBean
          reverbel

          In JBoss 3.2.x you use the "Standard Stateless SessionBean" configuration and override this configuration's default invoker with the "iiop" invoker. This is an example from the JBoss test suite:


          <enterprise-beans>

          <ejb-name>HelloWorld</ejb-name>
          <jndi-name>helloworld/Hello</jndi-name>
          <configuration-name>Standard Stateless SessionBean</configuration-name>
          <invoker-bindings>

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

          </invoker-bindings>

          </enterprise-beans>


          The IIOP configuration changed in JBoss 3.2.x to allow multiple invokers per EJB, a new feature of JBoss 3.2.x.. In the example above the EJB is accessible through the IIOP invoker only. If you want it simultaneously accessible via JRMP and via IIOP, you need two invokers:


          <enterprise-beans>

          <ejb-name>HelloWorld</ejb-name>
          <jndi-name>helloworld/Hello</jndi-name>
          <configuration-name>Standard Stateless SessionBean</configuration-name>
          <invoker-bindings>

          <invoker-proxy-binding-name>stateless-rmi-invoker</invoker-proxy-binding-name>


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

          </invoker-bindings>

          </enterprise-beans>


          The "stateless-rmi-invoker" is the default JRMP invoker used by the "Standard Stateless SessionBean" configuration. Now the HelloWorld EJB can receive requests both through this invoker and through the IIOP invoker.

          Francisco

          • 2. Re: IIOP Stateful SessionBean
            duong79

            Hi Francisco,
            With the configuration uses both JRMP and IIOP invokers, how I can get the 'Hello' object in case JRMP and IIOP?
            Thanks a lot for your help!

            Regards,
            Duong.

            • 3. Re: IIOP Stateful SessionBean
              duong79

              Hi,

              I had configured my jboss.xml file the following:

              <enterprise-beans>

              <ejb-name>Chatroom</ejb-name>
              <jndi-name>demo/chatroomHome</jndi-name>
              <configuration-name>Standard Stateless SessionBean</configuration-name>
              <invoker-bindings>

              <invoker-proxy-binding-name>stateless-rmi-invoker</invoker-proxy-binding-name>


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

              </invoker-bindings>

              </enterprise-beans>


              I got EJB home object the following:
              java.util.Properties properties = System.getProperties();
              properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
              properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
              properties.put(Context.PROVIDER_URL, "jnp://localhost:1099/");
              Context ctx = new InitialContext(properties);
              ChatroomHome home = (ChatroomHome)javax.rmi.PortableRemoteObject.narrow(ctx.lookup("demo/chatroomHome"), ChatroomHome.class);

              However, if I omit the following lines:

              <invoker-proxy-binding-name>stateless-rmi-invoker</invoker-proxy-binding-name>

              in jboss.xml file, I cannot get EJB home object. I do not know how to get EJB home object when I use IIOP protocol (I wrote a Java client).
              Thanks a lot for any help!

              Duong.

              • 4. Re: IIOP Stateful SessionBean
                reverbel

                > I got EJB home object the following:
                > java.util.Properties properties =
                > System.getProperties();
                > properties.put(Context.INITIAL_CONTEXT_FACTORY,
                > "org.jnp.interfaces.NamingContextFactory");
                > properties.put(Context.URL_PKG_PREFIXES,
                > "org.jboss.naming:org.jnp.interfaces");
                > properties.put(Context.PROVIDER_URL,
                > "jnp://localhost:1099/");
                > Context ctx = new InitialContext(properties);
                > ChatroomHome home =
                > (ChatroomHome)javax.rmi.PortableRemoteObject.narrow(ct
                > .lookup("demo/chatroomHome"), ChatroomHome.class);

                This way you get a JRMP proxy. If you want your client to use IIOP you should use the following property setting:

                properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
                properties.put(Context.PROVIDER_URL, "corbaloc::server.host.name:3528/JBoss/Naming/root");
                Context ctx = new InitialContext(properties);

                Alternatively, your client could use a jndi.properties file, as described in http://www.jboss.org/index.html?module=html&op=userdisplay&id=developers/projects/jboss/IIOP.

                Cheers,

                Francisco

                • 5. Re: IIOP Stateful SessionBean
                  duong79

                  Hi Francisco,

                  Thank you very much for your help. Now, I have got EJB home object and created EJB object in Java client.
                  The command line run the client like this:

                  java -Djava.security.manager -Djava.security.policy=./client.policy -Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB -Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton -classpath .:$JBOSS_HOME/client/jacorb.jar:$JBOSS_HOME/client/jboss-client.jar:$JBOSS_HOME/client/jboss-common-client.jar:$JBOSS_HOME/client/jboss-iiop-client.jar:$JBOSS_HOME/client/jboss-j2ee.jar test.Client

                  I know that the client have got stubs from JBoss app server.
                  However, when I call a method on EJB object with the arguments are objects be passed by reference (implements java.rmi.Remote), the following exception had occurred:
                  java.lang.ClassCastException at org.jboss.iiop.rmi.marshal.CDRStream$RemoteWriter.write(CDRStream.java:925)
                  at org.jboss.iiop.rmi.marshal.strategy.StubStrategy.writeParams(StubStrategy.java:194)
                  at org.jboss.proxy.ejb.DynamicIIOPStub.invoke(DynamicIIOPStub.java:111)
                  at ch.elca.iiop.demo.ejbChatroom._Chatroom_Stub.registerMe(Unknown Source)
                  .....
                  I do not know that the JBoss server can download Stubs from the client? I had encapsulated interfaces of these objects (are arguments) with EJB object and implemented those interfaces on the client.
                  Anyhow, thank you very much indeed for your help!

                  Regard,
                  Duong.

                  • 6. Re: IIOP Stateful SessionBean
                    duong79

                    Dear all,

                    I have a problem with my application like below:

                    My remote interface of EJB have a following method:
                    public void registerMe(MessageListener listener, String forUser) throws RemoteException, AlreadyRegisteredException;
                    The MessageListener is a interface:
                    public interface MessageListener extends java.rmi.Remote {
                    public void notifyMessage(Message msg) throws java.rmi.RemoteException;
                    }

                    The Message is a class that implements Serializable interface.

                    At client, I have implemented the MessageListener interface by MessageListenerImpl class.
                    Now, I have got EJB home object and created EJB object (ejbobject) in Java client. The command line run the client like this:
                    java -Djava.security.manager -Djava.security.policy=./client.policy -Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB -Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton -classpath .:$JBOSS_HOME/client/jacorb.jar:$JBOSS_HOME/client/jboss-client.jar:$JBOSS_HOME/client/jboss-common-client.jar:$JBOSS_HOME/client/jboss-iiop-client.jar:$JBOSS_HOME/client/jboss-j2ee.jar test.Client

                    When client call the following method:
                    MessageListenerImpl listener = new MessageListenerImpl(...);
                    ejbobject.registerMe(listener, "Hello");

                    I have been encountered exceptions like this:
                    java.lang.ClassCastException at org.jboss.iiop.rmi.marshal.CDRStream$RemoteWriter.write(CDRStream.java:925)
                    at org.jboss.iiop.rmi.marshal.strategy.StubStrategy.writeParams(StubStrategy.java:194)
                    at org.jboss.proxy.ejb.DynamicIIOPStub.invoke(DynamicIIOPStub.java:111)
                    at ch.elca.iiop.demo.ejbChatroom._Chatroom_Stub.registerMe(Unknown Source)
                    .....

                    I do not know that the JBoss server can download Stubs from the client?

                    Thanks a lot for comments!

                    Duong.