RE: Problem by Updating an Object

From: Kai Michael Bodach (kai.michael.bodac..ondat.de)
Date: Mon Feb 16 2004 - 05:43:25 EST

  • Next message: Andrus Adamchik: "Re: Problem by Updating an Object"

    Hi Andrus,

    finally I (and a high qualified co-worker) have solved the problem with my
    strange environment and cayenne. First I would like to point to an other
    list thread, which seems describe the same problem and which point us to the
    real cause of our problem -->
    http://objectstyle.org/cayenne/lists/cayenne-user/2004/01/0082.html
    Ok, the reason for the problem is the special way in which we launch the
    server and load the corresponding classes. In my environment, I load all
    related projects, like Cayenne or Tapestry as support projects and load the
    extended jar's via the launch process of Http Server(Jetty) directly out of
    Eclipse.
    The problem by this way is, that the classes of the related projects (like
    cayenne), will be load via the BootstrapClassLoader, but the custom classes
    of my project, which are located in the WEB-INF/classes folder, will be load
    with ContextClassLoader of my webapp. Here is a little documentation from
    Tomcat, which described the classloading way of Tomcat -->
    http://jakarta.apache.org/tomcat/tomcat-5.0-doc/class-loader-howto.html
    The different classloaders are the reason, why cayenne won't be able to find
    the ObjEntity, because Cayenne use a different loaded class as key in some
    Map's and if I use my class as parameter in a query, then this is not the
    same which use cayenne and so the right Exception will be thrown -->
    org.objectstyle.cayenne.CayenneRuntimeException
    [v.1.0.6 January 26 2004] Class 'MyClass' does not map to an ObjEntity and
    is therefore not persistent. Can't commit changes

    Ok I hope everybody can understand my damn bad english. And finally I have
    to thank you Andrus, for your fast support.
    Maybe it is helpful to put a hint in the Installation section of the user
    guide, which will be intent to this problem.

    Thanks a lot.

    -kai

    -----Original Message-----
    From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    Sent: Wednesday, February 11, 2004 7:38 PM
    To: cayenne-use..bjectstyle.org
    Subject: Re: Problem by Updating an Object

    Hi Kai,

    Your problem indeed points to an inconsistency in Cayenne in using
    bootstrapped ClassLoader - DataContext uses it, while ObjectId does
    not. I just fixed this and uploaded a patched 1.0.* version to
    http://objectstyle.org/downloads/cayenne/patched/cayenne-src-1.0.7-
    preview.tar.gz . Let me know if this works for you.

    Still there is something strange with your environment, and I can't
    really tell what it is without having access to it. So is this a
    standalone app, or a J2EE container?

    > In my configuration I use the PoolManager, to set up the connection
    > data,
    > because the user of my app should be able to define them.

    This part is likely not related to the problems above.

    > I do not found a
    > better way and so I hope it is the right one. And in my configuratin
    > every
    > session has there own DataContext. Here my configuration:

    Your code for changing connection info look OK too me. It will work as
    long as you know the implications - namely, that the DataSource you are
    configuring in the code is *shared* by all users who obtain their
    DataContexts via the same instance of DataDomain.

    Andrus



    This archive was generated by hypermail 2.0.0 : Mon Feb 16 2004 - 05:45:16 EST