Home » Modeling » EMF » NPE when using EcoreUtil.Copier and then copyReferences()
| |
Re: NPE when using EcoreUtil.Copier and then copyReferences() [message #429164 is a reply to message #429163] |
Fri, 10 April 2009 19:46 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
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 #429167 is a reply to message #429165] |
Fri, 10 April 2009 21:19 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
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 21:24 |
Mark Geib Messages: 432 Registered: July 2009 |
Senior Member |
|
|
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 21:31 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
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
|
|
|
Goto Forum:
Current Time: Wed Jun 05 07:52:16 GMT 2024
Powered by FUDForum. Page generated in 0.03882 seconds
|