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
Hi,

I have tried the latest version of eclipselink.jar and toplink-grid.jar in my application, which is: TOPLINK_11.1.1.2.0_GENERIC_090915.1800_toplink_111120.zip

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(EntityManagerSetupException.java:210)
        ... 73 more
Caused by: java.lang.IndexOutOfBoundsException: Index: 15, Size: 13
        at java.util.ArrayList.RangeCheck(ArrayList.java:547)
        at java.util.ArrayList.get(ArrayList.java:322)
        at org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAsmFactory.resolveGenericTypes(MetadataAsmFactory.java:121)
        at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.resolveGenericTypes(EntityAccessor.java:1328)
        at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.discoverMappedSuperclassesAndInheritanceParents(EntityAccessor.java:312)
        at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.preProcess(EntityAccessor.java:606)
        at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.preProcess(EntityAccessor.java:589)
        at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage1(MetadataProject.java:1269)
        at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:461)
        at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:359)
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:849)
        ... 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);
                genericParentTemp.removeAll(child.getInterfaces());
               
                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.

Regards
Shikha