1. OpenJPA
  2. OPENJPA-402

Unable to detect an valid Entity's meta data when the entity's .class file size is large.


    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.1, 1.1.0
    • Fix Version/s: 1.0.1, 1.1.0
    • Component/s: lib
    • Labels:


      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:

      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(); }


      { 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; }


        Albert Lee created issue -
        Albert Lee made changes -
        Field Original Value New Value
        Attachment OPENJPA-402.patch [ 12367676 ]
        Albert Lee made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Albert Lee made changes -
        Assignee Albert Lee [ allee8285 ]
        Albert Lee made changes -
        Status Resolved [ 5 ] Closed [ 6 ]


          • Assignee:
            Albert Lee
            Albert Lee
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: