Skip to main content



      Home
Home » Modeling » EMF » NPE when using EcoreUtil.Copier and then copyReferences()
NPE when using EcoreUtil.Copier and then copyReferences() [message #429162] Fri, 10 April 2009 15:37 Go to next message
Eclipse UserFriend
I am trying to load a Teneo hosted resource, then export to XMI by doing
a "copy" of the root object, then calling copyReferences on the
copier. When I do I get the following...

Exception in thread "main" java.lang.NullPointerException
at
org.eclipse.emf.ecore.util.DelegatingEcoreEList.resolveProxy (DelegatingEcoreEList.java:303)
at
org.eclipse.emf.ecore.util.DelegatingEcoreEList.resolve(Dele gatingEcoreEList.java:264)
at
org.eclipse.emf.common.util.DelegatingEList.get(DelegatingEL ist.java:394)
at
org.eclipse.emf.common.util.DelegatingEList$EIterator.doNext (DelegatingEList.java:1073)
at
org.eclipse.emf.common.util.DelegatingEList$EIterator.next(D elegatingEList.java:1060)
at
org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyReference(Ec oreUtil.java:710)
at
org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyReferences(E coreUtil.java:634)

I need help is detecting and resolving the issue within the resource to
allow this copy to completee... Any ideas.?

Thanks,
Mark.
Re: NPE when using EcoreUtil.Copier and then copyReferences() [message #429163 is a reply to message #429162] Fri, 10 April 2009 15:38 Go to previous messageGo to next message
Eclipse UserFriend
Sorry, forgot to add this in Europa, lastest updates.

Mark Geib wrote:
> I am trying to load a Teneo hosted resource, then export to XMI by doing
> a "copy" of the root object, then calling copyReferences on the copier.
> When I do I get the following...
>
> Exception in thread "main" java.lang.NullPointerException
> at
> org.eclipse.emf.ecore.util.DelegatingEcoreEList.resolveProxy (DelegatingEcoreEList.java:303)
>
> at
> org.eclipse.emf.ecore.util.DelegatingEcoreEList.resolve(Dele gatingEcoreEList.java:264)
>
> at
> org.eclipse.emf.common.util.DelegatingEList.get(DelegatingEL ist.java:394)
> at
> org.eclipse.emf.common.util.DelegatingEList$EIterator.doNext (DelegatingEList.java:1073)
>
> at
> org.eclipse.emf.common.util.DelegatingEList$EIterator.next(D elegatingEList.java:1060)
>
> at
> org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyReference(Ec oreUtil.java:710)
>
> at
> org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyReferences(E coreUtil.java:634)
>
>
> I need help is detecting and resolving the issue within the resource to
> allow this copy to completee... Any ideas.?
>
> Thanks,
> Mark.
Re: NPE when using EcoreUtil.Copier and then copyReferences() [message #429164 is a reply to message #429163] Fri, 10 April 2009 15:46 Go to previous messageGo to next message
Eclipse UserFriend
Hi Mark,
This is maybe a guess, but can it be that the DelegatingEList contains null entries? This can occur in case the
one-to-many is mapped with foreign keys and elements in the list have been deleted without loading the owner of the list.

gr. Martin

Mark Geib wrote:
> Sorry, forgot to add this in Europa, lastest updates.
>
> Mark Geib wrote:
>> I am trying to load a Teneo hosted resource, then export to XMI by
>> doing a "copy" of the root object, then calling copyReferences on the
>> copier. When I do I get the following...
>>
>> Exception in thread "main" java.lang.NullPointerException
>> at
>> org.eclipse.emf.ecore.util.DelegatingEcoreEList.resolveProxy (DelegatingEcoreEList.java:303)
>>
>> at
>> org.eclipse.emf.ecore.util.DelegatingEcoreEList.resolve(Dele gatingEcoreEList.java:264)
>>
>> at
>> org.eclipse.emf.common.util.DelegatingEList.get(DelegatingEL ist.java:394)
>> at
>> org.eclipse.emf.common.util.DelegatingEList$EIterator.doNext (DelegatingEList.java:1073)
>>
>> at
>> org.eclipse.emf.common.util.DelegatingEList$EIterator.next(D elegatingEList.java:1060)
>>
>> at
>> org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyReference(Ec oreUtil.java:710)
>>
>> at
>> org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyReferences(E coreUtil.java:634)
>>
>>
>> I need help is detecting and resolving the issue within the resource
>> to allow this copy to completee... Any ideas.?
>>
>> Thanks,
>> Mark.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: NPE when using EcoreUtil.Copier and then copyReferences() [message #429165 is a reply to message #429164] Fri, 10 April 2009 15:50 Go to previous messageGo to next message
Eclipse UserFriend
Anything is possible.. Suggestions on how to perform a fixup.

Martin Taal wrote:
> Hi Mark,
> This is maybe a guess, but can it be that the DelegatingEList contains
> null entries? This can occur in case the one-to-many is mapped with
> foreign keys and elements in the list have been deleted without loading
> the owner of the list.
>
> gr. Martin
>
> Mark Geib wrote:
>> Sorry, forgot to add this in Europa, lastest updates.
>>
>> Mark Geib wrote:
>>> I am trying to load a Teneo hosted resource, then export to XMI by
>>> doing a "copy" of the root object, then calling copyReferences on
>>> the copier. When I do I get the following...
>>>
>>> Exception in thread "main" java.lang.NullPointerException
>>> at
>>> org.eclipse.emf.ecore.util.DelegatingEcoreEList.resolveProxy (DelegatingEcoreEList.java:303)
>>>
>>> at
>>> org.eclipse.emf.ecore.util.DelegatingEcoreEList.resolve(Dele gatingEcoreEList.java:264)
>>>
>>> at
>>> org.eclipse.emf.common.util.DelegatingEList.get(DelegatingEL ist.java:394)
>>>
>>> at
>>> org.eclipse.emf.common.util.DelegatingEList$EIterator.doNext (DelegatingEList.java:1073)
>>>
>>> at
>>> org.eclipse.emf.common.util.DelegatingEList$EIterator.next(D elegatingEList.java:1060)
>>>
>>> at
>>> org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyReference(Ec oreUtil.java:710)
>>>
>>> at
>>> org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyReferences(E coreUtil.java:634)
>>>
>>>
>>> I need help is detecting and resolving the issue within the resource
>>> to allow this copy to completee... Any ideas.?
>>>
>>> Thanks,
>>> Mark.
>
>
Re: NPE when using EcoreUtil.Copier and then copyReferences() [message #429167 is a reply to message #429165] Fri, 10 April 2009 17:19 Go to previous messageGo to next message
Eclipse UserFriend
Well Mark, as you 'ask' for suggestions let me do my best for you...

I think the only approach is to fix this programmatically, this should not be too hard, iterate over the contents of the
resource, iterate over the lists and then when you encounter null values move the objects down in the list, the elist
has a move method.

gr. Martin

Mark Geib wrote:
> Anything is possible.. Suggestions on how to perform a fixup.
>
> Martin Taal wrote:
>> Hi Mark,
>> This is maybe a guess, but can it be that the DelegatingEList contains
>> null entries? This can occur in case the one-to-many is mapped with
>> foreign keys and elements in the list have been deleted without
>> loading the owner of the list.
>>
>> gr. Martin
>>
>> Mark Geib wrote:
>>> Sorry, forgot to add this in Europa, lastest updates.
>>>
>>> Mark Geib wrote:
>>>> I am trying to load a Teneo hosted resource, then export to XMI by
>>>> doing a "copy" of the root object, then calling copyReferences on
>>>> the copier. When I do I get the following...
>>>>
>>>> Exception in thread "main" java.lang.NullPointerException
>>>> at
>>>> org.eclipse.emf.ecore.util.DelegatingEcoreEList.resolveProxy (DelegatingEcoreEList.java:303)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.util.DelegatingEcoreEList.resolve(Dele gatingEcoreEList.java:264)
>>>>
>>>> at
>>>> org.eclipse.emf.common.util.DelegatingEList.get(DelegatingEL ist.java:394)
>>>>
>>>> at
>>>> org.eclipse.emf.common.util.DelegatingEList$EIterator.doNext (DelegatingEList.java:1073)
>>>>
>>>> at
>>>> org.eclipse.emf.common.util.DelegatingEList$EIterator.next(D elegatingEList.java:1060)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyReference(Ec oreUtil.java:710)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyReferences(E coreUtil.java:634)
>>>>
>>>>
>>>> I need help is detecting and resolving the issue within the resource
>>>> to allow this copy to completee... Any ideas.?
>>>>
>>>> Thanks,
>>>> Mark.
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: NPE when using EcoreUtil.Copier and then copyReferences() [message #429168 is a reply to message #429167] Fri, 10 April 2009 17:24 Go to previous messageGo to next message
Eclipse UserFriend
Martin,

Here is my first try...but I don't ever see a null.

private static void resolveAllObject(EObject eObject)
{
EList eIt = eObject.eContents();
// .eAllContents();
for(int i=0; i<eIt.size(); i++)
{
EObject eo = (EObject)eIt.get(i);
if(null == eo)
{
System.out.println("Found a null object:" + eo);
}
resolveAllObject(eo);
}
return;
}

Is this close to what you suggest.??

Mark.


Martin Taal wrote:
> Well Mark, as you 'ask' for suggestions let me do my best for you...
>
> I think the only approach is to fix this programmatically, this should
> not be too hard, iterate over the contents of the resource, iterate over
> the lists and then when you encounter null values move the objects down
> in the list, the elist has a move method.
>
> gr. Martin
>
> Mark Geib wrote:
>> Anything is possible.. Suggestions on how to perform a fixup.
>>
>> Martin Taal wrote:
>>> Hi Mark,
>>> This is maybe a guess, but can it be that the DelegatingEList
>>> contains null entries? This can occur in case the one-to-many is
>>> mapped with foreign keys and elements in the list have been deleted
>>> without loading the owner of the list.
>>>
>>> gr. Martin
>>>
>>> Mark Geib wrote:
>>>> Sorry, forgot to add this in Europa, lastest updates.
>>>>
>>>> Mark Geib wrote:
>>>>> I am trying to load a Teneo hosted resource, then export to XMI by
>>>>> doing a "copy" of the root object, then calling copyReferences on
>>>>> the copier. When I do I get the following...
>>>>>
>>>>> Exception in thread "main" java.lang.NullPointerException
>>>>> at
>>>>> org.eclipse.emf.ecore.util.DelegatingEcoreEList.resolveProxy (DelegatingEcoreEList.java:303)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.util.DelegatingEcoreEList.resolve(Dele gatingEcoreEList.java:264)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.common.util.DelegatingEList.get(DelegatingEL ist.java:394)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.common.util.DelegatingEList$EIterator.doNext (DelegatingEList.java:1073)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.common.util.DelegatingEList$EIterator.next(D elegatingEList.java:1060)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyReference(Ec oreUtil.java:710)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyReferences(E coreUtil.java:634)
>>>>>
>>>>>
>>>>> I need help is detecting and resolving the issue within the
>>>>> resource to allow this copy to completee... Any ideas.?
>>>>>
>>>>> Thanks,
>>>>> Mark.
>>>
>>>
>
>
Re: NPE when using EcoreUtil.Copier and then copyReferences() [message #429169 is a reply to message #429168] Fri, 10 April 2009 17:31 Go to previous message
Eclipse UserFriend
Hi Mark,
Yes this should give null, otherwise I don't see where the NPE is coming from.
I would run the copy-action (to xmi) in debug mode and put a conditional breakpoint at the NPE location. Then backtrack
through the stacktrace to check the contents of the elist which is iterated/resolved. Then you can also see which elist
(which eobject/efeature) is the problem one.

gr. Martin

Mark Geib wrote:
> Martin,
>
> Here is my first try...but I don't ever see a null.
>
> private static void resolveAllObject(EObject eObject)
> {
> EList eIt = eObject.eContents();
> // .eAllContents();
> for(int i=0; i<eIt.size(); i++)
> {
> EObject eo = (EObject)eIt.get(i);
> if(null == eo)
> {
> System.out.println("Found a null object:" + eo);
> }
> resolveAllObject(eo);
> }
> return;
> }
>
> Is this close to what you suggest.??
>
> Mark.
>
>
> Martin Taal wrote:
>> Well Mark, as you 'ask' for suggestions let me do my best for you...
>>
>> I think the only approach is to fix this programmatically, this should
>> not be too hard, iterate over the contents of the resource, iterate
>> over the lists and then when you encounter null values move the
>> objects down in the list, the elist has a move method.
>>
>> gr. Martin
>>
>> Mark Geib wrote:
>>> Anything is possible.. Suggestions on how to perform a fixup.
>>>
>>> Martin Taal wrote:
>>>> Hi Mark,
>>>> This is maybe a guess, but can it be that the DelegatingEList
>>>> contains null entries? This can occur in case the one-to-many is
>>>> mapped with foreign keys and elements in the list have been deleted
>>>> without loading the owner of the list.
>>>>
>>>> gr. Martin
>>>>
>>>> Mark Geib wrote:
>>>>> Sorry, forgot to add this in Europa, lastest updates.
>>>>>
>>>>> Mark Geib wrote:
>>>>>> I am trying to load a Teneo hosted resource, then export to XMI by
>>>>>> doing a "copy" of the root object, then calling copyReferences on
>>>>>> the copier. When I do I get the following...
>>>>>>
>>>>>> Exception in thread "main" java.lang.NullPointerException
>>>>>> at
>>>>>> org.eclipse.emf.ecore.util.DelegatingEcoreEList.resolveProxy (DelegatingEcoreEList.java:303)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.util.DelegatingEcoreEList.resolve(Dele gatingEcoreEList.java:264)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.common.util.DelegatingEList.get(DelegatingEL ist.java:394)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.common.util.DelegatingEList$EIterator.doNext (DelegatingEList.java:1073)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.common.util.DelegatingEList$EIterator.next(D elegatingEList.java:1060)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyReference(Ec oreUtil.java:710)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyReferences(E coreUtil.java:634)
>>>>>>
>>>>>>
>>>>>> I need help is detecting and resolving the issue within the
>>>>>> resource to allow this copy to completee... Any ideas.?
>>>>>>
>>>>>> Thanks,
>>>>>> Mark.
>>>>
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:confused about when a resource and resourceSet are associated
Next Topic:Avoid qualification of XML-tags in nested elements
Goto Forum:
  


Current Time: Wed Jul 16 22:28:21 EDT 2025

Powered by FUDForum. Page generated in 1.18036 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top