I changed that, but still no result. :-/ It reports "can't access class
member with modifiers 'public'" and still the "can't intanciate class, may
be no constructor is available".

I really don't know what to do anymore.



-----Ursprüngliche Nachricht-----
Von: Gus Heck [mailto:[EMAIL PROTECTED]
Gesendet: Donnerstag, 18. Dezember 2003 21:20
An: OJB Users List
Betreff: Re: AW: JDO - Unable to build object instance


It might be because you havn't followed the javabean get/set pattern...

you wrote:

public String GetName() {
public void SetName(String name) {

but the standard pattern is

public String getName() {
public void setName(String name) {

This probably causes the enhancer to not recognize your object as having
any properties to enhance or some such.

- Gus


Sebastian Muench wrote:

>Hi all,
>
>yes, I have the default public constructor.
>May it be, I missed some settings?
>I did:
>- the mapping in the Person.jdo (copied to target/classes/JDOTest/)
>- the mapping in the repository_jdo.xml (in target/test/ojb/)
>- the schema - creation in the hsqldb
>
>The build and enhance of the class is successful.
>See more complete source code below.
>
>Thanks for help,
>Sebastian
>
>
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Person.class <<<<<<<<<<<<<<<<<<<<<<<
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>package JDOTest;
>
>import java.io.Serializable;
>
>public class Person implements Serializable {
>
>       private int id;
>       protected String name;
>
>       public Person() {
>
>       }
>
>       public Person(int id, String name) {
>               this.id = id;
>               this.name = name;
>       }
>
>       public int GetId() {
>               return this.id;
>       }
>
>       public String GetName() {
>               return this.name;
>       }
>
>       public void SetId(int id) {
>               this.id = id;
>       }
>
>       public void SetName(String name) {
>               this.name = name;
>       }
>
>}
>
>
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>TestJdo.class <<<<<<<<<<<<<<<<<<<<<<<
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
>...
>
>public class TestJdo {
>
>       private PersistenceManagerFactory factory;
>       private PersistenceManager manager;
>
>       public TestJdo() {
>
>               factory = null;
>               manager = null;
>
>               try {
>                       factory = new OjbStorePMF();
>                       manager = factory.getPersistenceManager();
>               } catch(Throwable t) {
>                       System.out.println(t.getMessage());
>                       t.printStackTrace();
>               }
>
>       }
>
>       ...
>
>       private void run() {
>
>               Person p = new Person();
>
>               try     {
>                       
> PersistenceBrokerFactory.defaultPersistenceBroker().clearCache();
>                       this.manager.currentTransaction().begin();
>                       Query query = this.manager.newQuery(Person.class);
>
>                       Collection allPerson = (Collection)query.execute();
>
>                       Iterator iter = allPerson.iterator();
>                       if(!iter.hasNext()) {
>                               System.out.println("No entries found");
>                       }
>
>                       while(iter.hasNext()) {
>                               System.out.println(iter.next());
>                       }
>
>                       manager.currentTransaction().commit();
>               } catch(Throwable t) {
>                       t.printStackTrace();
>               }
>
>               finally {
>                       manager.close();
>               }
>
>       }
>
>}
>
>
>-----Ursprüngliche Nachricht-----
>Von: Brian McCallister [mailto:[EMAIL PROTECTED]
>Gesendet: Mittwoch, 17. Dezember 2003 18:34
>An: OJB Users List
>Betreff: Re: JDO - Unable to build object instance
>
>
>It doesn't outside of JDO at least, I use private no-arg constructors
>with OJB all the time.
>
>-Brian
>
>
>On Wed, 2003-12-17 at 12:18, Gus Heck wrote:
>
>
>>Mahler Thomas wrote:
>>
>>
>>
>>>Hi Sebastian,
>>>
>>>Does your class have a public default constructor?
>>>
>>>
>>>
>>>
>>>
>>>
>> From _Core Java Data Objects_ page 51:
>>
>>"There is one requirement, however; JDO requires that a
>>persistence-capable class have a no-arguments constructor. This
>>constructor does not need to be declared public it just needs to be
>>accessible to the class itself and to any potential subclasses. If thee
>>are no sublcasses it can be declared as private."
>>
>>Does OJB place a further restriction that it must be public?
>>
>>-Gus
>>
>>
>>
>>>
>>>
>>>>-----Original Message-----
>>>>From: Sebastian Muench [mailto:[EMAIL PROTECTED]
>>>>Sent: Wednesday, December 17, 2003 1:42 AM
>>>>To: OJB Users List; [EMAIL PROTECTED]
>>>>Subject: R: JDO - Unable to build object instance
>>>>
>>>>
>>>>Oh, the file I mentioned in my last mail hasn't been attached.
>>>>Here is the screenshot:
>>>>
>>>>[JDO] DEBUG: OjbStoreConnector.begin: connectionReadyForRelease=false
>>>>[org.apache.ojb.broker.accesslayer.RsIterator] ERROR: Error
>>>>while iterate
>>>>ResultSet for query
>>>>org.apache.ojb.broker.accesslayer.RsQueryObject[query:
>>>>Query from class JDOTest.Person where null, class descriptor:
>>>>JDOTest.Person]
>>>>Unable to build object instance (MAYBE you don't have a constructor
>>>>available):class JDOTest.Person
>>>>org.apache.ojb.broker.PersistenceBrokerException: Unable to
>>>>build object
>>>>instance (MAYBE you don't have a constructor available):class
>>>>JDOTest.Person
>>>>       at
>>>>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWi
>>>>thReflection(R
>>>>owReaderDefaultImpl.java:239)
>>>>       at
>>>>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObj
>>>>ectFrom(RowRea
>>>>derDefaultImpl.java:115)
>>>>       at
>>>>org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResu
>>>>ltSet(RsIterat
>>>>or.java:463)
>>>>       at
>>>>org.apache.ojb.broker.accesslayer.RsIterator.next(RsIterator.java:284)
>>>>       at
>>>>org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionB
>>>>yQuery(QueryRe
>>>>ferenceBroker.java:147)
>>>>       at
>>>>org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionB
>>>>yQuery(QueryRe
>>>>ferenceBroker.java:244)
>>>>       at
>>>>org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionB
>>>>yQuery(QueryRe
>>>>ferenceBroker.java:263)
>>>>       at
>>>>org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollection
>>>>ByQuery(Persis
>>>>tenceBrokerImpl.java:997)
>>>>       at
>>>>org.apache.ojb.broker.core.DelegatingPersistenceBroker.getColl
>>>>ectionByQuery(
>>>>DelegatingPersistenceBroker.java:322)
>>>>       at
>>>>org.apache.ojb.broker.core.DelegatingPersistenceBroker.getColl
>>>>ectionByQuery(
>>>>DelegatingPersistenceBroker.java:322)
>>>>       at
>>>>org.apache.ojb.jdori.sql.OjbExtent.<init>(OjbExtent.java:98)
>>>>       at
>>>>org.apache.ojb.jdori.sql.OjbStoreManager.getExtent(OjbStoreMan
>>>>ager.java:251)
>>>>       at
>>>>com.sun.jdori.common.PersistenceManagerImpl.getExtent(Unknown
>>>>Source)
>>>>       at
>>>>com.sun.jdori.common.query.QueryImpl.checkCandidates(Unknown
>>>>Source)
>>>>       at
>>>>com.sun.jdori.common.query.QueryImpl.execute(Unknown Source)
>>>>       at JDOTest.TestJdo.run(TestJdo.java:52)
>>>>       at JDOTest.TestJdo.main(TestJdo.java:39)
>>>>Caused by:
>>>>org.apache.ojb.broker.metadata.ClassNotPersistenceCapableExcep
>>>>tion: (Could
>>>>not instantiate JDOTest.Person: Class
>>>>org.apache.ojb.broker.util.ConstructorHelper can not access a
>>>>member of
>>>>class JDOTest.Person with modifiers "public")
>>>>       at
>>>>org.apache.ojb.broker.util.ConstructorHelper.instantiate(Const
>>>>ructorHelper.j
>>>>ava:162)
>>>>       at
>>>>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWi
>>>>thReflection(R
>>>>owReaderDefaultImpl.java:235)
>>>>       ... 16 more
>>>>Caused by: java.lang.IllegalAccessException: Class
>>>>org.apache.ojb.broker.util.ConstructorHelper can not access a
>>>>member of
>>>>class JDOTest.Person with modifiers "public"
>>>>       at
>>>>sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)
>>>>       at
>>>>java.lang.reflect.Constructor.newInstance(Constructor.java:268)
>>>>       at
>>>>org.apache.ojb.broker.util.ConstructorHelper.instantiate(Const
>>>>ructorHelper.j
>>>>ava:158)
>>>>       ... 17 more
>>>>org.apache.ojb.broker.PersistenceBrokerException:
>>>>java.util.NoSuchElementException: Could not obtain next
>>>>object: Unable to
>>>>build object instance (MAYBE you
>>>>don't have a constructor available):class JDOTest.Person
>>>>       at
>>>>org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionB
>>>>yQuery(QueryRe
>>>>ferenceBroker.java:251)
>>>>       at
>>>>org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionB
>>>>yQuery(QueryRe
>>>>ferenceBroker.java:263)
>>>>       at
>>>>org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollection
>>>>ByQuery(Persis
>>>>tenceBrokerImpl.java:997)
>>>>       at
>>>>org.apache.ojb.broker.core.DelegatingPersistenceBroker.getColl
>>>>ectionByQuery(
>>>>DelegatingPersistenceBroker.java:322)
>>>>       at
>>>>org.apache.ojb.broker.core.DelegatingPersistenceBroker.getColl
>>>>ectionByQuery(
>>>>DelegatingPersistenceBroker.java:322)
>>>>       at
>>>>org.apache.ojb.jdori.sql.OjbExtent.<init>(OjbExtent.java:98)
>>>>       at
>>>>org.apache.ojb.jdori.sql.OjbStoreManager.getExtent(OjbStoreMan
>>>>ager.java:251)
>>>>       at
>>>>com.sun.jdori.common.PersistenceManagerImpl.getExtent(Unknown
>>>>Source)
>>>>       at
>>>>com.sun.jdori.common.query.QueryImpl.checkCandidates(Unknown
>>>>Source)
>>>>       at
>>>>com.sun.jdori.common.query.QueryImpl.execute(Unknown Source)
>>>>       at JDOTest.TestJdo.run(TestJdo.java:52)
>>>>       at JDOTest.TestJdo.main(TestJdo.java:39)
>>>>Caused by: java.util.NoSuchElementException: Could not obtain
>>>>next object:
>>>>Unable to build object instance (MAYBE you don't have a constructor
>>>>available):class JDOTest.Person
>>>>       at
>>>>org.apache.ojb.broker.accesslayer.RsIterator.next(RsIterator.java:310)
>>>>       at
>>>>org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionB
>>>>yQuery(QueryRe
>>>>ferenceBroker.java:147)
>>>>       at
>>>>org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionB
>>>>yQuery(QueryRe
>>>>ferenceBroker.java:244)
>>>>       ... 11 more
>>>>Exception in thread "main" javax.jdo.JDOUserException: Cannot close
>>>>PersistenceManager while transaction is still active.
>>>>       at
>>>>com.sun.jdori.common.PersistenceManagerImpl.close(Unknown Source)
>>>>       at
>>>>com.sun.jdori.common.PersistenceManagerImpl.popCurrentWrapper(Unknown
>>>>Source)
>>>>       at
>>>>com.sun.jdori.common.PersistenceManagerWrapper.close(Unknown
>>>>Source)
>>>>       at JDOTest.TestJdo.run(TestJdo.java:69)
>>>>       at JDOTest.TestJdo.main(TestJdo.java:39)
>>>>
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>>For additional commands, e-mail: [EMAIL PROTECTED]
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>>>
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



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


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

Reply via email to