openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Albert Lee (JIRA)" <>
Subject [jira] Created: (OPENJPA-402) Unable to detect an valid Entity's meta data when the entity's .class file size is large.
Date Sat, 13 Oct 2007 03:17:51 GMT
Unable to detect an valid Entity's meta data when the entity's .class file size is large.

                 Key: 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
The class does not appear in the list of persistent types:

	at org.apache.openjpa.meta.MetaDataRepository.getMetaData(
	at org.apache.openjpa.kernel.BrokerImpl.persist(
	at org.apache.openjpa.kernel.BrokerImpl.persist(
	at org.apache.openjpa.kernel.DelegatingBroker.persist(
	at org.apache.openjpa.persistence.EntityManagerImpl.persist(
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 = != -1; bout.write(buf, 0, r)) ;
            content = bout.toByteArray();
        } else {
            content = new byte[(int) size];
  ;     <<<<<<<  cause of the problem here.
        return content;

What happened is if the entity class file is big enough, the 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

  ;     <<<<<<<  cause of the problem here.
            int offset = 0;
            int read;
            while (offset < size
                && (read =, 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.

View raw message