AOP remoting in DR3
eske Oct 9, 2003 7:55 AMWe are currently working on our Master's thesis which is about documenting and evaluating the AOP in JBoss 4. The idea is, that we would like to document how new AOP services can be written.
But... We are currently quite stuck on getting the already implemented AOP services to work - in particular AOP Remoting. We haven't been able to find any examples on using the AOP services, so we have looked at the tests in the testsuite from the jboss-head CVS module. We have practically copied the approach from the AOP Remoting test, but it does not work. Nor can we get the AOP Remoting test to work either.
What we have done so far:
We have created an MBean that can create a remote proxy for our POJO, thus making it a remote POJO. This part seems to work. We have registered our POJO (it is called Item) by calling "Dispatcher.singleton.registerTarget("item", item);" as stated in the AOP documentation.
We created an AOP deployment jar-file (.aop) that includes the required jboss-aop.xml file.
We created a .sar that contains our MBean as well as the .aop file.
Once copied into the server deployment dir, it seems to deploy alright.
The problem arises when we try to execute the JUnit test case (that is not deployed on the server and thus not in the same JVM). The test calls the "invoke" method on the RMIAdaptor - exactly as in the AOP Remoting test case.
From the testcase failure output we can verify that the Item class has had a proxy created for it.
[junit] ------------- Standard Error -----------------
[junit] java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
[junit] java.lang.ClassNotFoundException: org.jboss.aop.proxy$jboss.thesis.inventory.model.ItemImpl (no security manager: RMI class loader disabled)
[junit] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:169)
[junit] at org.jboss.jmx.adaptor.rmi.RMIAdaptorImpl_Stub.invoke(Unknown Source)
[junit] at jboss.thesis.inventory.test.InventoryRemoteTestCase.testRemoting(InventoryRemoteTestCase.java:136)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:324)
.... and so on through the JUnit framework, and then:
[junit] Caused by: java.lang.ClassNotFoundException: org.jboss.aop.proxy$jboss.thesis.inventory.model.ItemImpl (no security manager: RMI class loader disabled)
[junit] at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:371)
[junit] at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
[junit] at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:631)
[junit] at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:257)
[junit] at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:200)
[junit] at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1513)
[junit] at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
[junit] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
[junit] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
[junit] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
[junit] at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:297)
[junit] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:146)
[junit] ... 16 more
[junit] ------------- ---------------- ---------------
The problem seems to be getting the changed class definition to the client. Since the class must be downloaded dynamically from the server to the client, we tried installing an RMISecurityManager on the client (the test case). This, however, causes the test to halt and a NullPointerException to be thrown on the server:
15:28:04,805 ERROR [STDERR] java.lang.NullPointerException
15:28:04,805 ERROR [STDERR] at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:118)
15:28:04,805 ERROR [STDERR] at org.jboss.mx.loading.UnifiedClassLoader3.loadClass(UnifiedClassLoader3.java:159)
15:28:04,805 ERROR [STDERR] at java.lang.ClassLoader.loadClass(ClassLoader.java:282)
15:28:04,805 ERROR [STDERR] at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
15:28:04,805 ERROR [STDERR] at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:72)
15:28:04,805 ERROR [STDERR] at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1513)
15:28:04,815 ERROR [STDERR] at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
15:28:04,815 ERROR [STDERR] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
15:28:04,815 ERROR [STDERR] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
15:28:04,815 ERROR [STDERR] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
15:28:04,815 ERROR [STDERR] at org.jboss.remoting.loading.ClassUtil.deserialize(ClassUtil.java:58)
15:28:04,815 ERROR [STDERR] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:129)
15:28:04,815 ERROR [STDERR] at org.jboss.remoting.transport.socket.SocketServerInvoker$Client.run(SocketServerInvoker.java:208)
It appears that we get the same reaction - with regards to the halt of the client and NullPointerException - when we run the AOPRemoting test (the AOPRemoting test case times out after a while).
Our main concern is being able to establish a remote connection to a POJO. Maybe we just don't understand JBoss Remoting or maybe something is not working yet. Whatever the reason, we would be very happy to receive insights into what can make this work.
Help Obi-Wan Kenobi. You're my only hope!
Kind regards
Eske