Hi,

Just to provide more information on my problem. I tried a simpler XML data
file structure, in which there is no nested complex type. Now I can pass
through the "db = jdo.getDatabase();" line.

The simpler XML data structure is as follows (in xsd):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified"
  xmlns:xs="http://www.w3.org/2001/XMLSchema";>

<!-- simple types -->

<xs:simpleType name="NameType">
  <xs:restriction base="xs:string"/>
</xs:simpleType>

<xs:simpleType name="Acct_IDType">
  <xs:restriction base="xs:positiveInteger">
    <xs:totalDigits value="2"/>
  </xs:restriction>
</xs:simpleType>

<xs:simpleType name="DeskCodeType">
  <xs:restriction base="xs:positiveInteger">
    <xs:totalDigits value="3"/>
  </xs:restriction>
</xs:simpleType>

<!-- complex types -->

<xs:complexType name="DeskType">
  <xs:sequence>
    <xs:element minOccurs="1" maxOccurs="1" name="DeskCode"
      type="DeskCodeType"/>
    <xs:element minOccurs="1" maxOccurs="1" name="Name"
      type="NameType"/>
    <xs:element minOccurs="1" maxOccurs="1" name="Acct_ID"
      type="Acct_IDType"/>
  </xs:sequence>
</xs:complexType>

<!-- initiation -->
<xs:element name="Desk" type="DeskType"/>

</xs:schema>

Notice that the Acct_ID simple type replaces the Acct complex type at
DeskType.

I recall that Source Generator is not fully compactable with Castor JDO. It
seems that the problem boils down back to how to pass Arrays into JDO
again... But how come the NullPointerException if the Mapping is the one
having the problem?

If passing Arrays is the problem, I have searched it in your mailing list
archive, and implemented the solution by Keith
(http://www.mail-archive.com/[email protected]/msg03638.html) But it
doesn't seem to work that smoothly, as my error suggests... Any alternative
solutions?

--Johnny



-----Original Message-----
From: Fong, Kakeungjohnny 
Sent: Thursday, October 03, 2002 5:50 PM
To: [EMAIL PROTECTED]
Subject: [castor-dev] RE: jdo setConfiguration problem with sybase


Hi,

Thank you for the prompt reply. I've tried ur method, but the problem
doesn't go away.

java.lang.NullPointerException
        at org.exolab.castor.jdo.engine.JDOClassDescriptor.<init>(Unknown
Source)
        at
org.exolab.castor.jdo.engine.JDOMappingLoader.createDescriptor(Unknown
Source)
        at
org.exolab.castor.mapping.loader.MappingLoader.loadMapping(Unknown Source)
        at org.exolab.castor.jdo.engine.JDOMappingLoader.loadMapping(Unknown
Source)
        at org.exolab.castor.mapping.Mapping.getResolver(Unknown Source)

      at org.exolab.castor.jdo.engine.DatabaseRegistry.loadDatabase(Unknown
Source)
        at org.exolab.castor.jdo.JDO.getDatabase(Unknown Source)
      ...

The problem line of code becomes "db = jdo.getDatabase();"

I am using JBuilder7, and my file structure looks something like this:

/classes
  /com
    <copy of files at /xml>
    accounts.xml   <sample data>
    acctConfig.xml <Config file>
    acctMap.xml    <mapping file>
    /data
      <where the generated classes from Source Generator are stored>
      Acct.class
      AcctDescriptor.class
      AcctType.class
      AcctTypeDescriptor.class
      Desk.class
      DeskDescriptor.class
      DeskType.class
      DeskTypeDescriptor.class
    /sqlTest
      <where the testing program's classes are stored>
      AcctProcessor.class
      testAcct.class
/src
  /com
    /data
      <where the generated java files from Source Generator are stored>
      Acct.java
      AcctDescriptor.java
      AcctType.java
      AcctTypeDescriptor.java
      Desk.java
      DeskDescriptor.java
      DeskType.java
      DeskTypeDescriptor.java
    /sqlTest
      <where the testing program's java files are stored>
      AcctProcessor.class
      testAcct.class
/xml
  <where the xml files are stored>
  accounts.xml   <sample data>
  acctConfig.xml <Config file>
  acctMap.xml    <mapping file>

Are there any other problems in my files that might cause the Null Pointer
Exception?

--Johnny


-----Original Message-----
From: Bruce Snyder [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 03, 2002 3:44 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] jdo setConfiguration problem with sybase


This one time, at band camp, Fong, Kakeungjohnny said:

FK>I have been trying to use Castor with Sybase, and here is the java code
for
FK>connecting the database:
FK>
FK>      // Define the JDO object
FK>      jdo = new JDO();
FK>      jdo.setClassLoader( getClass().getClassLoader() );
FK>      jdo.setConfiguration("acctConfig.xml");

Johnny,

Where does acctConfig.xml reside on the file system? Based on the above
code, unless it's in the directory from which the Java application is
launched, Castor will not find it.

A better strategy for locating it is to make use of: 

    getClass().getResource() - this will require that acctConfig.xml reside
    where the calling .class resides

    getClass().getClassLoader().getSystemResource() - this will locate
    acctConfig.xml on the CLASSPATH

Bruce
-- 
perl -e 'print
unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to