Announcement Announcement Module
Collapse
No announcement yet.
HTTPInvoker causes ClassCastException on lazy-loaded field after upgrade to Spring2.5 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTTPInvoker causes ClassCastException on lazy-loaded field after upgrade to Spring2.5

    My server loads objects from a database using Hibernate with certain fields marked as "fetch=FetchType.LAZY". These objects are then sent to a client using Spring's HttpInvoker.

    The application worked fine until Spring 2.0.7.

    Now I upgraded to Spring 2.5. Suddenly I get the following exception when trying to load objects with unfetched fields:

    Code:
    Exception occurred during event dispatching:
    org.springframework.remoting.RemoteAccessException: Could not access HTTP invoker remote service at [...]
    at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.convertHttpInvokerAccessException(HttpInvokerClientInterceptor.java:211)
    at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:160)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    [...]
    Caused by: java.lang.ClassCastException: cannot assign instance of org.hibernate.proxy.pojo.cglib.SerializableProxy to field (field name) of type (field's type) in instance of (class name)
    at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(Unknown Source)
    at java.io.ObjectStreamClass.setObjFieldValues(Unknown Source)
    at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
    at java.io.ObjectInputStream.readSerialData(Unknown Source)
    at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
    at java.io.ObjectInputStream.readSerialData(Unknown Source)
    at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.doReadRemoteInvocationResult(AbstractHttpInvokerRequestExecutor.java:287)
    at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.readRemoteInvocationResult(AbstractHttpInvokerRequestExecutor.java:240)
    at org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor.doExecuteRequest(SimpleHttpInvokerRequestExecutor.java:65)
    at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:134)
    at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:191)
    at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:157)
    ... 12 more
    Once I downgrade back to Spring 2.0.7 on the client side (the server remains 2.5), it works again.

    Do I have to change anything more than simply replace the Spring jar?

    My configuration:
    Server: Linux, Tomcat, JDK 1.6.0_03
    Client: Windows XP, Standalone application, JDK 1.6.0_03

    Thanks for any help!

  • #2
    Originally posted by swolt View Post
    Do I have to change anything more than simply replace the Spring jar?
    Spring 2.5 is considered a upgrade by just replacing the jars, so if there is an issue it should be filed in Jira.

    Your problem (or ClassCastExceptions like this) might always be deployment problems though. Are you sure you replaced all old Spring and Hibernate (if you upgraded this one as well) jars with the new versions and don't have multiple jars deployed on the class loader hierarchy?

    Joerg

    Comment


    • #3
      The problem does not exist anymore in Spring 2.5.1.

      Sven

      Comment

      Working...
      X