The exception shows that OJB is trying to assign an instance of the wrong
object to User.logins. 

The problem actually lies in your repository.xml.

Look at the definition of the repository at
http://db.apache.org/ojb/repository.html,
and specifically at the collection-descriptor section. There is an optional
attribute "collection-class" which defines the collection class that OJB
will instantiate and assign.

Note that I have never used this facility of OJB, so I'm afraid I can't be
alot more help.

Cheers,

Charles.


>-----Original Message-----
>From: Goncalo Luiz [mailto:[EMAIL PROTECTED]
>Sent: 01 July 2003 18:30
>To: ML - OJB Users List
>Subject: Collections...
>
>
>Hello
>
>I creatd a class XPTO that extends a Vector, and use XPTO as a 
>container. I used it as follows:
>
>class A
>{
>XPTO bs; /**/
>}
>
>
>I get the following error when I try to persist object A:
>(what am I doing wrong?)
>
>[junit] [org.apache.ojb.broker.accesslayer.RsIterator] ERROR: 
>Error setting field:logins in object:domain.User
>[junit] ------------- ---------------- ---------------
>[junit] ------------- Standard Error -----------------
>[junit] java.lang.IllegalArgumentException
>[junit]     at 
>sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectField
>AccessorImpl.java:63)
>[junit]     at java.lang.reflect.Field.set(Field.java:519)
>[junit]     at 
>org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefau
>ltImpl.set(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveCollec
>tion(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveCollec
>tions(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResul
>tSet(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source)
>[junit]     at persistence.ojb.UserOJB.readByUsername(Unknown Source)
>[junit]     at 
>persistence.ojb.UserOJBTest.testReadExistingUserByUsername(Unkn
>own Source)
>[junit]     at 
>sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>[junit]     at 
>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccesso
>rImpl.java:39)
>[junit]     at 
>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMetho
>dAccessorImpl.java:25)
>[junit]     at java.lang.reflect.Method.invoke(Method.java:324)
>[junit]     at junit.framework.TestCase.runTest(TestCase.java:154)
>[junit]     at junit.framework.TestCase.runBare(TestCase.java:127)
>[junit]     at 
>junit.framework.TestResult$1.protect(TestResult.java:106)
>[junit]     at 
>junit.framework.TestResult.runProtected(TestResult.java:124)
>[junit]     at junit.framework.TestResult.run(TestResult.java:109)
>[junit]     at junit.framework.TestCase.run(TestCase.java:118)
>[junit]     at junit.framework.TestSuite.runTest(TestSuite.java:208)
>[junit]     at junit.framework.TestSuite.run(TestSuite.java:203)
>[junit]     at 
>org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.ru
>n(JUnitTestRunner.java:325)
>[junit]     at 
>org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.ma
>in(JUnitTestRunner.java:524)
>[junit] rethrown as 
>org.apache.ojb.broker.metadata.MetadataException: Error 
>setting field:logins in object:domain.Us
>
>[junit]     at 
>org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefau
>ltImpl.set(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveCollec
>tion(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveCollec
>tions(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResul
>tSet(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source)
>[junit]     at persistence.ojb.UserOJB.readByUsername(Unknown Source)
>[junit]     at 
>persistence.ojb.UserOJBTest.testReadExistingUserByUsername(Unkn
>own Source)
>[junit]     at 
>sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>[junit]     at 
>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccesso
>rImpl.java:39)
>[junit]     at 
>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMetho
>dAccessorImpl.java:25)
>[junit]     at java.lang.reflect.Method.invoke(Method.java:324)
>[junit]     at junit.framework.TestCase.runTest(TestCase.java:154)
>[junit]     at junit.framework.TestCase.runBare(TestCase.java:127)
>[junit]     at 
>junit.framework.TestResult$1.protect(TestResult.java:106)
>[junit]     at 
>junit.framework.TestResult.runProtected(TestResult.java:124)
>[junit]     at junit.framework.TestResult.run(TestResult.java:109)
>[junit]     at junit.framework.TestCase.run(TestCase.java:118)
>[junit]     at junit.framework.TestSuite.runTest(TestSuite.java:208)
>[junit]     at junit.framework.TestSuite.run(TestSuite.java:203)
>[junit]     at 
>org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.ru
>n(JUnitTestRunner.java:325)
>[junit]     at 
>org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.ma
>in(JUnitTestRunner.java:524)
>[junit] Caused by: java.lang.IllegalArgumentException
>[junit]     at 
>sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectField
>AccessorImpl.java:63)
>[junit]     at java.lang.reflect.Field.set(Field.java:519)
>[junit]     ... 21 more
>[junit] java.lang.IllegalArgumentException
>[junit]     at 
>sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectField
>AccessorImpl.java:63)
>[junit]     at java.lang.reflect.Field.set(Field.java:519)
>[junit]     at 
>org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefau
>ltImpl.set(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveCollec
>tion(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveCollec
>tions(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResul
>tSet(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source)
>[junit]     at persistence.ojb.UserOJB.readByUsername(Unknown Source)
>[junit]     at 
>persistence.ojb.UserOJBTest.testReadExistingUserByUsername(Unkn
>own Source)
>[junit]     at 
>sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>[junit]     at 
>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccesso
>rImpl.java:39)
>[junit]     at 
>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMetho
>dAccessorImpl.java:25)
>[junit]     at java.lang.reflect.Method.invoke(Method.java:324)
>[junit]     at junit.framework.TestCase.runTest(TestCase.java:154)
>[junit]     at junit.framework.TestCase.runBare(TestCase.java:127)
>[junit]     at 
>junit.framework.TestResult$1.protect(TestResult.java:106)
>[junit]     at 
>junit.framework.TestResult.runProtected(TestResult.java:124)
>[junit]     at junit.framework.TestResult.run(TestResult.java:109)
>[junit]     at junit.framework.TestCase.run(TestCase.java:118)
>[junit]     at junit.framework.TestSuite.runTest(TestSuite.java:208)
>[junit]     at junit.framework.TestSuite.run(TestSuite.java:203)
>[junit]     at 
>org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.ru
>n(JUnitTestRunner.java:325)
>[junit]     at 
>org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.ma
>in(JUnitTestRunner.java:524)
>[junit] rethrown as 
>org.apache.ojb.broker.metadata.MetadataException: Error 
>setting field:logins in object:domain.Us
>
>[junit]     at 
>org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefau
>ltImpl.set(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveCollec
>tion(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveCollec
>tions(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResul
>tSet(Unknown Source)
>[junit]     at 
>org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source)
>[junit]     at persistence.ojb.UserOJB.readByUsername(Unknown Source)
>[junit]     at 
>persistence.ojb.UserOJBTest.testReadExistingUserByUsername(Unkn
>own Source)
>[junit]     at 
>sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>[junit]     at 
>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccesso
>rImpl.java:39)
>[junit]     at 
>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMetho
>dAccessorImpl.java:25)
>[junit]     at java.lang.reflect.Method.invoke(Method.java:324)
>[junit]     at junit.framework.TestCase.runTest(TestCase.java:154)
>[junit]     at junit.framework.TestCase.runBare(TestCase.java:127)
>[junit]     at 
>junit.framework.TestResult$1.protect(TestResult.java:106)
>[junit]     at 
>junit.framework.TestResult.runProtected(TestResult.java:124)
>[junit]     at junit.framework.TestResult.run(TestResult.java:109)
>[junit]     at junit.framework.TestCase.run(TestCase.java:118)
>[junit]     at junit.framework.TestSuite.runTest(TestSuite.java:208)
>[junit]     at junit.framework.TestSuite.run(TestSuite.java:203)
>[junit]     at 
>org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.ru
>n(JUnitTestRunner.java:325)
>[junit]     at 
>org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.ma
>in(JUnitTestRunner.java:524)
>[junit] Caused by: java.lang.IllegalArgumentException
>[junit]     at 
>sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectField
>AccessorImpl.java:63)
>[junit]     at java.lang.reflect.Field.set(Field.java:519)
>[junit]     ... 21 more
>[junit] 1/Jul/2003 18:24:41 
>persistence.ojb.OJBPersistenceSupport beginTransaction
>[junit] SEVERE: beginTransaction:There was another transaction already.
>[junit] ------------- ---------------- ---------------
>
>[junit] Testcase: testReadExistingUserByUsername took 2,384 sec
>[junit]     FAILED
>[junit] could not clean test data.
>[junit] junit.framework.AssertionFailedError: could not clean 
>test data.
>[junit]     at 
>persistence.ojb.UserTestCaseOJB.cleanData(Unknown Source)
>[junit]     at persistence.ojb.UserTestCaseOJB.tearDown(Unknown Source)
>[junit]     at persistence.ojb.UserOJBTest.tearDown(Unknown Source)
>
>[junit] Testcase: testReadExistingUserByUsername
>----
>Gon�alo Luiz - IST 4� Ano (PSI) 
>[EMAIL PROTECTED]
>


This email and any attachments are strictly confidential and are intended
solely for the addressee. If you are not the intended recipient you must
not disclose, forward, copy or take any action in reliance on this message
or its attachments. If you have received this email in error please notify
the sender as soon as possible and delete it from your computer systems.
Any views or opinions presented are solely those of the author and do not
necessarily reflect those of HPD Software Limited or its affiliates.

 At present the integrity of email across the internet cannot be guaranteed
and messages sent via this medium are potentially at risk.  All liability
is excluded to the extent permitted by law for any claims arising as a re-
sult of the use of this medium to transmit information by or to 
HPD Software Limited or its affiliates.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to