java.lang.NullPointerException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • can't unmarshal wrapped elements
    via by 843834,
  • db:: 4.61::Unmarshaller unexpected element jm
    via by Unknown author,
  • db:: 4.92::Unmarshal exception 8j
    via by Unknown author,
  • I found a bug, that got introduced by adding functionality to the class TypeFactory in Hibernate 3.2.3. The Method TypeFactory#replaceAssociations(...) now has some special handling regarding components / embeddables. But if such a component is null, wich is fair enough, Hibernate will provoke a NullPointerException in sun.reflect.UnsafeFieldAccessorImpl.ensureObj(...): Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of de.ploed.test.MonetaryAmount.amount at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:647) at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:236) at de.ploed.test.EntityManagerTest.main(EntityManagerTest.java:22) Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of de.ploed.test.MonetaryAmount.amount at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:35) at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:64) at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:70) at org.hibernate.tuple.component.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:83) at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:353) at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:348) at org.hibernate.type.TypeFactory.replaceAssociations(TypeFactory.java:556) at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:366) at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:195) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:123) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53) at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665) at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:227) ... 1 more Caused by: java.lang.NullPointerException at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:36) at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18) at java.lang.reflect.Field.get(Field.java:357) at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:32) ... 15 more I think that the handling of target[i] in Line 556 of org.hibernate.type.TypeFactory is not null safe. I have created a patch for this and the bug above appears to be fixed in this patch. In my humble opinion this bug makes it impossible to merge any entity / value object containing a null reference to another value object. However this bug is not present when using session.save or session.saveOrUpdate. I was able to reproduce the bug in Hibernate Core 3.2.4.sp1, 3.2.4 and 3.2.3 .. It is not present in Hibernate Core Versions <= 3.2.2 Attached to this task are the following files: patch.txt - my patch proposal TestCase.zip - Test Case Please get back to me if you have any further questions! Cheers, Mike
    via by Michael Plöd,
  • I found a bug, that got introduced by adding functionality to the class TypeFactory in Hibernate 3.2.3. The Method TypeFactory#replaceAssociations(...) now has some special handling regarding components / embeddables. But if such a component is null, wich is fair enough, Hibernate will provoke a NullPointerException in sun.reflect.UnsafeFieldAccessorImpl.ensureObj(...): Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of de.ploed.test.MonetaryAmount.amount at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:647) at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:236) at de.ploed.test.EntityManagerTest.main(EntityManagerTest.java:22) Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of de.ploed.test.MonetaryAmount.amount at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:35) at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:64) at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:70) at org.hibernate.tuple.component.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:83) at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:353) at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:348) at org.hibernate.type.TypeFactory.replaceAssociations(TypeFactory.java:556) at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:366) at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:195) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:123) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53) at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665) at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:227) ... 1 more Caused by: java.lang.NullPointerException at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:36) at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18) at java.lang.reflect.Field.get(Field.java:357) at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:32) ... 15 more I think that the handling of target[i] in Line 556 of org.hibernate.type.TypeFactory is not null safe. I have created a patch for this and the bug above appears to be fixed in this patch. In my humble opinion this bug makes it impossible to merge any entity / value object containing a null reference to another value object. However this bug is not present when using session.save or session.saveOrUpdate. I was able to reproduce the bug in Hibernate Core 3.2.4.sp1, 3.2.4 and 3.2.3 .. It is not present in Hibernate Core Versions <= 3.2.2 Attached to this task are the following files: patch.txt - my patch proposal TestCase.zip - Test Case Please get back to me if you have any further questions! Cheers, Mike
    via by Michael Plöd,
    • java.lang.NullPointerException at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:36) at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18) at java.lang.reflect.Field.get(Field.java:357) at com.sun.xml.bind.v2.runtime.reflect.Accessor$FieldReflection.get(Accessor.java:185) at com.sun.xml.bind.v2.runtime.reflect.Lister$CollectionLister.startPacking(Lister.java:249) at com.sun.xml.bind.v2.runtime.reflect.Lister$CollectionLister.startPacking(Lister.java:224) at com.sun.xml.bind.v2.runtime.unmarshaller.Scope.add(Scope.java:78) at com.sun.xml.bind.v2.runtime.property.ArrayERProperty$ReceiverImpl.receive(ArrayERProperty.java:150) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.endElement(UnmarshallingContext.java:404) at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXConnector.java:125) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:200) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:173) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:142) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:151) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:169) at test.Class3.main(Class3.java:43)

    Users with the same issue

    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown User
    Unknown User2 times, last one,
    adawolfs
    adawolfs4 times, last one,
    3 more bugmates