cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mary-Anne Wolf <...@mocasystems.com>
Subject Re: No DataMap found, can't route query
Date Wed, 05 Mar 2008 00:19:15 GMT
Thanks, Michael, but something else appears to be the problem.
The XML files are at the top of the same "bin" directory
where the *.class files are placed.
When I run code in the debugger,
I can detect that the db-entity parts of my map.xml file
are getting loaded, so the problem is not trouble finding the file
The problem appears to be with the obj-entity parts of the XML.

In org.apache.cayenne.util.Util, where it says
*return Class.forName(className, true, classLoader);*
the first class it tries to find in my code is "Account". 
The full name of the class should be "com.mocasystems.apui.db.Account",
so if there is only "Account", forName cannot find it.  Oops!
I am not sure how this happened.
Maybe I assumed Eclipse would do the right thing
when I moved stuff,
but this XML is in the *.map.xml file
<obj-entity name="Account"
className="Account"
dbEntityName="ACCOUNT">

So I think I need to modify the *.map.xml file.
Does anyone know if I should add the package information
anywhere besides in the classname of the obj-entity?
Should I change the name as well?  If I do,
I may also need to tweak obj-relationship,
but if I don't, there is more risk of collisions.

Mary-Anne

Michael Gentry wrote:
> Look at where Eclipse built your .class files/etc and make sure that
> it did indeed put your cayenne.xml file in there when it built the
> project.  It needs to be at the top-level of that classpath.
>
> /dev/mrg
>
>
> On Tue, Mar 4, 2008 at 4:02 PM, Mary-Anne Wolf <mgw@mocasystems.com> wrote:
>   
>> I am just starting to use Cayenne.  After successfully reverse
>>  engineering a database and generating Java classes, I have written this
>>  minimal program
>>
>>     public static void main(String[] args) {
>>
>>         DataContext context = DataContext.createDataContext();
>>         SelectQuery q = new SelectQuery(Mocauser.class);
>>         List list = context.performQuery(q);
>>         System.out.println(list.size());
>>     }
>>
>>  When I run this code in Eclipse, I get this Exception stack:
>>  Exception in thread "main" org.apache.cayenne.CayenneRuntimeException:
>>  [v.2.0.4 October 8 2007] No DataMap found, can't route query
>>  org.apache.cayenne.query.SelectQuery@43462851[root=class
>>  com.mocasystems.apui.db.Mocauser,name=<null>]
>>     at org.apache.cayenne.query.AbstractQuery.route(AbstractQuery.java:137)
>>     at org.apache.cayenne.query.SelectQuery.route(SelectQuery.java:171)
>>     at
>>  org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:292)
>>     at
>>  org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQueryAction.java:60)
>>     at
>>  org.apache.cayenne.access.DataDomainQueryAction$1.transform(DataDomainQueryAction.java:273)
>>     at
>>  org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:836)
>>     at
>>  org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:270)
>>     at
>>  org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:110)
>>     at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:746)
>>     at
>>  org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:217)
>>     at
>>  org.apache.cayenne.access.DataContextQueryAction.execute(DataContextQueryAction.java:54)
>>     at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1395)
>>     at
>>  org.apache.cayenne.access.DataContext.performQuery(DataContext.java:1384)
>>     at com.mocasystems.apui.Main.main(Main.java:19)
>>
>>  My two XML files, currently named cayenne.xml and UntitledMap.map.xml
>>  are in a config directory which I have listed in Eclipse as a source
>>  directory.  This means that the cayenne.xml file, at least, can be
>>  found, because it is on the classpath.
>>
>>  I have verified that the name of the map file is accurately listed in
>>  cayenne.xml.
>>  <domains project-version="2.0">
>>   <domain name="UntitledDomain">
>>     <map name="UntitledMap" location="UntitledMap.map.xml"/>
>>   </domain>
>>  </domains>
>>
>>  Can anyone give me some help about how the map file is supposed to be
>>  found, and what might cause my problem in finding the map file?
>>
>>  Thanks,
>>
>>  Mary-Anne
>>
>>
>>     


Mime
View raw message