RE: Cayenne Newbe Question

From: JR Ruggentaler (j..pv.com)
Date: Mon Aug 05 2002 - 00:21:38 EDT

  • Next message: Andrus: "RE: Cayenne Newbe Question"

    Andrus,
            thanks! the initialization problem seem to have been due to the JAXP
    Version 1.0.1 library I had in my jre/lib/ext directory. I removed JAXP
    1.0.1 but now I seem to have a problem with generating PKs. My test tries to
    create a Claim object but Cayenne throws an exception in
    ctxt.commitChanges(java.util.logging.Level.SEVERE);.

    Aug 4, 2002 11:00:47 PM
    org.objectstyle.cayenne.conf.DomainHelper$NodeHandler init SEVERE: loading
    <node name='SWSignatureDataNode' datasource='SWSignatureDataNode'
    factory='org.objectstyle.cayenne.conf.DriverDataSourceFactory'>. Aug 4, 2002
    11:00:47 PM org.objectstyle.cayenne.conf.DomainHelper$NodeHandler init
    SEVERE: node DbAdapter: org.objectstyle.cayenne.dba.mysql.MySQLAdapter
    Aug 4, 2002 11:00:47 PM org.objectstyle.cayenne.conf.DriverDataSourceFactory
    load SEVERE: loading driver information from (SWSignatureDataNode).
    Aug 4, 2002 11:00:47 PM org.objectstyle.cayenne.util.ResourceLocator
    findResourceStream SEVERE: Resource URL:
    file:/C:/Kawa4.01/Projects/CayenneTst/resource/SWSignatureDataNode
    Aug 4, 2002 11:00:47 PM org.objectstyle.cayenne.conf.DriverDataSourceFactory
    load SEVERE: location found in filesystem.
    Aug 4, 2002 11:00:47 PM
    org.objectstyle.cayenne.conf.DriverDataSourceFactory$DriverHandler init
    SEVERE: loading driver org.gjt.mm.mysql.Driver
    Aug 4, 2002 11:00:47 PM
    org.objectstyle.cayenne.conf.DomainHelper$NodeHandler init SEVERE: loaded
    datasource. org.objectstyle.cayenne.CayenneRuntimeException: Error
    generating PK
    at
    org.objectstyle.cayenne.access.DataContext.createPermId(DataContext.java:857
    )
    at
    org.objectstyle.cayenne.access.DataContext.createPermIds(DataContext.java:79
    2)
    at
    org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:54
    2)
    at CayenneTst.<init>(CayenneTst.java:17)
    at CayenneTst.main(CayenneTst.java:23) Caused by:
    java.lang.NullPointerException
    at
    org.objectstyle.cayenne.access.DataContext.createPermId(DataContext.java:851
    )
    ... 4 more

    Here is some DB info;

    mysql> show tables;
    +---------------------+
    | Tables_in_SWStaging |
    +---------------------+
    | auto_pk_support |
    | claim |
    | line_item |
    +---------------------+
    3 rows in set (0.03 sec)

    mysql> select * from auto_pk_support;
    +------------+---------+
    | TABLE_NAME | NEXT_ID |
    +------------+---------+
    | CLAIM | 200 |
    | LINE_ITEM | 200 |
    +------------+---------+
    2 rows in set (0.12 sec)

    mysql> describe claim;
    +-------------+---------------+------+-----+---------+-------+
    | Field | Type | Null | Key | Default | Extra |
    +-------------+---------------+------+-----+---------+-------+
    | CLAIM_ID | int(11) | | PRI | 0 | |
    | INVOICE | decimal(12,0) | YES | | NULL | |
    | SYS | char(2) | YES | | NULL | |
    | PROVIDER_ID | int(11) | YES | | NULL | |
    | DOS | date | YES | | NULL | |
    | PATIENT_ID | int(11) | YES | | NULL | |
    | DIAGNOSIS4 | varchar(8) | YES | | NULL | |
    | DIAGNOSIS3 | varchar(8) | YES | | NULL | |
    | DIAGNOSIS2 | varchar(8) | YES | | NULL | |
    | DIAGNOSIS1 | varchar(8) | YES | | NULL | |
    +-------------+---------------+------+-----+---------+-------+
    10 rows in set (0.40 sec)

    Any ideas what's wrong here? I am using the nightly build suggested by
    Andrus in this email thread.
    This looks like the code in question.

    DataContext.java
                            try {
                                    PkGenerator gen =
    aNode.getAdapter().getPkGenerator();
                                    Object pk =
                                            gen.generatePkForDbEntity(aNode,
    objEntity.getDbEntity());
                                    autoPkDone = true;
                                    idMap.put(attr.getName(), pk);
                            } catch (Exception ex) {
                                    throw new CayenneRuntimeException("Error
    generating PK", ex);
                            }

    J.R.

    -----Original Message-----
    From: Andrus [mailto:andru..bjectstyle.org]
    Sent: Saturday, August 03, 2002 11:17 AM
    To: JR Ruggentaler
    Cc: cayenne-use..bjectstyle.org
    Subject: RE: Cayenne Newbe Question

    >If both answers are "yes", then a probable cause of the crash is the old
    >version of cayenne.xml hanging somewhere in CLASSPATH. Cayenne may be
    >using that older version. Please look for it in your classpath locations,
    >as well as any JAR files you may have built before.

    I figured that this may be a common problem, so I added some code to help
    in diagnostics. This will tell you which cayenne.xml is used:

    1. Get the latest Cayenne nightly build :
    http://objectstyle.org/downloads/cayenne/nightly/2002-8-3/
    2. Unpack it somewhere and change your CAYENNE_HOME to point to it.
    3. In your CayenneTst add this line of code:

    org.objectstyle.cayenne.conf.Configuration.setLogLevel(java.util.logging.Lev
    el.SEVERE);

    4. Run your application.
    5. Check the output on console. It should look something like that (second
    line tells which file was used):

    Aug 3, 2002 12:15:25 PM org.objectstyle.cayenne.util.ResourceLocator
    findResourceStream
    SEVERE: Resource URL: file:/F:/TMP/JR/cayenne.xml
    Aug 3, 2002 12:15:25 PM org.objectstyle.cayenne.conf.DomainHelper
    loadDomains
    SEVERE: start configuration loading.
    Aug 3, 2002 12:15:25 PM
    org.objectstyle.cayenne.conf.DomainHelper$DomainHandler init
    SEVERE: error: unnamed <domain>.
    Aug 3, 2002 12:15:25 PM org.objectstyle.cayenne.conf.Configuration
    initSharedConfig
    SEVERE: Error initializing shared Configuration
    org.xml.sax.SAXParseException: Domain 'name' attribute must be not null.
             at
    org.objectstyle.cayenne.conf.DomainHelper$DomainHandler.init(DomainHelper.ja
    va:
    445)
             at
    org.objectstyle.cayenne.conf.DomainHelper$DomainsHandler.startElement(Domain
    Hel

    Hope this helps.

    Andrus



    This archive was generated by hypermail 2.0.0 : Mon Aug 05 2002 - 00:21:23 EDT