Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 17699 invoked from network); 21 Sep 2010 13:56:01 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 21 Sep 2010 13:56:01 -0000 Received: (qmail 57296 invoked by uid 500); 21 Sep 2010 13:56:01 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 56118 invoked by uid 500); 21 Sep 2010 13:55:58 -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 56093 invoked by uid 99); 21 Sep 2010 13:55:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Sep 2010 13:55:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Sep 2010 13:55:55 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o8LDtX1m015214 for ; Tue, 21 Sep 2010 13:55:33 GMT Message-ID: <32980043.316011285077333490.JavaMail.jira@thor> Date: Tue, 21 Sep 2010 09:55:33 -0400 (EDT) From: "Willis Blackburn (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Commented: (OPENJPA-1804) NPE in MappingInfo.java line 1514 In-Reply-To: <7307874.276561284839673337.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-1804?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D12= 912984#action_12912984 ]=20 Willis Blackburn commented on OPENJPA-1804: ------------------------------------------- Rick, you asked, "Perhaps we need to have a stronger warning message when t= his feature is enabled? ... or disable it all together?" I saw on the roadmap that OpenJPA 2.1 will require Java 6. I think that if= OpenJPA is not going to support Java 6, then there is no need to support w= orking with unenhanced classes. The strategy of using the attach API to in= stall the agent will work for casual users, and the others can pass the age= nt on the command line, use the J2EE container hooks, or use the build-time= enhancer. The behavior of OpenJPA when using unenhanced classes is differ= ent from its behavior when using enhanced classes (no lazy loading, changes= only detected at flush), so anything that users actually develop in that m= ode is not going to be production-ready. At some point developers will hav= e to figure out how to get the agent or the build-time enhancer working and= test their code under that configuration. Given how easy it is to use the= attach API enhancer under Java 6, there's not a strong case for having a l= ess-functional alternative. Have I added enough comments to this issue yet? I think I'm going for a pe= rsonal record. > NPE in MappingInfo.java line 1514 > --------------------------------- > > Key: OPENJPA-1804 > URL: https://issues.apache.org/jira/browse/OPENJPA-1804 > Project: OpenJPA > Issue Type: Bug > Components: Enhance, UnenhancedClasses, usability > Affects Versions: 2.0.1 > Reporter: Willis Blackburn > > I am encountering a NPE at MappingInfo.java line 1514. I'm sorry I don't= have time to prepare a test case right now. I'm not even 100% sure what i= s causing the problem, but it seems to be something like this: > I have classes Organization, Group, User, and AddressBook. > Group has a reference (many-to-one) to Organization. > I'm using field-level access and the Java 6 runtime enhancer. (NOT the b= uild-time enhancer or the agent.) > In ManagedClassSubclasser.prepareUnenhancedClasses, the code receives a l= ist of Class objects--the ones in persistence.xml. They are not in the sam= e order as they are in persistence.xml, but I don't know if that's importan= t. The first one is Group. During the processing of Group, the code invok= es ClassMapping.setTable to set the table name, which is "group_table." Th= is comes from the @Table annotation of Group. So far, so good. Then the c= ode does some additional processing on the relationship mappings of Group, = which include the reference to Organization. During the processing of that= relationship, the code calls MappingInfo.mergeJoinColumn. On line 1367, t= he method calls rel.getTable. The "rel" variable points to the ClassMappin= g for Organization. Remember that prepareUnenhancedClasses hasn't gotten t= o Organization yet--it's still working on Group--and so I assume that this = Organization mapping was created on-demand. However, rel.getTable returns = null. The Organization class has a @Table attribute, and I can see that th= e table name has been loaded in the ClassMappingInfo instance attached to t= he ClassMapping for Organization, however the table name has not yet been c= opied from ClassMappingInfo to ClassMapping. Later, the mergeJoinColumn me= thod attempts to dereference the null table name and generates the NPE. > Bottom line: When using the Java 6, runtime enhancer, if class A has a r= eference to class B, and both classes have @Table annotations (at least), a= nd class A is processed first, then it produces a NPE. --=20 This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.