Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 90785 invoked from network); 13 Oct 2007 03:18:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Oct 2007 03:18:42 -0000 Received: (qmail 35881 invoked by uid 500); 13 Oct 2007 03:18:30 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 35853 invoked by uid 500); 13 Oct 2007 03:18:30 -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 35844 invoked by uid 99); 13 Oct 2007 03:18:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Oct 2007 20:18:29 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 13 Oct 2007 03:18:41 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 615017141F1 for ; Fri, 12 Oct 2007 20:17:51 -0700 (PDT) Message-ID: <20757679.1192245471345.JavaMail.jira@brutus> Date: Fri, 12 Oct 2007 20:17:51 -0700 (PDT) From: "Albert Lee (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Created: (OPENJPA-402) Unable to detect an valid Entity's meta data when the entity's .class file size is large. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Unable to detect an valid Entity's meta data when the entity's .class file size is large. ----------------------------------------------------------------------------------------- Key: OPENJPA-402 URL: https://issues.apache.org/jira/browse/OPENJPA-402 Project: OpenJPA Issue Type: Bug Components: lib Affects Versions: 1.0.1, 1.1.0 Reporter: Albert Lee Fix For: 1.0.1, 1.1.0 We ran into a scenario in which an application has all the correct configuration in the persistence.xml and orm.xml but the provider is still unabled to recognize an entity and establish its meta data. As a result, the following exception is thrown from openjpa. org.apache.openjpa.persistence.ArgumentException:No metadata was found for type "class suite.r70.base.jpaspec.relationships.manyXmany.entities.containertype.annotated.MMContainerTypeEntityA". The class does not appear in the list of persistent types: [suite.r70.base.jpaspec.relationships.manyXmany.entities.uni.annotation.MMUniEntA, suite.r70.base.jpaspec.relationships.manyXmany.entities.bi.xml.XMLMMBiEntB_CA, .......... suite.r70.base.jpaspec.relationships.manyXmany.entities.bi.xml.XMLMMBiEntB_CRM] at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:299) at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2371) at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2224) at org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1005) at org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:541) There are many entities defined in this application. A point of interest is there are 2 entities in the same package, in the same persistence archive but only one of these entity's meta data is found. ------------------------------------------ The cause of the problem is in ZipFileMetaDataIterator.getContent() method. public byte[] getContent() throws IOException { long size = _entry.getSize(); if (size == 0) return new byte[0]; InputStream in = _file.getInputStream(_entry); byte[] content; if (size < 0) { ByteArrayOutputStream bout = new ByteArrayOutputStream(); byte[] buf = new byte[1024]; for (int r; (r = in.read(buf)) != -1; bout.write(buf, 0, r)) ; content = bout.toByteArray(); } else { content = new byte[(int) size]; in.read(content); <<<<<<< cause of the problem here. } in.close(); return content; } What happened is if the entity class file is big enough, the in.read() only returns partial content of the .class file. Therefore during the ClassAnnotationMetaDataFilter.match() processing the annotation attribute count in the .class file is read to be zero and the entity is not detected as an Entity. The solution is to replace in.read(content); <<<<<<< cause of the problem here. by int offset = 0; int read; while (offset < size && (read = in.read(content, offset, (int) size - offset)) != -1) { offset += read; } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.