MetadataAsmFactory in error: IndexOutOfBoundsException

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

MetadataAsmFactory in error: IndexOutOfBoundsException

Shikha Malhotra

I have tried the latest version of eclipselink.jar and toplink-grid.jar in my application, which is:

It gives me an exception while pre-deploying all my entities:

Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.0.0.v20090909-r5076): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [ohi-orm] failed.
Internal Exception: java.lang.IndexOutOfBoundsException: Index: 15, Size: 13
        at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(
        ... 73 more
Caused by: java.lang.IndexOutOfBoundsException: Index: 15, Size: 13
        at java.util.ArrayList.RangeCheck(
        at java.util.ArrayList.get(
        at org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAsmFactory.resolveGenericTypes(
        at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.resolveGenericTypes(
        at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.discoverMappedSuperclassesAndInheritanceParents(
        at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.preProcess(
        at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.preProcess(
        at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage1(
        at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(
        at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(
        ... 72 more

The general entity hierarchy that we have in our application is as under:
-public class <SomeEntity> extends AbstractPersistable
 -public abstract class AbstractPersistable<Name, Type> extends AbstractDynamicFields<Name, Type>       
  implements Persistable, LocaleAware
  -public abstract class AbstractDynamicFields<Name, Type>
    extends AbstractOhiNextGroovySupport<Name, Type> implements DynamicFields<Name, Type>
    -public abstract class AbstractOhiNextGroovySupport<Name, Type>
    extends GroovyObjectSupport

where GroovyObjectSupport is a Groovy internal class.
This hierarchy worked in the earlier versions.

I tries to debug the source, and it appears that the following code:
public void resolveGenericTypes(MetadataClass child, List<String> genericTypes, MetadataClass parent, MetadataDescriptor descriptor) {        
        // If we have a generic parent we need to grab our generic types
        // that may be used (and therefore need to be resolved) to map
        // accessors correctly.
        if (genericTypes != null) {
            // The generic types provided map to its parents generic types. The
            // generics also include the superclass, and interfaces. The parent
            // generics include the type and ":" and class.
            List<String> parentGenericTypes = parent.getGenericType();
            if (parentGenericTypes != null) {
                List genericParentTemp = new ArrayList(genericTypes);
                int size = genericParentTemp.size();
                int parentIndex = 0;
                for (int index = genericTypes.indexOf(parent.getName()) + 1; index < size; index++) {
                    String actualTypeArgument = genericTypes.get(index);
                    String variable = parentGenericTypes.get(parentIndex);
                    parentIndex = parentIndex + 3;......

is in error, as size is size of temp arrayList whereas in the loop, we are looping on genericTYpes and parentGenericTypes. So the for loop should check for their size instead.