Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 332972

Summary: IllegalStateException thrown by DescriptionException at line 391
Product: z_Archived Reporter: Brian Schlining <bschlining>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P2 CC: tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Brian Schlining CLA 2010-12-20 15:34:37 EST
Build Identifier: 

I enabled lazy-loading in my application using static weaving. When static weaving was enabled, I immediately started to see the following stack trace:

Caused by: java.lang.IllegalStateException: Can't overwrite cause
	at java.lang.Throwable.initCause(Throwable.java:320)
	at org.eclipse.persistence.exceptions.DescriptorException.errorAccessingSetMethodOfEntity(DescriptorException.java:391)
	at org.eclipse.persistence.internal.indirection.WeavedObjectBasicIndirectionPolicy.getSetMethod(WeavedObjectBasicIndirectionPolicy.java:87)
	at org.eclipse.persistence.internal.indirection.WeavedObjectBasicIndirectionPolicy.setRealAttributeValueInObject(WeavedObjectBasicIndirectionPolicy.java:131)
	at org.eclipse.persistence.internal.indirection.WeavedObjectBasicIndirectionPolicy.updateValueInObject(WeavedObjectBasicIndirectionPolicy.java:99)
	at org.eclipse.persistence.internal.indirection.WeavedObjectBasicIndirectionPolicy.getRealAttributeValueFromObject(WeavedObjectBasicIndirectionPolicy.java:67)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.getRealAttributeValueFromAttribute(ForeignReferenceMapping.java:865)
	at org.eclipse.persistence.mappings.ObjectReferenceMapping.getRealAttributeValueFromAttribute(ObjectReferenceMapping.java:279)
	at org.eclipse.persistence.mappings.ObjectReferenceMapping.compareForChange(ObjectReferenceMapping.java:152)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.createObjectChangeSetThroughComparison(DeferredChangeDetectionPolicy.java:165)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.createObjectChangeSet(DeferredChangeDetectionPolicy.java:137)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChanges(DeferredChangeDetectionPolicy.java:89)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChangesForExistingObject(DeferredChangeDetectionPolicy.java:54)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChanges(UnitOfWorkImpl.java:634)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1512)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:264)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1148)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)

The root problem is line 391 in DescriptorException:

    public static DescriptorException errorAccessingSetMethodOfEntity(Class aClass, String methodName, ClassDescriptor descriptor, Exception underlying) {
        Object[] args = { aClass, methodName };

        DescriptorException exception = new DescriptorException(ExceptionMessageGenerator.buildMessage(DescriptorException.class, INTERNAL_ERROR_SET_METHOD, args), descriptor, underlying);
        exception.initCause(underlying); // LINE 391: IllegalStateException is thrown here.
        return exception;
    }


Line 391 is the only place that exception.initCause(...) is called in the entire file. 'initCause' should not be called!!! All other methods in DescriptorException use exception.setErrorCode(...) instead.

Also NOTE that because IllegalStateException is thrown, it's impossible to see the original underlying exception. 



Reproducible: Always
Comment 1 Tom Ware CLA 2011-01-05 08:54:13 EST
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:16:45 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:26:27 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink