Announcement Announcement Module
No announcement yet.
Error returning Collections across remoting Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error returning Collections across remoting

    Hi everyone,
    we are developing a new application with hibernate(3) + spring (2.5) with HTTP Invoker to remote. All run over tomcat 5.5.25

    We are developing dao classes and the problem happens when we try to return a class with collections across remote.
    With simple clases works fine, but with next class (a class with inner class):

    public class Corresponsal implements{
    private Long oid;
    private String nombre;
    private Set<Telefono> telefonos;

    public static class Telefono implements{
    private String telf;
    public Telefono(){ }
    public void setTelf (String _telf){this.telf = _telf; }
    public String getTelf(){return telf; }

    ... the rest of methods..

    With this class we get the next exception:
    nested exception is java.lang.ClassNotFoundException: org.hibernate.collection.PersistentSet
    Method read of Dao class is next:
    public Corresponsal read(Long oid){
    return(Corresponsal) session.get(Corresponsal.class, oid);

    Someone have any idea about what it's happening????

    thanks in advanced for your support
    Victor & Daniel

  • #2
    Hibernate enhanced the class and one thing it does is wrap (or replace) the existing collections with there Hibernate counter part. If you want to use remoting you will have to translate them back into the original ones.

    Dozer for instance can do this for you.


    • #3
      Are you telling me that error I got is normal?
      and so, I have to clone the object before to give back to remote client???
      is it?



      • #4
        Let me say it this way, if you return the object as is you require the client to have Hibernate in it's classpath!

        Also I'm not talking about cloning, I'm said you need to recreate your object and remove the Hibernate Stuff. As soon as you have a networking boundary (as with remoting) you want to pass a clean as possible object to the client. You don't want your clients to have hibernate, jpa, etc. on their classpath. Next to that if you would pass the hibernate managed object over the line also the session, sessionfactory etc. would be serialized (if even possible!) and passed over the line.....

        This makes me wonder WHERE do you get the exception? As soon as you pass the object over the line? Or is this still on the server side?

        Dozer is a framework which can make that happen for you.


        • #5
          Great !
          You are right, we got the exception at client.
          First we copied hibernate.jar at client, and it worked... but we don't like to copy jars in client (obviously).

          So we have tried Dover and it works fine.

          thanks a lot for your support.
          Victor & Daniel