RE: Newbie question on Cayenne error at runtime

From: McBrayer, Roy (Roy.McBraye..ail.va.gov)
Date: Wed Jul 14 2004 - 16:58:27 EDT

  • Next message: Andrus Adamchik: "Re: Newbie question on Cayenne error at runtime"

    I have tried everything I can think of in JBuilder to get my first Cayenne
    app to run.

    I have placed

     Configuration.bootstrapSharedConfiguration(iiv_test.SiteDailySum);

    into my main method and iiv_text.SiteDailySum is not a valid parameter.
    This is true even though SiteDailySum is a class within the iiv_test
    package. Does anyone have any additional suggestions on how to configure an
    application within JBuilder to use Cayenne?

    Thanks,
    Roy

    -----Original Message-----
    From: McBrayer, Roy
    Sent: Wednesday, July 14, 2004 12:32 PM
    To: 'Andrus Adamchik'
    Subject: RE: Newbie question on Cayenne error at runtime

    I am running this in JBuilder with cayenne.jar added as a library. This
    basically addes the cayenne.jar to the classpath when the program runs. So,
    I'm not sure why this is showing up.

    I need to experiment a little to see what I can configure to get the
    cayenne.jar to run with Jbuilder.

    Thanks,
    Roy

    -----Original Message-----
    From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    Sent: Wednesday, July 14, 2004 10:08 AM
    To: cayenne-use..bjectstyle.org
    Subject: Re: Newbie question on Cayenne error at runtime

    Hi Roy,

    This is not something related to Cayenne (and therefore there is no
    Modeler checkbox to "fix" it). This is the way ClassLoaders are
    implemented in Java. ClassLoaders are hierarchical. In a standalone app
    there is a "bootstrap" ClassLoader and an application ClassLoader, in
    web application environment there can be a whole tree of them (e.g.
    http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-
    howto.html). If you run from an IDE, IDE can also add its own share to
    the mix.

    The general rule is that a *child* ClassLoader can see the classes
    loaded by itself and its parents in the hierarchy. At the same time
    *parent* can not see classes loaded by its children. So if cayenne.jar
    is loaded via a bootstrap classloader one way or another, and
    iiv_test.SiteDailySum is loaded via an application ClassLoader (a child
    of bootstrap ClassLoader), Cayenne has no way of instantiating
    iiv_test.SiteDailySum, hence the exception.

    How could this situation happen in a standalone app:

    - if you put cayenne.jar in $JRE_HOME/lib/ext/ . Please don't do that!
    - if you run from and IDE, (e.g. Eclipse) and add cayenne.jar to
    "Bootstrap Entries" instead of "User Entries"

    Now the bootstrap code.... Ideally it shouldn't be needed at all. If
    you run an app like this, it should work without it:

    java -cp cayenne.jar:/path/to/my/classes iiv_test.CreateReport

    Still if you have other reasons to use bootstrap, put it as a first
    line in the main() method.

    Andrus

    On Jul 14, 2004, at 9:09 AM, McBrayer, Roy wrote:

    > I have been unable to figure out where to put the statement
    >
    > Configuration.bootstrapSharedConfiguration(iiv_test.SiteDailySum);
    >
    > within my code. Where should this be located? In the main method?
    >
    > Also, what causes this problem? Is there any setting within the
    > Modeler
    > that will avoid it?
    >
    > Thanks,
    > Roy McBrayer
    >
    >
    >
    > -----Original Message-----
    > From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    > Sent: Tuesday, July 13, 2004 5:26 PM
    > To: cayenne-use..bjectstyle.org
    > Subject: Re: Newbie question on Cayenne error at runtime
    >
    >
    > Hi Roy,
    >
    > This looks like a nested ClassLoader issue recently discussed on the
    > list -
    > http://objectstyle.org/cayenne/lists/cayenne-user/2004/07/0047.html
    >
    > The solution is either load cayenne.jar using the same class loader as
    > the one used for the application classes (in case of web app, this
    > simply means putting cayenne.jar in the web app WEB-INF/lib/
    > directory), or bootstrap cayenne with appropriate class loader
    > explicitly:
    >
    > Configuration.bootstrapSharedConfiguration(iiv_test.SiteDailySum);
    >
    > The first solution is cleaner, but you don't always have a choice...
    >
    > Andrus
    >
    > On Jul 13, 2004, at 5:09 PM, McBrayer, Roy wrote:
    >> I am getting this error when trying to run a simple Cayenne based
    >> project.
    >> It builds just fine but when I try to run it I get the following.
    >>
    >>
    >> java.lang.IllegalArgumentException: Can't find ObjEntity for
    >> DataObject
    >> class: iiv_test.SiteDailySum, class is likely not mapped. at
    >> org.objectstyle.cayenne.access.DataContext.registerNewObject(DataConte
    >> x
    >> t.jav
    >> a:889) at iiv_test.CreateReport.createReport1(CreateReport.java:20)
    >
    >> at
    >> iiv_test.CreateReport.main(CreateReport.java:12) Exception in thread
    >> "main"
    >>
    >>
    >> I am also getting a long list of warnings like
    >>
    >> WARN EntityResolver: *** Class 'XplSdw' not found in runtime.
    >> Ignoring.
    >>
    >>
    >>
    >> I have created all of my Java source code and the 3 xml files.
    >>
    >> What else do I need to do?
    >>
    >> Roy McBrayer
    >> Dept. of Veteran's Affairs



    This archive was generated by hypermail 2.0.0 : Wed Jul 14 2004 - 16:58:12 EDT