3 Replies Latest reply on Feb 13, 2006 12:21 PM by bill.burke

    Remoting with EJB3

    dhartford

      Hey all,
      Using what appears to be the old JNDI port 1099 way, I can do remote ejb3 tasks. That's cool, but the transport is adding a lot of time to the call.

      So, jboss remoting seems to be a good idea. However, I can't seem to understand HOW to use jboss remoting.

      I'm keeping the standard ejb3 connector configuration in jboss-service.xml (socket://0.0.0.0:3873) and using the following client code:

       String locatorURI = "socket://myserver:3873"; //?serializationtype=jboss";
      
       MyBusinessManager bam;
       try {
       bam = (MyBusinessManager)TransporterClient.createTransporterClient(locatorURI, MyBusinessManager.class);
      
       System.out.println(bam.hello());
       TransporterClient.destroyTransporterClient(bam);
       } catch (Exception e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
       }
      


      MyBusinessManager is an interface with the 'hello' method, and a MyBusinessManagerBean is in place that implements the interface (that simply returns a string for 'hello'). I get the following error when trying to run this client code:

      java.lang.ClassCastException: org.jboss.remoting.invocation.NameBasedInvocation
       at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:81)
       at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:660)
       at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:513)
       at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:290)
       at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:344)
       at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:202)
       at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:183)
       at org.jboss.remoting.Client.invoke(Client.java:444)
       at org.jboss.remoting.Client.invoke(Client.java:407)
       at org.jboss.remoting.Client.invoke(Client.java:392)
       at org.jboss.remoting.transporter.TransporterClient.invoke(TransporterClient.java:237)
       at $Proxy1.hello(Unknown Source)
       at ClientTest.main(ClientTest.java:60)
      


      I've managed to go through most of the learning curve on my own, but this has me at a standstill :-(

      -D

        • 1. Re: Remoting with EJB3
          dhartford

          There doesn't seem to be a way to take advantage of the jboss remoting with EJB3 (at least no responses). I was hoping to test between the serializationtype=java and jboss, but oh well.

          For anyone else interested, the following is all you need to do:

          jndi.properties

          java.naming.provider.url=jnp://localhostorserver:1099
          


          ClientSample.java
           Properties env = new Properties();
          //for security env.setProperty(Context.SECURITY_PRINCIPAL, username);
          //for security env.setProperty(Context.SECURITY_CREDENTIALS, password);
           env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.JndiLoginInitialContextFactory");
           InitialContext ctx = new InitialContext(env);
          
           MyBeanInterface mbi = (MyBeanInterface)ctx.lookup("MyBean/remote");
           //mbi.sayHello();
           return mbi;
          
          


          • 2. Re: Remoting with EJB3
            clebert.suconic

            Under jboss-4.0.4RC1\server\all\deploy\ejb3.deployer\META-INF you will find jboss-service.xml.

            You can change the MBean as follows:

             <mbean code="org.jboss.remoting.transport.Connector"
             xmbean-dd="org/jboss/remoting/transport/Connector.xml"
             name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3">
             <depends>jboss.aop:service=AspectDeployer</depends>
             <attribute name="InvokerLocator">socket://${jboss.bind.address}:3873/?serializationtype=java</attribute>
             <attribute name="Configuration">
             <handlers>
             <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
             </handlers>
             </attribute>
             </mbean>
            



            You can swap between jboss and java for jboss-serialization and java-serialization

            • 3. Re: Remoting with EJB3
              bill.burke

              Yeah, I need to modify the use of java.rmi.MarshalledObject to use org.jboss.io.MarshalledObject so that the full advantages of JBoss Serialization can be realized....Till then...