7 Replies Latest reply on May 5, 2004 12:09 PM by kado0002

    AOP Remoting

    kado0002

      I' ve got enormous trouble with AOP Remoting!
      Here a little Example!
      I hope someone can tell me what I make wrong!

      First the Simple Class HelloWorld:

      package code;
      
      public class HelloWorld {
      
       private String message;
      
       public HelloWorld(){
       }
       public void setMessage(String message){
       this.message=message;
       }
       public String getMessage(){
       return message;
       }
      }
      

      This is the Mbean to is register my object with the Dispatcher!
      import org.jboss.aop.Dispatcher;
      import org.jboss.aop.remoting.Remoting;
      import javax.naming.InitialContext;
      
      public class Test implements TestMBean{
      
       public Test(){
       System.out.println("Hello MBean");
       }
      
       public void register(){
       code.HelloWorld hello = new code.HelloWorld();
       hello.setMessage("HelloWorld");
       Dispatcher.singleton.registerTarget("hello",hello);
       }
       public void start(){}
       public void stop(){}
      }
      

      and now the Client:
      import org.jboss.aop.remoting.Remoting;
      public class Client{
      
       public static void main(String[] args) {
       try{
       code.HelloWorld proxy =(code.HelloWorld)Remoting.createRemoteProxy("hello",code.HelloWorld.class,"socket://localhost:8084");
       System.out.println(proxy.getClass()+"");
       System.out.println(proxy.getMessage());
       }
       catch(Exception e1 ) {
       System.out.println("Error happened !");
       e1.printStackTrace ();
       }
       }
      }
      

      and here the output:
      class org.jboss.aop.proxy$code.HelloWorld
      org.jboss.remoting.SubsystemNotSupported: Subsystem 'AOP' not supported on target VM (InvokerLocator [socket://172.17.199.225:8084/])
      at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:355)
      at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:282)
      at org.jboss.remoting.transport.socket.SocketServerInvoker$Client.run(SocketServerInvoker.java:208)
      Error happened !



        • 1. Re: AOP Remoting
          bill.burke

          Much apologies. I haven't been able to give AOP Remoting much love since the original release both in code and in doco.

          But anyways, you have to specify a connector:


           <mbean code="org.jboss.remoting.transport.Connector"
           xmbean-dd="org/jboss/remoting/transport/Connector.xml"
           name="jboss.remoting:type=Connector,transport=socket5150">
           <attribute name="InvokerLocator">socket://localhost:5150</attribute>
           <attribute name="Configuration">
           <handlers>
           <handler subsystem="AOP">org.jboss.aop.remoting.AOPRemotingInvocationHandler</handler>
           </handlers>
           </attribute>
           </mbean>
          


          • 2. Re: AOP Remoting
            kado0002

            Now I get an other Exception:


            class org.jboss.aop.proxy$code.HelloWorld
            java.lang.NullPointerException
            at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
            at org.jboss.aop.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:75)
            at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:369)
            at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:282)
            at org.jboss.remoting.transport.socket.SocketServerInvoker$Client.run(SocketServerInvoker.java:208)

            Error happened !
            It seems that the Hello World object isn't registered by the dispatcher
            But as you can see, the register() method does this.
            And I've executed the register method before executing the client!

            • 3. Re: AOP Remoting
              bill.burke

              Do you see a message:

              Dispatcher trying to find methodMap for: .......

              What exactly does it say?

              • 4. Re: AOP Remoting
                bill.burke

                Ok, I know what is wrong....(poor testing on my part)

                I will fix this in the beta2 release, but you should do the following within the MBean:

                org.jboss.aop.proxy.ClassProxy.newInstance(code.HelloWorld.class);
                


                The reason being is that the Dispatcher is looking for a hash to java.lang.reflect.Method map that is initialized by create proxy. I didn't have the foresite to test the scenario of the user not creating a proxy on the server side. The underlying remoting framework is being used in production, but the AOP layer on top of this is quite raw as you can see. I just haven't had the time to give it some love, nor has somebody stepped up to help.

                Apologies.

                Bill

                • 5. Re: AOP Remoting
                  kado0002

                  Here the output:

                  R3/server/default/conf/jboss-service.xml
                  15:27:42,894 INFO [Server] JBoss (MX MicroKernel) [4.0.0DR3 (build: CVSTag=
                  date=200403161350)] Started in 23s:293ms
                  15:28:44,333 INFO [STDOUT] Dispatcher trying to find methodMap for: code.HelloWorld
                  15:28:44,333 INFO [STDOUT] java.lang.NullPointerException
                  15:28:44,333 INFO [STDOUT] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
                  15:28:44,333 INFO [STDOUT] at org.jboss.aop.remoting.AOPRemotingInvocation
                  Handler.invoke(AOPRemotingInvocationHandler.java:75)
                  15:28:44,333 INFO [STDOUT] at org.jboss.remoting.ServerInvoker.invoke(Server
                  Invoker.java:369)
                  15:28:44,333 INFO [STDOUT] at org.jboss.remoting.ServerInvoker.invoke(Server
                  Invoker.java:282)
                  15:28:44,333 INFO [STDOUT] at org.jboss.remoting.transport.socket.Socket
                  ServerInvoker$Client.run(SocketServerInvoker.java:208)


                  • 6. Re: AOP Remoting
                    bill.burke

                    Did you apply the code suggestion to your MBean?

                    • 7. Re: AOP Remoting
                      kado0002

                      Now it runs
                      thank you
                      Karsten