Results 1 to 2 of 2

Thread: Passing CGLIB proxied objects from Server to Client

  1. #1
    Join Date
    Mar 2009
    Posts
    5

    Default Passing CGLIB proxied objects from Server to Client

    Hello all -
    I'm using HttpInvokerProxyFactoryBean to create a simple Spring RMI service. Some of the method calls on the server return CGLIB proxied objects to the client. My general question is, is this a valid thing to do? In other words, is something like this supported?

    The error I get is:

    Code:
    Exception in thread "main" org.springframework.remoting.RemoteAccessException: Cannot deserialize result from HTTP invoker remote service [http://localhost:8080/myservice50/http/applicationService]; nested exception is java.lang.ClassNotFoundException: org.evs.LazyLoadableCodeToReturn$$EnhancerByCGLIB$$7aa18e06
    Caused by: java.lang.ClassNotFoundException: org.evs.helpers.lazyloading.LazyLoadableCodeToReturn$$EnhancerByCGLIB$$7aa18e06
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    	at java.lang.Class.forName0(Native Method)
    	at java.lang.Class.forName(Class.java:242)
    	at org.springframework.remoting.rmi.CodebaseAwareObjectInputStream.resolveClass(CodebaseAwareObjectInputStream.java:99)
    ...
    This leads me to believe that the client side is looking to build the class from a name, and its dying because CGLIB added the $$EnhancerByCGLIB$$ part. I'm pretty sure CGLIB proxies are serializable, but perhaps there's something that limits them from being sent back and forth via RMI. Any info would be great.

    Thanks, Kevin

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    For something to be able to be send to another JVM the classes have to reside in both JVMs. No the problem here is that you are using cglib which creates dynamic classes which only exist in 1 JVM not in both, hence the ClassNotFoundException.

    A class can be Serializable as much as it wants to but if not both JVMs have the classes nothing is going to happen...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •