From dev-return-7712-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Thu Apr 03 05:24:34 2008 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 6819 invoked from network); 3 Apr 2008 05:24:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Apr 2008 05:24:34 -0000 Received: (qmail 66833 invoked by uid 500); 3 Apr 2008 05:24:33 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 66817 invoked by uid 500); 3 Apr 2008 05:24:33 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 66808 invoked by uid 99); 3 Apr 2008 05:24:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Apr 2008 22:24:33 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of catalina.wei@gmail.com designates 209.85.200.174 as permitted sender) Received: from [209.85.200.174] (HELO wf-out-1314.google.com) (209.85.200.174) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Apr 2008 05:23:52 +0000 Received: by wf-out-1314.google.com with SMTP id 29so2962406wff.24 for ; Wed, 02 Apr 2008 22:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=S9RVya1JyPUNTlOxLrU3qS1M9cSeNuJoyDyWYlV7NpQ=; b=dEgB2taBuC7N4wPkPeWR7Oijp0GTKwOdZysNJLlWx+oSMbgYGKhUKtVFH48i8hJrw3Kj5Nu+YKEQ2KSMXrTbPMDnPoq8GoJ6pBy/2MqXa2Z2Pp5kC+qfGn01L1no379cPuyPH7r+nSl+kl2cWLa/xIfGWCvgvTlFzG9qda2uSe4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=T0zT0dOJTfv9Ip4bbrgvoJhGYayKho8ya/9sIU+o6sWlgKSW7FJ1a/wcxqdKlLADoEQ4c1UcXj5qlfr7fd8rPXbwO9lw0hnpYRR3UncVVOcc0f3Z12MgvCqB37cxPz9fnjA+RoVjjOy/AwMOq5d9MyPsSstaLzar/Vys7Ke3Lxo= Received: by 10.142.171.6 with SMTP id t6mr4481179wfe.12.1207200244237; Wed, 02 Apr 2008 22:24:04 -0700 (PDT) Received: by 10.142.211.16 with HTTP; Wed, 2 Apr 2008 22:24:03 -0700 (PDT) Message-ID: Date: Wed, 2 Apr 2008 22:24:03 -0700 From: "catalina wei" To: dev@openjpa.apache.org Subject: Re: about the initialization of DB2Dictionary In-Reply-To: <5e0fd2eb0804021748q7a3e9fe2v93fab86649925e74@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1198_14975832.1207200244231" References: <5e0fd2eb0804021748q7a3e9fe2v93fab86649925e74@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_1198_14975832.1207200244231 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline HI Amy, Several methods in DB2Dictionary precondition is that connectedConfiguration() is called so that databaseProductName and databaseProductVersion are initialized. A quick fix for you is to modify isDB2... method to check for not nulls, for example: public boolean isDB2UDBV82OrLater() { boolean match = false; if (databaseProductName != null && (databaseProductVersion.indexOf("SQL") != -1 || databaseProductName.indexOf("DB2/") != -1) && ((maj == 8 && min >= 2) || (maj >= 9))) match = true; return match; } public boolean isDB2ZOSV8xOrLater() { boolean match = false; if (databaseProductName != null && (databaseProductVersion.indexOf("DSN") != -1 || databaseProductName.indexOf("DB2/") == -1) && maj >= 8) match = true; return match; } public boolean isDB2ISeriesV5R3OrEarlier() { boolean match = false; if (databaseProductName != null && databaseProductName.indexOf("AS") != -1 && ((maj == 5 && min <=3) || maj < 5)) match = true; return match; } public boolean isDB2ISeriesV5R4OrLater() { boolean match = false; if (databaseProductName != null && databaseProductName.indexOf("AS") != -1 && (maj >=6 || (maj == 5 && min >=4))) match = true; return match; } public boolean isDB2UDBV81OrEarlier() { boolean match = false; if (databaseProductName != null && (databaseProductVersion.indexOf("SQL") != -1 || databaseProductName.indexOf("DB2/") != -1) && ((maj == 8 && min <= 1) || maj < 8)) match = true; return match; } This should resolve that NullPointerExceiption, but requires user to manually create index if needed. If this fix works for you, I can commit the changes. Catalina On 4/2/08, milotty wrote: > > Hi, > Now I'm encountered a problem of NullPointerException like this: > java.lang.NullPointerException > at > org.apache.openjpa.jdbc.sql.DB2Dictionary.isDB2ZOSV8xOrLater( > DB2Dictionary.java:392) > > at > org.apache.openjpa.jdbc.sql.DB2Dictionary.createIndexIfNecessary( > DB2Dictionary.java:784) > > at > org.apache.openjpa.jdbc.kernel.TableJDBCSeq.addSchema(TableJDBCSeq.java > :244) > > at > org.apache.openjpa.jdbc.meta.MappingTool.addSequenceComponents( > MappingTool.java:609) > > at > org.apache.openjpa.jdbc.meta.MappingTool.addSequenceComponents( > MappingTool.java:591) > > at > org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:477) > at org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java > :1075) > at > org.apache.openjpa.jdbc.ant.MappingToolTask.executeOn(MappingToolTask.java > :197) > > at > org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask.java:172) > at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java > :275) > > at org.apache.tools.ant.Task.perform(Task.java:364) > at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java > :64) > > at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java > :275) > > at org.apache.tools.ant.Task.perform(Task.java:364) > > The scenario is I'm only using the ant task of MappingTool to build schema > for some JDO classes. > I looked into the source code a little. The problem is when > org.apache.openjpa.jdbc.kernel.TableJDBCSeq.addSchema() invokes > org.apache.openjpa.jdbc.sql.DB2Dictionary.createIndexIfNecessary() to > create > the index for the sequence table, the databaseProductVersion and/or > databaseProductName of DB2Dictionary are needed. But these 2 variables > will > not be initialized until DB2Dictionary.connectedConfiguration() is > invoked, > and it need a connection to the database. But in addSchema(), there isn't > any connection yet. > MappingTool doesn't always require a connection. So it should be wrong if > simply adding a connection before addSchema() invoked. > > Could anyone give me any suggestion of this problem? How to resolve this > problem in OpenJPA scope? Or, is there any method from DB2 side can be > used > to get databaseProductVersion and/or databaseProductName without a > connection to database? > > > > Thanks, > Amy > ------=_Part_1198_14975832.1207200244231--