Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF Compare and Merge(Got Invocation InvocationTargetException when click on commit button in compare dialog)
EMF Compare and Merge [message #1798544] Tue, 20 November 2018 10:16 Go to next message
Ramesh Javalagatti is currently offline Ramesh JavalagattiFriend
Messages: 16
Registered: November 2018
Junior Member
Hi,
I am trying to compare and merge two resources using EMF compare and Merge.I am getting InvocationTargetException when commiting the merge transaction so please give me solution. please find code and error screen shot.

public boolean compareAndMergeEObjects(IFile local_oldSWCFile,IProject local_selectedProject,IStructuredSelection selectedSTructure) {

HashMap<String, Resource> local_arPackages=new HashMap<String, Resource>();
local_arPackages=this.getARPackages(local_oldSWCFile,local_selectedProject,selectedSTructure);
boolean local_flag=false;
Notifier left =local_arPackages.get("local_SWCresource");
Notifier right=local_arPackages.get("local_ARXMLresource");
if(local_arPackages !=null){
IComparisonScope scope = new DefaultComparisonScope(left,
right,null);
EMFCompare comparator = EMFCompare.builder().build();
Comparison comparison = comparator.compare(scope);
EList<Diff> differences = comparison.getDifferences();
if(differences.isEmpty()){
local_flag=true;
return local_flag;
}

ICompareEditingDomain editingDomain = EMFCompareEditingDomain.create(left,
right,null);
AdapterFactory adapterFactory = new ComposedAdapterFactory
(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
@SuppressWarnings("restriction")
EMFCompareConfiguration configuration=new EMFCompareConfiguration(new CompareConfiguration());

@SuppressWarnings("restriction")
CompareEditorInput input = new ComparisonEditorInput(configuration, comparison, editingDomain, adapterFactory);
//To Open Compare dialog to show differences
CompareUI.openCompareDialog(input);

}
return local_flag;

}
/**
*
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
global_window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
return null;
}
/**
*
* @param local_oldSWCFile
* @param local_selectedProject
* @return
*/
public HashMap<String,Resource> getARPackages(IFile local_oldSWCFile,
IProject local_selectedProject,IStructuredSelection selectedStructure){


IFile local_arxmlFile=null;
IResource[] local_resource=null;

//List<ARPackage> local_SWCarPackages = null;
//List<ARPackage> local_ARXMLarPackages = null;
HashMap<String,Resource> local_arPackageMap=new HashMap<String, Resource>();

if(local_oldSWCFile !=null){
URI local_createPlatformResourceURISWC = URI.createPlatformResourceURI
(local_oldSWCFile.getFullPath().toString(), true);
Resource local_SWCresource = new ResourceSetImpl()
.getResource(local_createPlatformResourceURISWC, true);
local_arPackageMap.put("local_SWCresource", local_SWCresource);
}
else{
ModelARXMLFileCreation local_modelARXMLFileCreation=new ModelARXMLFileCreation(local_selectedProject, "ModelFile.arxml",selectedStructure);
local_modelARXMLFileCreation.createModelFile();

try {
local_resource = local_selectedProject.members();
} catch (CoreException e) {

e.printStackTrace();
}
for (IResource iResource : local_resource) {
if (iResource instanceof IFile) {
if (((IFile)iResource).getName().equals("ModelFile.arxml")) {
global_swcFile = (IFile) iResource;
break;
} // End of if(matcher.matches())
} // End of If (iResource instanceof IFile)
}

/*
variable used to store regular expression of a file (autosartoplevelstructure)
final String local_AUTOSAR_PATTERN = "([^\\s]+(\\.(?i)(autosartoplevelstructure))$)";
*//**
* method used to complie of regular expression pattern
*
* @param ARPACKAGE_PATTERN
* compiles the regular expression into a pattern
* @return pattern return the given regular expression compiled into a
* pattern and assigned to a variable pattern
*//*
Pattern local_pattern = Pattern.compile(local_AUTOSAR_PATTERN);

for (IResource iResource : local_resource) {
if (iResource instanceof IFile) {
Matcher local_matcher = local_pattern.matcher(((IFile) iResource).getName());
if (local_matcher.matches()) {
local_swcFile = (IFile) iResource;
} // End of if(matcher.matches())
}
}*/
URI local_createPlatformResourceURISWC = URI.createPlatformResourceURI
(global_swcFile.getFullPath().toString(), true);
Resource local_SWCresource = new ResourceSetImpl()
.getResource(local_createPlatformResourceURISWC, true);
local_arPackageMap.put("local_SWCresource", local_SWCresource);
//EList<EObject> local_SWCresources = local_SWCresource.getContents();
}
/* variable used to store regular expression of a file */
final String local_DESCRIPTIONFILE_PATTERN = "([^\\s]+(\\.(?i)(arxml))$)";
/**
* method used to compiles the regular expression into a pattern
*
* @param local_DESCRIPTIONFILE_PATTERN
* hold the .arxml file extension
* @return pattern returns the given regular expression compiled
* into a pattern and assigned to a variable arxmlPattern
*/
Pattern local_arxmlPattern = Pattern.compile(local_DESCRIPTIONFILE_PATTERN);
try {
local_resource = local_selectedProject.members();
} catch (CoreException e) {
e.printStackTrace();
}
for (IResource iResource : local_resource) {
if (iResource instanceof IFile) {
Matcher local_arxmlMatcher = local_arxmlPattern.matcher(((IFile) iResource).getName());
if (local_oldSWCFile != null) {
if (local_arxmlMatcher.matches()
&& !(((IFile) iResource).getName()).equals(local_oldSWCFile.getName())) {
local_arxmlFile = (IFile) iResource;
break;
}
} else {
if(local_arxmlMatcher.matches()
&& !(((IFile)iResource).getName()).equals("ModelFile.arxml")){
local_arxmlFile = (IFile) iResource;
break;
}
}
} // End of If (iResource instanceof IFile)
}

//create resources from the arxmFile
URI local_createPlatformResourceURIARXML = URI.createPlatformResourceURI
(local_arxmlFile.getFullPath().toString(), true);
Resource local_ARXMLresource = new ResourceSetImpl()
.getResource(local_createPlatformResourceURIARXML, true);
local_arPackageMap.put("local_ARXMLresource", local_ARXMLresource);
// Get all contents from the resource

//EList<EObject> local_ARXMLResources = local_ARXMLresource.getContents();

return local_arPackageMap;

}

Below line of code throwing the exception
PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
saveChanges(monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
  • Attachment: error.PNG
    (Size: 46.70KB, Downloaded 38 times)
Re: EMF Compare and Merge [message #1798581 is a reply to message #1798544] Tue, 20 November 2018 16:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30653
Registered: July 2009
Senior Member
You also posted on the EMF Compare forum:

https://www.eclipse.org/forums/index.php/t/1096280/

That's where you should ask. Though if it were me answering, I'd ask to see the stack trace.
Re: EMF Compare and Merge [message #1798606 is a reply to message #1798581] Wed, 21 November 2018 04:46 Go to previous messageGo to next message
Ramesh Javalagatti is currently offline Ramesh JavalagattiFriend
Messages: 16
Registered: November 2018
Junior Member
I am Sorry for posting in two places.Please find stack trace below

!ENTRY org.eclipse.emf.common 2 0 2018-11-20 15:36:41.749
!MESSAGE An exception was ignored during command execution
!STACK 0
org.eclipse.emf.common.util.WrappedException: An exception was ignored during command execution
at org.eclipse.emf.common.command.BasicCommandStack.handleError(BasicCommandStack.java:281)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.handleError(AbstractTransactionalCommandStack.java:125)
at org.eclipse.emf.common.command.BasicCommandStack.undo(BasicCommandStack.java:148)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.basicUndo(AbstractTransactionalCommandStack.java:257)
at org.eclipse.emf.transaction.impl.TransactionalCommandStackImpl.undo(TransactionalCommandStackImpl.java:134)
at org.eclipse.emf.compare.command.impl.TransactionalDualCompareCommandStack.undo(TransactionalDualCompareCommandStack.java:179)
at org.eclipse.emf.compare.ide.ui.internal.editor.AbstractEMFCompareEditorInput.cancelPressed(AbstractEMFCompareEditorInput.java:87)
at org.eclipse.compare.internal.CompareDialog.buttonPressed(CompareDialog.java:207)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:618)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4418)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4236)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3824)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:818)
at org.eclipse.jface.window.Window.open(Window.java:794)
at org.eclipse.compare.internal.CompareDialog.open(CompareDialog.java:196)
at org.eclipse.compare.internal.CompareUIPlugin$4.run(CompareUIPlugin.java:1419)
at org.eclipse.compare.internal.CompareUIPlugin.syncExec(CompareUIPlugin.java:1429)
at org.eclipse.compare.internal.CompareUIPlugin.internalOpenDialog(CompareUIPlugin.java:1422)
at org.eclipse.compare.internal.CompareUIPlugin.openCompareDialog(CompareUIPlugin.java:596)
at org.eclipse.compare.CompareUI.openCompareDialog(CompareUI.java:211)
at com.avin.importArxml.SwcEditorDiffMergeImpl.compareAndMergeEObjects(SwcEditorDiffMergeImpl.java:95)
at com.avin.importArxml.SwcEditorProjectWizardFileSystemResourceImportPage.finish(SwcEditorProjectWizardFileSystemResourceImportPage.java:825)
at com.avin.importArxml.SwcEditorProjectFileSystemImportWizard.performFinish(SwcEditorProjectFileSystemImportWizard.java:132)
at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:790)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:423)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:618)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4418)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4236)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3824)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:818)
at org.eclipse.jface.window.Window.open(Window.java:794)
at org.eclipse.ui.internal.handlers.WizardHandler$Import.executeHandler(WizardHandler.java:158)
at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:290)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:295)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:282)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:264)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:494)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:488)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommand(LegacyHandlerService.java:353)
at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:155)
at org.eclipse.ui.internal.actions.CommandAction.run(CommandAction.java:165)
at org.eclipse.ui.actions.ImportResourcesAction.run(ImportResourcesAction.java:99)
at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:167)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:565)
at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:397)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4418)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4236)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3824)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:693)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
Caused by: org.eclipse.emf.common.util.WrappedException: java.lang.NumberFormatException: For input string: "AR_SR_INTRA"
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.getEObjectForURIFragmentRootSegment(ResourceImpl.java:717)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.getEObject(ResourceImpl.java:763)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.getEObject(ResourceImpl.java:742)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:223)
at org.eclipse.sphinx.emf.ecore.proxymanagement.ProxyResolutionBehavior.eResolveProxyInResourceSet(ProxyResolutionBehavior.java:63)
at org.eclipse.sphinx.emf.ecore.proxymanagement.ProxyResolutionBehavior.eResolveProxy(ProxyResolutionBehavior.java:47)
at org.eclipse.sphinx.emf.ecore.ExtendedMinimalEObjectImpl.eResolveProxy(ExtendedMinimalEObjectImpl.java:28)
at autosar40.swcomponent.swcinternalbehavior.rteevents.impl.RTEEventImpl.getStartOnEvent(RTEEventImpl.java:298)
at autosar40.swcomponent.swcinternalbehavior.rteevents.impl.RTEEventImpl.eGet(RTEEventImpl.java:441)
at autosar40.swcomponent.swcinternalbehavior.rteevents.impl.TimingEventImpl.eGet(TimingEventImpl.java:245)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1011)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1003)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:998)
at org.eclipse.emf.ecore.change.impl.FeatureChangeImpl.preApply(FeatureChangeImpl.java:692)
at org.eclipse.emf.ecore.change.impl.ChangeDescriptionImpl.preApply(ChangeDescriptionImpl.java:803)
at org.eclipse.emf.ecore.change.impl.ChangeDescriptionImpl.applyAndReverse(ChangeDescriptionImpl.java:324)
at org.eclipse.emf.edit.command.ChangeCommand.undo(ChangeCommand.java:163)
at org.eclipse.emf.common.command.BasicCommandStack.undo(BasicCommandStack.java:143)
... 84 more
Caused by: java.lang.NumberFormatException: For input string: "AR_SR_INTRA"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.getEObjectForURIFragmentRootSegment(ResourceImpl.java:713)
Re: EMF Compare and Merge [message #1798609 is a reply to message #1798606] Wed, 21 November 2018 06:08 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30653
Registered: July 2009
Senior Member
This stack trace suggests that a number of additional software components are involved. I.e., Autosar models, based on Sphinx. It also suggests that your instance model contains a bad proxy URI fragment, or at least one that can't be handled by a non-specialized resource implementation. Perhaps Sphinx/Autosar has a specialized resource implementation that should be used but isn't being used. The fragment starts with a "/" and what follows is not a number, so definitely either the fragment is incorrect or the wrong resource implementation is being used to load the instance. But only you can solve that problem and you have more than enough information to set a break point and find out what's going wrong.
Re: EMF Compare and Merge [message #1798732 is a reply to message #1798609] Fri, 23 November 2018 12:01 Go to previous messageGo to next message
Ramesh Javalagatti is currently offline Ramesh JavalagattiFriend
Messages: 16
Registered: November 2018
Junior Member
Hi Ed Merks,

Actually i am getting that Error for only imported arxml file which is generated by artop model, if I export model which is generated by my work space it is working fine. So can I get any example how to convert imported arxml file to AUTOSAR model in work-space.
Re: EMF Compare and Merge [message #1798734 is a reply to message #1798732] Fri, 23 November 2018 12:08 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6514
Registered: July 2009
Senior Member
Hi

Use the Sample Reflective Ecore Editor to detect where the bug is.

If your model can be successfully loaded and validated, then the producer is ok and the consumer is bad. Else the producer/installation is bad and you are wasting time attempting to debug consumers.

Regards

Ed Willink
Re: EMF Compare and Merge [message #1798760 is a reply to message #1798734] Fri, 23 November 2018 16:14 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30653
Registered: July 2009
Senior Member
This is the EMF forum, not the Artop forum and not AUTOSAR fourm. You need to consult with the people who are providing these specific technologies.
Previous Topic:Getting Error For EForms
Next Topic:team dev, git, and emf code gen
Goto Forum:
  


Current Time: Fri Nov 22 20:17:40 GMT 2019

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

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

Back to the top