SOLVED: JDO - Unable to build object instance

2003-12-25 Thread Sebastian Muench
()) {
System.out.println(No Product entries found!);
}

while (iter.hasNext()) {
House house = (House) iter.next();
System.out.println(house.toString());
}

manager.currentTransaction().commit();

} catch (Throwable t) {
t.printStackTrace();
}

finally {
manager.close();
}
}

private void getHouses() {

System.out.print(Insert house - ID: );
int house = Integer.parseInt(readLine());
System.out.println(All listings for house  + house);

}

}

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


Sebastian,

One thing I notice that is different about your implementation (from
mine) is that your table name does not directly match your class name. I
think that _shouldn't_ matter, but it is a difference. There are few
other differences too.

I notice your jdo file is full of ojb-extensions to specify table names,
user name and such. This also differs from mine.  Mine looks like this
(one class only shown, generated by Xdoclet)

?xml version=1.0 encoding=UTF-8?
!DOCTYPE jdo PUBLIC -//Sun Microsystems, Inc.//DTD Java Data Objects
Metadata 1.0//EN http://java.sun.com/dtd/jdo_1_0.dtd;

jdo
  package name=org.cs101.fdb.impl.jdo
class name=LocationBase
   identity-type=application
 !-- end class tag --
/class
  /package

!--
To use additional vendor extensions, create a vendor-extensions.xml
file that
contains the additional extensions (in extension tags) and place it
in your
projects merge dir.
--

/jdo

What is working for me is Xdoclet generated repository_user.xml, Xdoclet
generated package.jdo, and MySQL. Torque is creating the database tables
for me at runtime, though creating the tables at build time or
independantly should suffice so long as nothing silly happens like
creating tables in one db and then connecting to another. Insert usual
caveats about everything staying in sync here...

One direction you might take is to cut back to letting everything fall
into default naming and see if it works, then if it does, add in your
customizations one by one to see what breaks it.

Looking at your extension elements, I also just wondered this... did you
specify your user name and password in repository.xml
(repository_database.xml)? Granted the error message is very odd if that
is the type of problem here, but...

-Gus

Sebastian Muench wrote:

Hi,

at first, thank you for help so far. Unfortunately, the error message is
still appearing. I checked the information given by the doc you referred me
to, Gus. The strange thing at all is, that I can make new objects
persistent
without problems. But retrieving collections is still the problem. I
checked
and doublechecked everything, but don't know where's the problem.

My persistente class is House. I'm testing on the HSQLDB, comming with OJB.
I prepare my user class for enhancing by compiling it as usual, and copy
the
class files to my dir target/classes/package/ and
target/classestest/package/
As I already wrote, enhancing is successful.

Here some important lines from my repository_jdo.xml, House.jdo,
House.java,
etc.


SQL statement for the table in HSQLDB

CREATE TABLE Seb_House (
ID INTEGER NOT NULL PRIMARY KEY,
NAME VARCHAR)




Corresponding mapping tags in repository_jdo.xml

   !-- Definitions for dbsii.House --
   class-descriptor
  class=dbsii.House
  table=Seb_House
   
  field-descriptor
 name=id
 column=ID
 jdbc-type=INTEGER
 primarykey=true
  /
  field-descriptor
 name=name
 column=NAME
 jdbc-type=VARCHAR
  /
   /class-descriptor



The persistente class file

package dbsii;

import java.io.Serializable;

class House implements Serializable {

   private int id;
   protected String name;

   public House() {
   }

   public House(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;
   }

   public String toString() {
return [ + this.id + ]  + this.name;
}

}




The corresponding House.jdo

?xml version=1.0 encoding=UTF-8?
!DOCTYPE jdo PUBLIC -//Sun Microsystems, Inc.//DTD Java Data Objects
Metadata 1.0//EN http://java.sun.com/dtd/jdo_1_0.dtd;

jdo

 !--extension vendor-name=ojb key=dbplatform value=hsqldb/
 extension vendor

AW: AW: JDO - Unable to build object instance

2003-12-19 Thread Sebastian Muench
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

AW: JDO - Unable to build object instance

2003-12-17 Thread Sebastian Muench
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

R: JDO - Unable to build object instance

2003-12-16 Thread Sebastian Muench
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.buildWithReflection(R
owReaderDefaultImpl.java:239)
at
org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObjectFrom(RowRea
derDefaultImpl.java:115)
at
org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(RsIterat
or.java:463)
at
org.apache.ojb.broker.accesslayer.RsIterator.next(RsIterator.java:284)
at
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryRe
ferenceBroker.java:147)
at
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryRe
ferenceBroker.java:244)
at
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryRe
ferenceBroker.java:263)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
tenceBrokerImpl.java:997)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(
DelegatingPersistenceBroker.java:322)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(
DelegatingPersistenceBroker.java:322)
at org.apache.ojb.jdori.sql.OjbExtent.init(OjbExtent.java:98)
at
org.apache.ojb.jdori.sql.OjbStoreManager.getExtent(OjbStoreManager.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.ClassNotPersistenceCapableException: (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(ConstructorHelper.j
ava:162)
at
org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWithReflection(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(ConstructorHelper.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.getCollectionByQuery(QueryRe
ferenceBroker.java:251)
at
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryRe
ferenceBroker.java:263)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
tenceBrokerImpl.java:997)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(
DelegatingPersistenceBroker.java:322)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(
DelegatingPersistenceBroker.java:322)
at org.apache.ojb.jdori.sql.OjbExtent.init(OjbExtent.java:98)
at
org.apache.ojb.jdori.sql.OjbStoreManager.getExtent(OjbStoreManager.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.getCollectionByQuery(QueryRe
ferenceBroker.java:147)
at
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryRe
ferenceBroker.java:244)
... 11 more
Exception in thread main javax.jdo.JDOUserException: Cannot 

JDO Enhancer

2003-12-13 Thread Sebastian Muench
Hi,

I get an error class given to extent does not implement
javax.jod.spi.PersistenteCapable anytime I run my jdo-application. I put
the mapping entries in the repository_jdo.xml. I don't know how to set up
the bytecode enhancer. Do I have to compile my SourceCode a second time
including the enhancer? How do I have to do that? Thanks for any kind of
help (including hints where to find documentation)

Greetinx,
Sebastian


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



install jdo-api

2003-12-12 Thread Sebastian Muench
Hi all,

I try to execute the jdo-tutorial after installing ojb by following the
quickstart guide. I added the obj/lib directory to my classpath. The
tutorial applicaions 1 and 2 are running fine. By building the jdo-tutorial
(using bin/build.sh with-jdori prepare-tutorials enhance-jdori ), I get the
following error (please see below).
Does anybody know how to fix that?

Thanx for help,
Sebastian

[EMAIL PROTECTED] db-ojb-1.0.rc4]# bin/build.sh with-jdori prepare-tutorials
enhance-jdori
Buildfile: build.xml

splash:

set-archive-name:

set-archive-name-date:

detect-jdk:

check-jdk12proxy-classes:

check-jndi-classes:

use-jdk12:

use-jdk13:

use-jdk14:
 [echo] detected JDK 1.4

init:

prepare:

check-jdo-classes:

check-jdori-classes:

with-jdori:
 [copy] Copying 16 files to /usr/local/src/db-ojb-1.0.rc4/target/src
 [copy] Copying 1 file to
/usr/local/src/db-ojb-1.0.rc4/target/src/org/apache/ojb/tutorial5

splash:

set-archive-name:

set-archive-name-date:

detect-jdk:

check-jdk12proxy-classes:

check-jndi-classes:

use-jdk12:

use-jdk13:

use-jdk14:
 [echo] detected JDK 1.4

init:

prepare:

check-j2ee-classes:

preprocess:
 [echo] using switches: +JDK13, +JDBC30
 [java]








 [java]



...

main:
[javac] Compiling 564 source files to
/usr/local/src/db-ojb-1.0.rc4/target/classes
[javac]
/usr/local/src/db-ojb-1.0.rc4/target/src/org/apache/ojb/jdori/sql/OjbStoreMa
nager.java:76: cannot resolve symbol
[javac] symbol  : class RuntimeJDOModelFactoryImpl
[javac] location: package jdo
[javac] import
com.sun.jdori.common.model.jdo.RuntimeJDOModelFactoryImpl;
[javac]   ^
[javac]
/usr/local/src/db-ojb-1.0.rc4/target/src/org/apache/ojb/jdori/sql/OjbStoreMa
nager.java:80: cannot resolve symbol
[javac] symbol  : class JDOModelException
[javac] location: package jdo
[javac] import com.sun.jdori.model.jdo.JDOModelException;
[javac]^
[javac]
/usr/local/src/db-ojb-1.0.rc4/target/src/org/apache/ojb/jdori/sql/OjbFieldMa
nager.java:64: cannot resolve symbol
[javac] symbol  : class RuntimeJDOModelFactoryImpl
[javac] location: package jdo
[javac] import
com.sun.jdori.common.model.jdo.RuntimeJDOModelFactoryImpl;
[javac]   ^
[javac]
/usr/local/src/db-ojb-1.0.rc4/target/src/org/apache/ojb/jdori/sql/OjbFieldMa
nager.java:68: cannot resolve symbol
[javac] symbol  : class JDOModelException
[javac] location: package jdo
[javac] import com.sun.jdori.model.jdo.JDOModelException;
[javac]^
[javac]
/usr/local/src/db-ojb-1.0.rc4/target/src/org/apache/ojb/jdori/sql/OjbStoreMa
nager.java:252: cannot
resolve symbol
[javac] symbol  : variable RuntimeJDOModelFactoryImpl
[javac] location: class org.apache.ojb.jdori.sql.OjbStoreManager
[javac] JDOModel m =
RuntimeJDOModelFactoryImpl.getInstance().getJDOModel(cl);
[javac]  ^
[javac]
/usr/local/src/db-ojb-1.0.rc4/target/src/org/apache/ojb/jdori/sql/OjbStoreMa
nager.java:255: cannot
resolve symbol
[javac] symbol  : class JDOModelException
[javac] location: class org.apache.ojb.jdori.sql.OjbStoreManager
[javac] catch (JDOModelException ex)
[javac]^
[javac]
/usr/local/src/db-ojb-1.0.rc4/target/src/org/apache/ojb/jdori/sql/OjbFieldMa
nager.java:289: cannot
resolve symbol
[javac] symbol  : variable RuntimeJDOModelFactoryImpl
[javac] location: class org.apache.ojb.jdori.sql.OjbFieldManager
[javac] JDOModel m =
RuntimeJDOModelFactoryImpl.getInstance().getJDOModel(cl);
[javac]  ^
[javac]
/usr/local/src/db-ojb-1.0.rc4/target/src/org/apache/ojb/jdori/sql/OjbFieldMa
nager.java:292: cannot
resolve symbol
[javac] symbol  : class JDOModelException
[javac] location: class org.apache.ojb.jdori.sql.OjbFieldManager
[javac] catch (JDOModelException ex)
[javac]^
[javac] 8 errors

BUILD FAILED
file:/usr/local/src/db-ojb-1.0.rc4/build.xml:218: Compile failed; see the