You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by ADAMA COULIBALY <tu...@temple.edu> on 2012/04/03 06:55:48 UTC

errors

Hi
I am new to cayenne and I built my project. I get the following error:
Exception in thread "main" java.lang.IllegalArgumentException: Class is not
mapped with Cayenne: org.example.cayenne.persistent.Student at
org.apache.cayenne.access.DataContext.newObject(DataContext.java:689) at
org.example.cayenne.Main.main(Main.java:15)
I created three different project and I am getting the same error

Best,

Adama

Re: errors

Posted by ADAMA COULIBALY <tu...@temple.edu>.
Andrus

Thanks a lot. I started a new project in another workplace and that works
Best Reards

Adama

On Thu, Apr 5, 2012 at 4:43 AM, Andrus Adamchik <an...@objectstyle.org>wrote:

> I suspect you might have some other DataMap file that is loaded in runtime
> instead of the one you want. So you need to figure out which file the
> application actually loads.
>
> Unfortunately 3.1M3 doesn't log DataMap location during load (something I
> just fixed on trunk), but you can still verify which location is loaded by
> checking what cayenne-*.xml is used. Look for the line like this in the
> logs:
>
> INFO: Loading XML configuration resource from
> file:/Users/andrus/work/cayenne-git/framework/cayenne-jdk1.5-unpublished/target/test-classes/org/apache/cayenne/configuration/cayenne-testConfig1.xml
>
> Then open this file, and check the location of the DataMap in it. E.g.:
>
> <map name="testConfigMap2" location="testConfigMap2.map.xml"/>
>
> Since the location is relative to cayenne-testConfig.xml, the full
> location will be
>
>
> /Users/andrus/work/cayenne-git/framework/cayenne-jdk1.5-unpublished/target/test-classes/org/apache/cayenne/configuration/testConfigMap2.map.xml
>
> Now verify that this is the right DataMap.
>
> Andrus
>
> On Apr 4, 2012, at 9:11 PM, ADAMA COULIBALY wrote:
>
> > Hi Andrus
> >
> > I this is the content of my DataMap XML file
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
> >  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >  xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap
> > http://cayenne.apache.org/schema/3.0/modelMap.xsd"
> >  project-version="3.0.0.1">
> > <property name="defaultPackage" value="org.example.cayenne.persistent"/>
> > <db-entity name="BOOK">
> > <db-attribute name="AUTHOR" type="VARCHAR" length="200"/>
> > <db-attribute name="BOOK_ID" type="INTEGER" isPrimaryKey="true"
> > isMandatory="true"/>
> > <db-attribute name="TITLE" type="VARCHAR" length="200"/>
> > </db-entity>
> > <db-entity name="LOAN">
> > <db-attribute name="DATE" type="DATE"/>
> > <db-attribute name="LOAN_BOOK_ID" type="INTEGER"/>
> > <db-attribute name="LOAN_ID" type="INTEGER" isPrimaryKey="true"
> > isMandatory="true"/>
> > <db-attribute name="LOAN_STU_ID" type="INTEGER"/>
> > </db-entity>
> > <db-entity name="STUDENT">
> > <db-attribute name="MAJOR" type="VARCHAR" length="200"/>
> > <db-attribute name="NAME" type="VARCHAR" length="200"/>
> > <db-attribute name="STUDENT_ID" type="INTEGER" isPrimaryKey="true"
> > isMandatory="true"/>
> > </db-entity>
> > <obj-entity name="Book" className="org.example.cayenne.persistent.Book"
> > dbEntityName="BOOK">
> > <obj-attribute name="author" type="java.lang.String"
> > db-attribute-path="AUTHOR"/>
> > <obj-attribute name="title" type="java.lang.String"
> > db-attribute-path="TITLE"/>
> > </obj-entity>
> > <obj-entity name="Loan" className="org.example.cayenne.persistent.Loan"
> > dbEntityName="LOAN">
> > <obj-attribute name="date" type="java.util.Date"
> db-attribute-path="DATE"/>
> > </obj-entity>
> > <obj-entity name="Student"
> > className="org.example.cayenne.persistent.Student"
> dbEntityName="STUDENT">
> > <obj-attribute name="major" type="java.lang.String"
> > db-attribute-path="MAJOR"/>
> > <obj-attribute name="name" type="java.lang.String"
> > db-attribute-path="NAME"/>
> > </obj-entity>
> > <db-relationship name="loans" source="BOOK" target="LOAN" toMany="true">
> > <db-attribute-pair source="BOOK_ID" target="LOAN_BOOK_ID"/>
> > </db-relationship>
> > <db-relationship name="book" source="LOAN" target="BOOK" toMany="false">
> > <db-attribute-pair source="LOAN_BOOK_ID" target="BOOK_ID"/>
> > </db-relationship>
> > <db-relationship name="student" source="LOAN" target="STUDENT"
> > toMany="false">
> > <db-attribute-pair source="LOAN_STU_ID" target="STUDENT_ID"/>
> > </db-relationship>
> > <db-relationship name="loans" source="STUDENT" target="LOAN"
> toMany="true">
> > <db-attribute-pair source="STUDENT_ID" target="LOAN_STU_ID"/>
> > </db-relationship>
> > <obj-relationship name="loans" source="Book" target="Loan"
> > deleteRule="Deny" db-relationship-path="loans"/>
> > <obj-relationship name="book" source="Loan" target="Book"
> > deleteRule="Nullify" db-relationship-path="book"/>
> > <obj-relationship name="student" source="Loan" target="Student"
> > deleteRule="Nullify" db-relationship-path="student"/>
> > <obj-relationship name="loans" source="Student" target="Loan"
> > deleteRule="Deny" db-relationship-path="loans"/>
> > </data-map>
> >
> > I cannot not create instance of Student, Book, and Loan class
> > And I created another project to make sure that I did all mapping
> correctly
> > but I am getting the same errors
> >
> > Best,
> >
> > Adama
> >
> >
> > On Tue, Apr 3, 2012 at 3:14 AM, Andrus Adamchik <andrus@objectstyle.org
> >wrote:
> >
> >> Check your DataMap XML file (*.map.xml) - is there indeed a mapping for
> >> org.example.cayenne.persistent.Student?
> >>
> >>
> >> On Apr 3, 2012, at 7:55 AM, ADAMA COULIBALY wrote:
> >>
> >>> Hi
> >>> I am new to cayenne and I built my project. I get the following error:
> >>> Exception in thread "main" java.lang.IllegalArgumentException: Class is
> >> not
> >>> mapped with Cayenne: org.example.cayenne.persistent.Student at
> >>> org.apache.cayenne.access.DataContext.newObject(DataContext.java:689)
> at
> >>> org.example.cayenne.Main.main(Main.java:15)
> >>> I created three different project and I am getting the same error
> >>>
> >>> Best,
> >>>
> >>> Adama
> >>
> >>
>
>

Re: errors

Posted by Andrus Adamchik <an...@objectstyle.org>.
Hmm... actually 'project-version="3.0.0.1"' indicates that you are on Cayenne 3.0.x, which should print the DataMap XML location on startup with no special tricks.

Andrus

On Apr 5, 2012, at 11:43 AM, Andrus Adamchik wrote:

> I suspect you might have some other DataMap file that is loaded in runtime instead of the one you want. So you need to figure out which file the application actually loads. 
> 
> Unfortunately 3.1M3 doesn't log DataMap location during load (something I just fixed on trunk), but you can still verify which location is loaded by checking what cayenne-*.xml is used. Look for the line like this in the logs:
> 
> INFO: Loading XML configuration resource from file:/Users/andrus/work/cayenne-git/framework/cayenne-jdk1.5-unpublished/target/test-classes/org/apache/cayenne/configuration/cayenne-testConfig1.xml
> 
> Then open this file, and check the location of the DataMap in it. E.g.:
> 
> <map name="testConfigMap2" location="testConfigMap2.map.xml"/>
> 
> Since the location is relative to cayenne-testConfig.xml, the full location will be
> 
> /Users/andrus/work/cayenne-git/framework/cayenne-jdk1.5-unpublished/target/test-classes/org/apache/cayenne/configuration/testConfigMap2.map.xml
> 
> Now verify that this is the right DataMap.
> 
> Andrus
> 
> On Apr 4, 2012, at 9:11 PM, ADAMA COULIBALY wrote:
> 
>> Hi Andrus
>> 
>> I this is the content of my DataMap XML file
>> 
>> <?xml version="1.0" encoding="utf-8"?>
>> <data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap
>> http://cayenne.apache.org/schema/3.0/modelMap.xsd"
>> project-version="3.0.0.1">
>> <property name="defaultPackage" value="org.example.cayenne.persistent"/>
>> <db-entity name="BOOK">
>> <db-attribute name="AUTHOR" type="VARCHAR" length="200"/>
>> <db-attribute name="BOOK_ID" type="INTEGER" isPrimaryKey="true"
>> isMandatory="true"/>
>> <db-attribute name="TITLE" type="VARCHAR" length="200"/>
>> </db-entity>
>> <db-entity name="LOAN">
>> <db-attribute name="DATE" type="DATE"/>
>> <db-attribute name="LOAN_BOOK_ID" type="INTEGER"/>
>> <db-attribute name="LOAN_ID" type="INTEGER" isPrimaryKey="true"
>> isMandatory="true"/>
>> <db-attribute name="LOAN_STU_ID" type="INTEGER"/>
>> </db-entity>
>> <db-entity name="STUDENT">
>> <db-attribute name="MAJOR" type="VARCHAR" length="200"/>
>> <db-attribute name="NAME" type="VARCHAR" length="200"/>
>> <db-attribute name="STUDENT_ID" type="INTEGER" isPrimaryKey="true"
>> isMandatory="true"/>
>> </db-entity>
>> <obj-entity name="Book" className="org.example.cayenne.persistent.Book"
>> dbEntityName="BOOK">
>> <obj-attribute name="author" type="java.lang.String"
>> db-attribute-path="AUTHOR"/>
>> <obj-attribute name="title" type="java.lang.String"
>> db-attribute-path="TITLE"/>
>> </obj-entity>
>> <obj-entity name="Loan" className="org.example.cayenne.persistent.Loan"
>> dbEntityName="LOAN">
>> <obj-attribute name="date" type="java.util.Date" db-attribute-path="DATE"/>
>> </obj-entity>
>> <obj-entity name="Student"
>> className="org.example.cayenne.persistent.Student" dbEntityName="STUDENT">
>> <obj-attribute name="major" type="java.lang.String"
>> db-attribute-path="MAJOR"/>
>> <obj-attribute name="name" type="java.lang.String"
>> db-attribute-path="NAME"/>
>> </obj-entity>
>> <db-relationship name="loans" source="BOOK" target="LOAN" toMany="true">
>> <db-attribute-pair source="BOOK_ID" target="LOAN_BOOK_ID"/>
>> </db-relationship>
>> <db-relationship name="book" source="LOAN" target="BOOK" toMany="false">
>> <db-attribute-pair source="LOAN_BOOK_ID" target="BOOK_ID"/>
>> </db-relationship>
>> <db-relationship name="student" source="LOAN" target="STUDENT"
>> toMany="false">
>> <db-attribute-pair source="LOAN_STU_ID" target="STUDENT_ID"/>
>> </db-relationship>
>> <db-relationship name="loans" source="STUDENT" target="LOAN" toMany="true">
>> <db-attribute-pair source="STUDENT_ID" target="LOAN_STU_ID"/>
>> </db-relationship>
>> <obj-relationship name="loans" source="Book" target="Loan"
>> deleteRule="Deny" db-relationship-path="loans"/>
>> <obj-relationship name="book" source="Loan" target="Book"
>> deleteRule="Nullify" db-relationship-path="book"/>
>> <obj-relationship name="student" source="Loan" target="Student"
>> deleteRule="Nullify" db-relationship-path="student"/>
>> <obj-relationship name="loans" source="Student" target="Loan"
>> deleteRule="Deny" db-relationship-path="loans"/>
>> </data-map>
>> 
>> I cannot not create instance of Student, Book, and Loan class
>> And I created another project to make sure that I did all mapping correctly
>> but I am getting the same errors
>> 
>> Best,
>> 
>> Adama
>> 
>> 
>> On Tue, Apr 3, 2012 at 3:14 AM, Andrus Adamchik <an...@objectstyle.org>wrote:
>> 
>>> Check your DataMap XML file (*.map.xml) - is there indeed a mapping for
>>> org.example.cayenne.persistent.Student?
>>> 
>>> 
>>> On Apr 3, 2012, at 7:55 AM, ADAMA COULIBALY wrote:
>>> 
>>>> Hi
>>>> I am new to cayenne and I built my project. I get the following error:
>>>> Exception in thread "main" java.lang.IllegalArgumentException: Class is
>>> not
>>>> mapped with Cayenne: org.example.cayenne.persistent.Student at
>>>> org.apache.cayenne.access.DataContext.newObject(DataContext.java:689) at
>>>> org.example.cayenne.Main.main(Main.java:15)
>>>> I created three different project and I am getting the same error
>>>> 
>>>> Best,
>>>> 
>>>> Adama
>>> 
>>> 
> 
> 


Re: errors

Posted by Andrus Adamchik <an...@objectstyle.org>.
I suspect you might have some other DataMap file that is loaded in runtime instead of the one you want. So you need to figure out which file the application actually loads. 

Unfortunately 3.1M3 doesn't log DataMap location during load (something I just fixed on trunk), but you can still verify which location is loaded by checking what cayenne-*.xml is used. Look for the line like this in the logs:

INFO: Loading XML configuration resource from file:/Users/andrus/work/cayenne-git/framework/cayenne-jdk1.5-unpublished/target/test-classes/org/apache/cayenne/configuration/cayenne-testConfig1.xml

Then open this file, and check the location of the DataMap in it. E.g.:

<map name="testConfigMap2" location="testConfigMap2.map.xml"/>

Since the location is relative to cayenne-testConfig.xml, the full location will be

/Users/andrus/work/cayenne-git/framework/cayenne-jdk1.5-unpublished/target/test-classes/org/apache/cayenne/configuration/testConfigMap2.map.xml

Now verify that this is the right DataMap.

Andrus

On Apr 4, 2012, at 9:11 PM, ADAMA COULIBALY wrote:

> Hi Andrus
> 
> I this is the content of my DataMap XML file
> 
> <?xml version="1.0" encoding="utf-8"?>
> <data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>  xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap
> http://cayenne.apache.org/schema/3.0/modelMap.xsd"
>  project-version="3.0.0.1">
> <property name="defaultPackage" value="org.example.cayenne.persistent"/>
> <db-entity name="BOOK">
> <db-attribute name="AUTHOR" type="VARCHAR" length="200"/>
> <db-attribute name="BOOK_ID" type="INTEGER" isPrimaryKey="true"
> isMandatory="true"/>
> <db-attribute name="TITLE" type="VARCHAR" length="200"/>
> </db-entity>
> <db-entity name="LOAN">
> <db-attribute name="DATE" type="DATE"/>
> <db-attribute name="LOAN_BOOK_ID" type="INTEGER"/>
> <db-attribute name="LOAN_ID" type="INTEGER" isPrimaryKey="true"
> isMandatory="true"/>
> <db-attribute name="LOAN_STU_ID" type="INTEGER"/>
> </db-entity>
> <db-entity name="STUDENT">
> <db-attribute name="MAJOR" type="VARCHAR" length="200"/>
> <db-attribute name="NAME" type="VARCHAR" length="200"/>
> <db-attribute name="STUDENT_ID" type="INTEGER" isPrimaryKey="true"
> isMandatory="true"/>
> </db-entity>
> <obj-entity name="Book" className="org.example.cayenne.persistent.Book"
> dbEntityName="BOOK">
> <obj-attribute name="author" type="java.lang.String"
> db-attribute-path="AUTHOR"/>
> <obj-attribute name="title" type="java.lang.String"
> db-attribute-path="TITLE"/>
> </obj-entity>
> <obj-entity name="Loan" className="org.example.cayenne.persistent.Loan"
> dbEntityName="LOAN">
> <obj-attribute name="date" type="java.util.Date" db-attribute-path="DATE"/>
> </obj-entity>
> <obj-entity name="Student"
> className="org.example.cayenne.persistent.Student" dbEntityName="STUDENT">
> <obj-attribute name="major" type="java.lang.String"
> db-attribute-path="MAJOR"/>
> <obj-attribute name="name" type="java.lang.String"
> db-attribute-path="NAME"/>
> </obj-entity>
> <db-relationship name="loans" source="BOOK" target="LOAN" toMany="true">
> <db-attribute-pair source="BOOK_ID" target="LOAN_BOOK_ID"/>
> </db-relationship>
> <db-relationship name="book" source="LOAN" target="BOOK" toMany="false">
> <db-attribute-pair source="LOAN_BOOK_ID" target="BOOK_ID"/>
> </db-relationship>
> <db-relationship name="student" source="LOAN" target="STUDENT"
> toMany="false">
> <db-attribute-pair source="LOAN_STU_ID" target="STUDENT_ID"/>
> </db-relationship>
> <db-relationship name="loans" source="STUDENT" target="LOAN" toMany="true">
> <db-attribute-pair source="STUDENT_ID" target="LOAN_STU_ID"/>
> </db-relationship>
> <obj-relationship name="loans" source="Book" target="Loan"
> deleteRule="Deny" db-relationship-path="loans"/>
> <obj-relationship name="book" source="Loan" target="Book"
> deleteRule="Nullify" db-relationship-path="book"/>
> <obj-relationship name="student" source="Loan" target="Student"
> deleteRule="Nullify" db-relationship-path="student"/>
> <obj-relationship name="loans" source="Student" target="Loan"
> deleteRule="Deny" db-relationship-path="loans"/>
> </data-map>
> 
> I cannot not create instance of Student, Book, and Loan class
> And I created another project to make sure that I did all mapping correctly
> but I am getting the same errors
> 
> Best,
> 
> Adama
> 
> 
> On Tue, Apr 3, 2012 at 3:14 AM, Andrus Adamchik <an...@objectstyle.org>wrote:
> 
>> Check your DataMap XML file (*.map.xml) - is there indeed a mapping for
>> org.example.cayenne.persistent.Student?
>> 
>> 
>> On Apr 3, 2012, at 7:55 AM, ADAMA COULIBALY wrote:
>> 
>>> Hi
>>> I am new to cayenne and I built my project. I get the following error:
>>> Exception in thread "main" java.lang.IllegalArgumentException: Class is
>> not
>>> mapped with Cayenne: org.example.cayenne.persistent.Student at
>>> org.apache.cayenne.access.DataContext.newObject(DataContext.java:689) at
>>> org.example.cayenne.Main.main(Main.java:15)
>>> I created three different project and I am getting the same error
>>> 
>>> Best,
>>> 
>>> Adama
>> 
>> 


Re: errors

Posted by ADAMA COULIBALY <tu...@temple.edu>.
Hi Andrus

I this is the content of my DataMap XML file

<?xml version="1.0" encoding="utf-8"?>
<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap
http://cayenne.apache.org/schema/3.0/modelMap.xsd"
  project-version="3.0.0.1">
<property name="defaultPackage" value="org.example.cayenne.persistent"/>
<db-entity name="BOOK">
<db-attribute name="AUTHOR" type="VARCHAR" length="200"/>
<db-attribute name="BOOK_ID" type="INTEGER" isPrimaryKey="true"
isMandatory="true"/>
<db-attribute name="TITLE" type="VARCHAR" length="200"/>
</db-entity>
<db-entity name="LOAN">
<db-attribute name="DATE" type="DATE"/>
<db-attribute name="LOAN_BOOK_ID" type="INTEGER"/>
<db-attribute name="LOAN_ID" type="INTEGER" isPrimaryKey="true"
isMandatory="true"/>
<db-attribute name="LOAN_STU_ID" type="INTEGER"/>
</db-entity>
<db-entity name="STUDENT">
<db-attribute name="MAJOR" type="VARCHAR" length="200"/>
<db-attribute name="NAME" type="VARCHAR" length="200"/>
<db-attribute name="STUDENT_ID" type="INTEGER" isPrimaryKey="true"
isMandatory="true"/>
</db-entity>
<obj-entity name="Book" className="org.example.cayenne.persistent.Book"
dbEntityName="BOOK">
<obj-attribute name="author" type="java.lang.String"
db-attribute-path="AUTHOR"/>
<obj-attribute name="title" type="java.lang.String"
db-attribute-path="TITLE"/>
</obj-entity>
<obj-entity name="Loan" className="org.example.cayenne.persistent.Loan"
dbEntityName="LOAN">
<obj-attribute name="date" type="java.util.Date" db-attribute-path="DATE"/>
</obj-entity>
<obj-entity name="Student"
className="org.example.cayenne.persistent.Student" dbEntityName="STUDENT">
<obj-attribute name="major" type="java.lang.String"
db-attribute-path="MAJOR"/>
<obj-attribute name="name" type="java.lang.String"
db-attribute-path="NAME"/>
</obj-entity>
<db-relationship name="loans" source="BOOK" target="LOAN" toMany="true">
<db-attribute-pair source="BOOK_ID" target="LOAN_BOOK_ID"/>
</db-relationship>
<db-relationship name="book" source="LOAN" target="BOOK" toMany="false">
<db-attribute-pair source="LOAN_BOOK_ID" target="BOOK_ID"/>
</db-relationship>
<db-relationship name="student" source="LOAN" target="STUDENT"
toMany="false">
<db-attribute-pair source="LOAN_STU_ID" target="STUDENT_ID"/>
</db-relationship>
<db-relationship name="loans" source="STUDENT" target="LOAN" toMany="true">
<db-attribute-pair source="STUDENT_ID" target="LOAN_STU_ID"/>
</db-relationship>
<obj-relationship name="loans" source="Book" target="Loan"
deleteRule="Deny" db-relationship-path="loans"/>
<obj-relationship name="book" source="Loan" target="Book"
deleteRule="Nullify" db-relationship-path="book"/>
<obj-relationship name="student" source="Loan" target="Student"
deleteRule="Nullify" db-relationship-path="student"/>
<obj-relationship name="loans" source="Student" target="Loan"
deleteRule="Deny" db-relationship-path="loans"/>
</data-map>

I cannot not create instance of Student, Book, and Loan class
And I created another project to make sure that I did all mapping correctly
but I am getting the same errors

Best,

Adama


On Tue, Apr 3, 2012 at 3:14 AM, Andrus Adamchik <an...@objectstyle.org>wrote:

> Check your DataMap XML file (*.map.xml) - is there indeed a mapping for
> org.example.cayenne.persistent.Student?
>
>
> On Apr 3, 2012, at 7:55 AM, ADAMA COULIBALY wrote:
>
> > Hi
> > I am new to cayenne and I built my project. I get the following error:
> > Exception in thread "main" java.lang.IllegalArgumentException: Class is
> not
> > mapped with Cayenne: org.example.cayenne.persistent.Student at
> > org.apache.cayenne.access.DataContext.newObject(DataContext.java:689) at
> > org.example.cayenne.Main.main(Main.java:15)
> > I created three different project and I am getting the same error
> >
> > Best,
> >
> > Adama
>
>

Re: errors

Posted by Andrus Adamchik <an...@objectstyle.org>.
Check your DataMap XML file (*.map.xml) - is there indeed a mapping for org.example.cayenne.persistent.Student?


On Apr 3, 2012, at 7:55 AM, ADAMA COULIBALY wrote:

> Hi
> I am new to cayenne and I built my project. I get the following error:
> Exception in thread "main" java.lang.IllegalArgumentException: Class is not
> mapped with Cayenne: org.example.cayenne.persistent.Student at
> org.apache.cayenne.access.DataContext.newObject(DataContext.java:689) at
> org.example.cayenne.Main.main(Main.java:15)
> I created three different project and I am getting the same error
> 
> Best,
> 
> Adama