3 Replies Latest reply on Feb 13, 2006 12:21 PM by Bill Burke

    Remoting with EJB3

    darren hartford Expert

      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:// and using the following client code:

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

      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 :-(


        • 1. Re: Remoting with EJB3
          darren hartford Expert

          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:



           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");
           return mbi;

          • 2. Re: Remoting with EJB3
            Clebert Suconic Master

            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"
             <attribute name="InvokerLocator">socket://${jboss.bind.address}:3873/?serializationtype=java</attribute>
             <attribute name="Configuration">
             <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>

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

            • 3. Re: Remoting with EJB3
              Bill Burke Master

              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...