Bugzilla Version 2.16.7
Bugzilla Bug 1781
  JDO2.loadConfiguration(JdoConf) - use JDoConfFactory with JDO2
     Query page      Enter new bug
Bug#: 1781   Platform:   Reporter: martin-fuchs at gmx dot net (Martin Fuchs)
Product:   OS:   Add CC:
Component:   Version:   CC:
Remove selected CCs
Status: NEW   Priority:  
Resolution:   Severity:  
Assigned To: werner dot guttmann at gmx dot net (Werner Guttmann)   Target Milestone:  

Attachment Type Modified Status Actions
proposed patch (in working state) patch 2004-11-03 15:06 none Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 1781 depends on: 1860 Show dependency tree
Show dependency graph
Bug 1781 blocks: 1915
Votes: 0    Show votes for this bug    Vote for this bug

Additional Comments:

Leave as NEW 
Accept bug (change status to ASSIGNED)
Resolve bug, changing resolution to
Resolve bug, mark it as duplicate of bug #
Reassign bug to
Reassign bug to owner of selected component

View Bug Activity   |   Format For Printing

Description: Opened: 2004-11-03 15:03

Moving the enhancement to use JdoConfFactory with JDO2 from bug 1511 to this new


Martin, it looks like JDO is working again, but JDO2 still lacks a
loadConfiguration(JdoConf) method. Whilst this is not high priority, I think we
should try to make it for the 0.9.6 release.

And maybe we should try to pick up on this old idea below as well.

> When setting a URI for a JDO configuration file, try to unmarshall
> the configuration file immediately, and store the result in one and
> one instance variable only: _jdoConf (of type JdoConf).


The proposed patch includes the requested method JDO2.loadConfiguration(JdoConf)
as well as a revised version of the old JDO class to load the JDO configuration
file immediately when calling JDO.setConfiguration().

Creating an JDO2 instance using JdoConfFactory is achieved by calling a new
JDO2.createInstance() overload with both parameters "JdoConf jdoConf" and
"String databaseName" at one time, not by using two distinct calls, because we
need both informations at the same time.

Here is a small usage example:

   org.exolab.castor.jdo.conf.Database jdoDbConf;

   String db_url = "jdbc:mysql://localhost:3306/test";
   String username = "test";
   String password = "";

   URL map_url = DeptEmp.class.getResource("mapping.xml");

    // Set up JDO with the configuration the specified database driver and
connection information
   jdoDbConf = JdoConfFactory.createJdoDbConf("db", "mysql",
        db_url, username, password));

    // Store mapping file location in the configuration

    // Activate the JDO configuration
   JDO2 jdo = JDO2.createInstance(JdoConfFactory.createJdoConf(jdoDbConf), "db");

The documentation update contains the JDO2 example from above. It also fixes a
few small mistakes of the old JDO examples, and indents them to make it a bit
easier to read.

The changes already work for my test applications, both using XML configuration
files and JDOConfFactory.
However the JTF tests don't yet run - they print the following exception

Caused by: unable to add attribute "configuration"
to 'org.exolab.castor.jdo.JDO' due to the following error: org.exolab
.castor.mapping.MappingRuntimeException: Nested error:
org.exolab.castor.mapping.MappingException: Nested error: Parsing
 Error : File "file:///D:/java/castor-1511/sybase.xml" not found.
Line : 0
Column : 0
{file: [not available]; line: 11; column: 62}
        at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:622)
        at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:516)
        at Main.run(Main.java:146)
        at Main.main(Main.java:226)
Caused by: org.xml.sax.SAXException: unable to add attribute "configuration"
to 'org.exolab.castor.jdo.JDO' due to the f
ollowing error: org.exolab.castor.mapping.MappingRuntimeException: Nested
error: org.exolab.castor.mapping.MappingExcept
ion: Nested error: Parsing Error : File "file:///D:/java/castor-
1511/sybase.xml" not found.
Line : 0
Column : 0

It seems the BASE URI used to load the config file is the current directory
instead of the class directory.
May be some one else can have a look at this?


if you look into the patch you will see it also addresses some other small
issues I found on the way:

- JDO2_jdoConfURI was incorrectly used as string in
JDO2.getReference/getObjectInstance(). I removed it completely.
- Some JDO2 comments contained "JDOold", I think this was a thing left over from
creating JDO2.
- some more comment and white space changes

I asked myself if it would not be better to remove the static variable
JDOConfLoader._jdoConf completely. Providing the method unmarshalConfiguration()
to unmarshal the JDO configuration from an input source and returning the 
configuration object immediately should be enough. Anything other, like the
database or transaction configuration can be queried directly from this returned

------- Additional Comment #1 From Martin Fuchs 2004-11-03 15:06 -------
Created an attachment (id=760)
proposed patch (in working state)

------- Additional Comment #2 From ralf joachim 2005-03-07 15:48 -------
Gregory, how should your code look like if you want to pass a ready configured
driver or datasource into castor as discussed on IRC.

------- Additional Comment #3 From Werner Guttmann 2005-04-01 02:51 -------
Gregory ?

     Query page      Enter new bug
This is Bugzilla: the Mozilla bug system. For more information about what Bugzilla is and what it can do, see bugzilla.org.
Actions: New | Query | bug # | Reports   New Account | Log In