Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » Need help/guidance in using emf-compare standalone to compare two xml files based on a model
Need help/guidance in using emf-compare standalone to compare two xml files based on a model [message #1064922] Fri, 21 June 2013 16:29 Go to next message
Amit Kumar is currently offline Amit Kumar
Messages: 12
Registered: May 2013
Junior Member
My objective is to run emf-compare in standalone mode especially the merge feature to merge two xml files based on an ecore model.
For this I am using the example plugin and imported org.eclipse.emf.compare.examples.standalone proejct in my workspaace.
I have all the required jar files in my classpath as explained at FAQs


The xml files are taken from another example org.eclipse.emf.compare.examples.export.library\model\samples\v1.library and v2.library
And the model is present at org.eclipse.emf.compare.examples.export.library\model\library.ecore

I have attached these files with this post.

Now on running the ExampleLauncher along with the two sample files as command line arguments I get this exception:

org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with uri 'library' not found. (file:/C:/Users/AmitK14/Desktop/4_0_2-System-File/test/v1.library, 2, 112)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:191)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:180)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1445)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1241)
	at org.eclipse.emf.compare.util.ModelUtils.load(ModelUtils.java:320)
	at org.eclipse.emf.compare.util.ModelUtils.load(ModelUtils.java:218)
	at org.eclipse.emf.compare.examples.standalone.ExampleLauncher.main(ExampleLauncher.java:78)
Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'library' not found. (file:/C:/Users/AmitK14/Desktop/4_0_2-System-File/test/v1.library, 2, 112)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:2576)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(XMLHandler.java:2407)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1285)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1454)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1019)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:83)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1001)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:712)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:167)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:181)
	... 6 more


I am not able to get to the root cause for this. Any ideas where am I going wrong?

I appreciate your help and am willing to update the eclipse wiki with my example to run the emf compare in standalone mode.

Thanks in advance.

--
amit
  • Attachment: examples.zip
    (Size: 272.67KB, Downloaded 64 times)
Re: Need help/guidance in using emf-compare standalone to compare two xml files based on a model [message #1064942 is a reply to message #1064922] Fri, 21 June 2013 18:59 Go to previous messageGo to next message
Amit Kumar is currently offline Amit Kumar
Messages: 12
Registered: May 2013
Junior Member
More info: I have not written code for merge yet and the ExampleLauncher.java is exactly the same as in the attached file which I am running. The idea was to get the diff object first and see its output.

--
amit
Re: Need help/guidance in using emf-compare standalone to compare two xml files based on a model [message #1065067 is a reply to message #1064942] Mon, 24 June 2013 08:31 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1625
Registered: July 2009
Senior Member
This is a very common error with EMF. You might also look at what I wrote back then on http://eclipsemde.blogspot.fr/2010/06/package-with-uri-not-found.html .

Since you are running your code in standalone, you need to register your package yourself. The two lines of code I mentionned in the above blog post are still true today.

Laurent Goubet
Obeo
Re: Need help/guidance in using emf-compare standalone to compare two xml files based on a model [message #1065243 is a reply to message #1065067] Tue, 25 June 2013 05:55 Go to previous messageGo to next message
Amit Kumar is currently offline Amit Kumar
Messages: 12
Registered: May 2013
Junior Member
Thanks Laurent for the pointer. I will try this.

--
amit
Re: Need help/guidance in using emf-compare standalone to compare two xml files based on a model [message #1066650 is a reply to message #1065243] Wed, 03 July 2013 14:57 Go to previous messageGo to next message
Amit Kumar is currently offline Amit Kumar
Messages: 12
Registered: May 2013
Junior Member
Hi Laurent,
I tried as explained in the blog and it fixed the problem. But I am now facing another issue while merging the diff I got. Its not merging the diffs in the origin nor in target.
DiffModel doDiff = diffEng.doDiff(contentMatch);
final List<DiffElement> differences = doDiff.getOwnedElements();
		List<DiffElement> diffs= new ArrayList<DiffElement>();
		for(DiffElement diff:differences )
		{
			diffs.add(diff);
		}
DefaultMerger defMerger= new  DefaultMerger();
	for (DiffElement diffElement : diffs ) {
					defMerger.setDiffElement(diffElement);
					diffElement.eContainer().
					defMerger.applyInOrigin();

				}


Am I supposed to write my own implementation of DefaultMerger here ? Can you give me some pointer to how to go about achieving this ?
Note: I am now doing this in the plugin development environment, instead of standalone. Do you want me to create a new thread ?

Thanks,
Amit
Re: Need help/guidance in using emf-compare standalone to compare two xml files based on a model [message #1066796 is a reply to message #1066650] Thu, 04 July 2013 12:28 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1625
Registered: July 2009
Senior Member
Amit,

merging differences in EMF Compare 1.* required you to use the proper merger for each difference. The Default is only a base implementation for subclasses.

Please use the MergeService to avoid such issues : MergeService.merge(differences, true).

Laurent Goubet
Obeo

[Updated on: Thu, 04 July 2013 12:28]

Report message to a moderator

Re: Need help/guidance in using emf-compare standalone to compare two xml files based on a model [message #1066799 is a reply to message #1066796] Thu, 04 July 2013 12:59 Go to previous messageGo to next message
Amit Kumar is currently offline Amit Kumar
Messages: 12
Registered: May 2013
Junior Member
Hi Laurent,
Thanks for your reply, I tried MergeService.merge(differences, true) as suggested by you already. But it gives me class cast exceptions:
java.lang.ClassCastException: java.lang.String cannot be cast to org.eclipse.emf.ecore.util.FeatureMap$Entry
	at org.eclipse.emf.ecore.util.BasicFeatureMap.addUnique(BasicFeatureMap.java:1)
	at org.eclipse.emf.compare.util.EFactory.eAdd(EFactory.java:92)
	at org.eclipse.emf.compare.diff.internal.merge.impl.AttributeChangeLeftTargetMerger.undoInTarget(AttributeChangeLeftTargetMerger.java:76)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.doMerge(MergeService.java:166)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.merge(MergeService.java:130)


Where am I going wrong? I checked the differences , they are all fine.

Thanks,
Amit
Re: Need help/guidance in using emf-compare standalone to compare two xml files based on a model [message #1066908 is a reply to message #1066799] Fri, 05 July 2013 06:39 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1625
Registered: July 2009
Senior Member
Amit,

This looks like a bug in our merger implementation for the FeatureMaps. EMF Compare 1 being deprecated by EMF Compare 2, there is no plan to fix the bugs in that legacy implementation. The best wolution would be to turn to EMF Compare 2.1 and start using the new APIs, that should be better on all aspects (detection, merging ... and flexibility of use).

If you need to use EMF Compare 1, you might want to turn to the LTS (Long Term Support) initiative or mail Obeo (commercial(at)obeo.fr) for support and hot fixes of legacy versions.

Laurent Goubet
Obeo
Re: Need help/guidance in using emf-compare standalone to compare two xml files based on a model [message #1066912 is a reply to message #1066908] Fri, 05 July 2013 06:50 Go to previous messageGo to next message
Amit Kumar is currently offline Amit Kumar
Messages: 12
Registered: May 2013
Junior Member
Thanks, for the information.
I will try to use EMF Compare 2 for this. Can you point me to the docs of the new apis ?

Thanks,
Amit
Re: Need help/guidance in using emf-compare standalone to compare two xml files based on a model [message #1066961 is a reply to message #1066912] Fri, 05 July 2013 09:02 Go to previous messageGo to next message
Amit Kumar is currently offline Amit Kumar
Messages: 12
Registered: May 2013
Junior Member
Laurent,
I downloaded emf compare 2.1 and found the docs here :
org.eclipse.emf.compare.doc_2.1.0.201306250935/tutorials/Using_Compare_Services.html


I will try this and let you know.

Thanks,
Amit
Re: Need help/guidance in using emf-compare standalone to compare two xml files based on a model [message #1067036 is a reply to message #1066961] Fri, 05 July 2013 14:33 Go to previous messageGo to next message
Amit Kumar is currently offline Amit Kumar
Messages: 12
Registered: May 2013
Junior Member
I am sorry but I think the doc is not updated with emf compare 2.1 apis Sad can anyone share a sample program like ExampleLauncher ?
Re: Need help/guidance in using emf-compare standalone to compare two xml files based on a model [message #1067277 is a reply to message #1067036] Mon, 08 July 2013 08:00 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1625
Registered: July 2009
Senior Member
Amit,

The included documentation hasn't been updated for 2.1 yet. All of the wiki, however, is up-to-date (even if nt complete for somer parts). The answer to your question is in the FAQ.

Laurent Goubet
Obeo

[Updated on: Mon, 08 July 2013 08:01]

Report message to a moderator

Re: Need help/guidance in using emf-compare standalone to compare two xml files based on a model [message #1067921 is a reply to message #1067277] Thu, 11 July 2013 09:12 Go to previous message
Amit Kumar is currently offline Amit Kumar
Messages: 12
Registered: May 2013
Junior Member
Thanks Laurent, I am trying this.
Previous Topic:Improving threshold usage on EditionDistance.distance(Comparison inProgress, EObject a, EObject b)
Next Topic:About the next EMF Compare release plans
Goto Forum:
  


Current Time: Wed Sep 17 05:42:06 GMT 2014

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

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