Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 55705 invoked from network); 23 Aug 2007 01:42:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Aug 2007 01:42:21 -0000 Received: (qmail 79781 invoked by uid 500); 23 Aug 2007 01:42:17 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 79756 invoked by uid 500); 23 Aug 2007 01:42:17 -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 79747 invoked by uid 99); 23 Aug 2007 01:42:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Aug 2007 18:42:17 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [192.18.43.132] (HELO sca-es-mail-1.sun.com) (192.18.43.132) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Aug 2007 01:42:52 +0000 Received: from fe-sfbay-09.sun.com ([192.18.43.129]) by sca-es-mail-1.sun.com (8.13.7+Sun/8.12.9) with ESMTP id l7N1fpMq000168 for ; Wed, 22 Aug 2007 18:41:51 -0700 (PDT) Received: from conversion-daemon.fe-sfbay-09.sun.com by fe-sfbay-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0JN700K01E0ZF900@fe-sfbay-09.sun.com> (original mail from Marina.Vatkina@Sun.COM) for dev@openjpa.apache.org; Wed, 22 Aug 2007 18:41:51 -0700 (PDT) Received: from [129.145.132.161] by fe-sfbay-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0JN700B96E1EVAD0@fe-sfbay-09.sun.com> for dev@openjpa.apache.org; Wed, 22 Aug 2007 18:41:51 -0700 (PDT) Date: Wed, 22 Aug 2007 18:38:48 -0700 From: Marina Vatkina Subject: Re: [jira] Commented: (OPENJPA-328) PCEnhancer does not enhance classes specified in the mapping files declared in the persistence xml In-reply-to: <33199558.1187829391420.JavaMail.jira@brutus> Sender: Marina.Vatkina@Sun.COM To: dev@openjpa.apache.org Reply-to: Marina.Vatkina@Sun.COM Message-id: <46CCE528.6010902@Sun.COM> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=us-ascii Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en References: <33199558.1187829391420.JavaMail.jira@brutus> User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.7) Gecko/20051027 X-Virus-Checked: Checked by ClamAV on apache.org Pinaki, The location according to the spec (see 6.2.1.6 mapping-file, jar-file, class, exclude-unlisted-classes) is "present anywhere on the class path. Regards, -marina Pinaki Poddar (JIRA) wrote: > [ https://issues.apache.org/jira/browse/OPENJPA-328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12521983 ] > > Pinaki Poddar commented on OPENJPA-328: > --------------------------------------- > > content of in persistence.xml is resolved relative to location of persistence.xml itself. So, for exaple, if persistence.xml and orm.xml reside in the same directory, then persistence.xml should need to specify > orm.xml > > Or nothing because, by default, OpenJPA will look for a orm.xml file. > > The attached content shows that ptp/test/issue5/orm.xml. That is why OpenJPA is not finding the metadata/mapping info for Entity class. > > > > > >>PCEnhancer does not enhance classes specified in the mapping files declared in the persistence xml >>-------------------------------------------------------------------------------------------------- >> >> Key: OPENJPA-328 >> URL: https://issues.apache.org/jira/browse/OPENJPA-328 >> Project: OpenJPA >> Issue Type: Bug >> Components: build / infrastructure >> Affects Versions: 1.0.0 >> Reporter: Henry Lai >> Attachments: ptpissue5.zip >> >> >>running >>org.apache.openjpa.enhance.PCEnhancer -p ptp/test/issue5/persistence.xml >>did not do the class file enhancement, result in The class does not have metadata - enhanced as persistence-aware. >>The message are >>250 test TRACE [main] openjpa.MetaData - Finished parsing metadata resource "file:/C:/workspace/jpatest/TestOpenJPA/bin/ptp/test/issue5/orm.xml". >>250 test TRACE [main] openjpa.MetaData - Parsing class "ptp.test.issue5.T5Entity". >>250 test TRACE [main] openjpa.Enhance - Enhancing type "class ptp.test.issue5.T5Entity". >>250 test WARN [main] openjpa.Enhance - Type "class ptp.test.issue5.T5Entity" has no metadata; enhancing as persistence aware. If you intended for "class ptp.test.issue5.T5Entity" to be persistence-capable, then this means that OpenJPA could not find any metadata for "class ptp.test.issue5.T5Entity". This can happen if the directory containing your metadata is not in your CLASSPATH, or if your metadata files are not named properly. See the documentation on metadata placement for more information. >>250 test TRACE [main] openjpa.Tool - The class does not have metadata - enhanced as persistence-aware. >>modify the following method of the PCEnhancer to get it to work >> /** >> * Enhance the given classes. >> */ >> public static boolean run(OpenJPAConfiguration conf, String[] args, >> Flags flags, MetaDataRepository repos, BytecodeWriter writer, >> ClassLoader loader) >> throws IOException { >> if (loader == null) >> loader = conf.getClassResolverInstance(). >> getClassLoader(PCEnhancer.class, null); >> if (flags.tmpClassLoader) >> loader = new TemporaryClassLoader(loader); >> if (repos == null) { >> repos = conf.newMetaDataRepositoryInstance(); >> repos.setSourceMode(MetaDataRepository.MODE_META); >> } >> Log log = conf.getLog(OpenJPAConfiguration.LOG_TOOL); >> Collection classes; >> String [] persistentTypeNames = args; >> if (args.length == 0) { >> log.info(_loc.get("running-all-classes")); >> classes = repos.getPersistentTypeNames(true, loader); >> if (classes == null) { >> log.warn(_loc.get("no-class-to-enhance")); >> return false; >> } >> persistentTypeNames = new String [ classes.size() ]; >> classes.toArray( persistentTypeNames ); >> } >> ClassArgParser cap = conf.getMetaDataRepositoryInstance(). >> getMetaDataFactory().newClassArgParser(); >> cap.setClassLoader(loader); >> classes = new HashSet(); >> for (int i = 0; i < persistentTypeNames.length; i++) >> classes.addAll(Arrays.asList(cap.parseTypes(persistentTypeNames[i]))); >> >> >> Project project = new Project(); >> BCClass bc; >> PCEnhancer enhancer; >> int status; >> for (Iterator itr = classes.iterator(); itr.hasNext();) { >> Object o = itr.next(); >> if (log.isTraceEnabled()) >> log.trace(_loc.get("enhance-running", o)); >> if (o instanceof String) >> bc = project.loadClass((String) o); >> else >> bc = project.loadClass((Class) o); >> enhancer = new PCEnhancer(conf, bc, repos, loader); >> if (writer != null) >> enhancer.setBytecodeWriter(writer); >> enhancer.setDirectory(flags.directory); >> enhancer.setAddDefaultConstructor(flags.addDefaultConstructor); >> status = enhancer.run(); >> if (status == ENHANCE_NONE) { >> if (log.isTraceEnabled()) >> log.trace(_loc.get("enhance-norun")); >> } else if (status == ENHANCE_INTERFACE) { >> if (log.isTraceEnabled()) >> log.trace(_loc.get("enhance-interface")); >> } else if (status == ENHANCE_AWARE) { >> if (log.isTraceEnabled()) >> log.trace(_loc.get("enhance-aware")); >> enhancer.record(); >> } else >> enhancer.record(); >> project.clear(); >> } >> return true; >> } > >