Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [COMPARE / TENEO] how can I apply a diff to an existing EObject without the NPE?
[COMPARE / TENEO] how can I apply a diff to an existing EObject without the NPE? [message #610253] Wed, 07 November 2007 01:10
Jason Henriksen is currently offline Jason HenriksenFriend
Messages: 231
Registered: July 2009
Senior Member
Hi All,

I'm getting this exception running EMF Compare in a
WebSphere SOAP service. I can't just call save on the XML backed object
because that will cause Hibernate to do an insert instead of an update.

================================
Caused by: java.lang.Throwable: java.lang.NullPointerException
at
org.eclipse.emf.compare.diff.service.DiffService.parseExtens ionMetadata(DiffService.java:195)
at
org.eclipse.emf.compare.diff.service.DiffService.<clinit>(DiffService.java:54)
at
java.lang.J9VMInternals.initializeImpl(Native Method)
================================


I've gotten one EObject graph out of Teneo and the other from
deserializing a SOAP request. Here's the code:

=================================
//--- get an updated EObject from XML
consumerUpdateInput =
(ConsumerUpdateRequest)soapUtil.
getObjectFromSoap(consumerUpdateRequest);
consumerXML = consumerUpdateInput.getConsumer();

//--- get the real one from the DB
int consumerKey = consumerXML.getConsumerSK();
consumerSQL = (Consumer)session.load("Consumer",
new Integer(consumerKey));


//--- apply the changes to the DB backed object.
Resource leftRes = new XMLResourceImpl();
leftRes.setURI(URI.createURI("leftRes.xml"));
leftRes.getContents().add((EObject)consumerSQL);

Resource rightRes = new XMLResourceImpl();
rightRes.setURI(URI.createURI("rightRes.xml"));
rightRes.getContents().add((EObject)consumerXML);

//!!! This line throws the exception
final MatchModel match = new DifferencesServices().modelMatch(
(EObject)consumerSQL,
(EObject)consumerXML,
new NullProgressMonitor(),
Collections.<String, Object> emptyMap());

final DiffModel diff = new DiffMaker().doDiff(match);
EList<DiffElement> e = diff.getOwnedElements();
ListIterator li = e.listIterator();
while(li.hasNext()){
DiffElement element = (DiffElement)li.next();
AbstractMerger merger = MergeFactory.createMerger(element);
merger.applyInOrigin();
}

//--- save the updated consumer.
session.save(consumerSQL);
session.getTransaction().commit();
resultMessage.setCode("SUCCESS");
==============================

Any help is very much appreciated,

Jason Henriksen
Previous Topic:[CDO] how to handle object update conflicts
Next Topic:UMLProfile vs Ecore
Goto Forum:
  


Current Time: Thu Apr 25 11:55:44 GMT 2024

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

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

Back to the top