Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Null pointer exception in EStructuralFeatureImpl.getSettingDelegate(null pointer exception)
Null pointer exception in EStructuralFeatureImpl.getSettingDelegate [message #1150219] Tue, 22 October 2013 16:25 Go to next message
Aram Hovsepyan is currently offline Aram HovsepyanFriend
Messages: 34
Registered: July 2009
Member
Hi,

I have been struggling for the past couple of days with an EMF problem. I am using EMF UML2 4.0 models that are created by MagicDraw exporter. The model works just fine when I open it in both UML editor as well as in Sample Ecore Model editor. However, when I try to load it programmatically in my plugin it gives a
java.lang.NullPointerException
at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.getSettingDelegate(EStructuralFeatureImpl.java:830)
(full stack trace is provided hereunder).

The crash happens in my plugin during the run of this piece of code:

ResourceSet rSet = new ResourceSetImpl();
rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", _xmiFac);
URI uri = URI.createFileURI(sourceModelFile.getAbsolutePath());
Resource resource = rSet.getResource(uri, true); // NPE triggered here

Strange thing is that when I remove all magicdraw profile references from my model it works just fine. MagicDraw claims its an EMF problem. Most of all I'd like to understand where the problem comes from and eventually look for a workaround.

Help is highly appreciated on the matter.
Thanks.

java.lang.NullPointerException
at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.getSettingDelegate(EStructuralFeatureImpl.java:830)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSettingDelegate(BasicEObjectImpl.java:1561)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicIsSet(BasicEObjectImpl.java:1271)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1253)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1237)
at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.hasNext(EContentsEList.java:401)
at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.next(EContentsEList.java:559)
at org.eclipse.emf.ecore.util.EcoreUtil$CrossReferencer.handleCrossReference(EcoreUtil.java:1740)
at org.eclipse.emf.ecore.util.ECrossReferenceAdapter$InverseCrossReferencer.add(ECrossReferenceAdapter.java:140)
at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.setTarget(ECrossReferenceAdapter.java:692)
at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.setTarget(ECrossReferenceAdapter.java:674)
at org.eclipse.uml2.common.util.CacheAdapter.setTarget(CacheAdapter.java:345)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.didAdd(BasicNotifierImpl.java:121)
at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:444)
at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:341)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.add(BasicNotifierImpl.java:200)
at org.eclipse.uml2.common.util.CacheAdapter.addAdapter(CacheAdapter.java:275)
at org.eclipse.uml2.common.util.CacheAdapter.addAdapter(CacheAdapter.java:299)
at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.handleContainment(ECrossReferenceAdapter.java:582)
at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.selfAdapt(ECrossReferenceAdapter.java:490)
at org.eclipse.uml2.common.util.CacheAdapter.selfAdapt(CacheAdapter.java:560)
at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.notifyChanged(ECrossReferenceAdapter.java:424)
at org.eclipse.uml2.common.util.CacheAdapter.notifyChanged(CacheAdapter.java:368)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.dispatchNotification(NotifyingListImpl.java:261)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:294)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processTopObject(XMLHandler.java:1491)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1343)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1475)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1026)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:81)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:163)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1363)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:253)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:2550)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(XMLHandler.java:2429)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1306)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1475)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1026)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:81)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:163)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1363)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:253)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:2550)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(XMLHandler.java:2429)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1306)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1475)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1026)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:81)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:163)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:179)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1343)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:253)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
at com.boza.phpgen.actions.CodeGenerator.generate(CodeGenerator.java:120)
at com.boza.phpgen.wizards.GeneratorWizard.performFinish(GeneratorWizard.java:56)
at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:847)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:436)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:633)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4170)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1489)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1474)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1279)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4013)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3652)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:827)
at org.eclipse.jface.window.Window.open(Window.java:803)
at com.boza.phpgen.actions.CodeGenerator.run(CodeGenerator.java:80)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:588)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:505)
at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:456)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4170)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1489)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1474)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1279)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4013)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3652)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:144)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:613)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:109)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:80)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:372)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:226)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
  • Attachment: mbus.uml
    (Size: 66.18KB, Downloaded 363 times)
Re: Null pointer exception in EStructuralFeatureImpl.getSettingDelegate [message #1150238 is a reply to message #1150219] Tue, 22 October 2013 16:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Aram,


I suppose it's happening at the last line below.

public EStructuralFeature.Internal.SettingDelegate getSettingDelegate()
{
if (settingDelegate == null)
{
EClass eClass = getEContainingClass();
eClass.getFeatureCount();
EReference eOpposite = getEOpposite();
if (eOpposite != null)
{
eOpposite.getEContainingClass().getFeatureCount();
}

EClassifier eType = getEType();
Class<?> instanceClass = eType.getInstanceClass();

That implies you have a feature doesn't have a type. Likely you have
some problem with proxies that fail to resolve so you the resulting
Ecore model simply doesn't work until that's addressed.



On 22/10/2013 6:25 PM, Aram Hovsepyan wrote:
> Hi,
>
> I have been struggling for the past couple of days with an EMF problem. I am using EMF UML2 4.0 models that are created by MagicDraw exporter. The model works just fine when I open it in both UML editor as well as in Sample Ecore Model editor. However, when I try to load it programmatically in my plugin it gives a
> java.lang.NullPointerException
> at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.getSettingDelegate(EStructuralFeatureImpl.java:830)
> (full stack trace is provided hereunder).
>
> The crash happens in my plugin during the run of this piece of code:
>
> ResourceSet rSet = new ResourceSetImpl();
> rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", _xmiFac);
> URI uri = URI.createFileURI(sourceModelFile.getAbsolutePath());
> Resource resource = rSet.getResource(uri, true); // NPE triggered here
>
> Strange thing is that when I remove all magicdraw profile references from my model it works just fine. MagicDraw claims its an EMF problem. Most of all I'd like to understand where the problem comes from and eventually look for a workaround.
>
> Help is highly appreciated on the matter.
> Thanks.
>
> java.lang.NullPointerException
> at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.getSettingDelegate(EStructuralFeatureImpl.java:830)
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSettingDelegate(BasicEObjectImpl.java:1561)
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicIsSet(BasicEObjectImpl.java:1271)
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1253)
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1237)
> at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.hasNext(EContentsEList.java:401)
> at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.next(EContentsEList.java:559)
> at org.eclipse.emf.ecore.util.EcoreUtil$CrossReferencer.handleCrossReference(EcoreUtil.java:1740)
> at org.eclipse.emf.ecore.util.ECrossReferenceAdapter$InverseCrossReferencer.add(ECrossReferenceAdapter.java:140)
> at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.setTarget(ECrossReferenceAdapter.java:692)
> at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.setTarget(ECrossReferenceAdapter.java:674)
> at org.eclipse.uml2.common.util.CacheAdapter.setTarget(CacheAdapter.java:345)
> at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.didAdd(BasicNotifierImpl.java:121)
> at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:444)
> at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:341)
> at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.add(BasicNotifierImpl.java:200)
> at org.eclipse.uml2.common.util.CacheAdapter.addAdapter(CacheAdapter.java:275)
> at org.eclipse.uml2.common.util.CacheAdapter.addAdapter(CacheAdapter.java:299)
> at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.handleContainment(ECrossReferenceAdapter.java:582)
> at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.selfAdapt(ECrossReferenceAdapter.java:490)
> at org.eclipse.uml2.common.util.CacheAdapter.selfAdapt(CacheAdapter.java:560)
> at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.notifyChanged(ECrossReferenceAdapter.java:424)
> at org.eclipse.uml2.common.util.CacheAdapter.notifyChanged(CacheAdapter.java:368)
> at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
> at org.eclipse.emf.common.notify.impl.NotifyingListImpl.dispatchNotification(NotifyingListImpl.java:261)
> at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:294)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processTopObject(XMLHandler.java:1491)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1343)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1475)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1026)
> at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:81)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
> at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:163)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1363)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
> at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
> at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
> at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:253)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:2550)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(XMLHandler.java:2429)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1306)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1475)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1026)
> at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:81)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
> at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:163)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1363)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
> at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
> at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
> at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:253)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:2550)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(XMLHandler.java:2429)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1306)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1475)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1026)
> at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:81)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
> at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:163)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
> at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:179)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1343)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
> at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
> at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
> at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:253)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
> at com.boza.phpgen.actions.CodeGenerator.generate(CodeGenerator.java:120)
> at com.boza.phpgen.wizards.GeneratorWizard.performFinish(GeneratorWizard.java:56)
> at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:847)
> at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:436)
> at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:633)
> at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
> at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4170)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1489)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1474)
> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1279)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4013)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3652)
> at org.eclipse.jface.window.Window.runEventLoop(Window.java:827)
> at org.eclipse.jface.window.Window.open(Window.java:803)
> at com.boza.phpgen.actions.CodeGenerator.run(CodeGenerator.java:80)
> at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
> at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
> at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:588)
> at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:505)
> at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:456)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
> at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4170)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1489)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1474)
> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1279)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4013)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3652)
> at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
> at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
> at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
> at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:144)
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:613)
> at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
> at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
> at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
> at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:109)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:80)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:372)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:226)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1450)


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Null pointer exception in EStructuralFeatureImpl.getSettingDelegate [message #1187815 is a reply to message #1150238] Fri, 15 November 2013 09:44 Go to previous messageGo to next message
Aram Hovsepyan is currently offline Aram HovsepyanFriend
Messages: 34
Registered: July 2009
Member
Ed,

Thanks for your reply. I wasn't aware it was posted until now.

Quote:

That implies you have a feature doesn't have a type. Likely you have some problem with proxies that fail to resolve so you the resulting Ecore model simply doesn't work until that's addressed.


What do you mean by "proxies"? Is there something wrong with the model or a referred resource that is missing? Because the model loads just fine in the Sample Reflective Ecore Model Editor.

What I'm trying to accomplish is to obtain an EObject that represents the EMF model. The source code I have right now is this:

EObject sourceModel = null;
XMIResourceFactoryImpl _xmiFac = new XMIResourceFactoryImpl();
ResourceSet rSet = new ResourceSetImpl();
rSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
		.put("*", _xmiFac);
URI uri = URI.createFileURI(sourceModelFile.getAbsolutePath());
Resource resource = rSet.getResource(uri, true);
if (resource != null) {
	if (resource.getContents().size() > 0) {
		sourceModel = (EObject) resource.getContents().get(0);
	}
}


Thanks.

[Updated on: Fri, 15 November 2013 09:49]

Report message to a moderator

Re: Null pointer exception in EStructuralFeatureImpl.getSettingDelegate [message #1187930 is a reply to message #1187815] Fri, 15 November 2013 10:58 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Aram,

Comments below.

On 15/11/2013 10:44 AM, Aram Hovsepyan wrote:
> Ed,
>
> Thanks for your reply. I wasn't aware it was posted until now.
>
> Quote:
>> That implies you have a feature doesn't have a type. Likely you have
>> some problem with proxies that fail to resolve so you the resulting
>> Ecore model simply doesn't work until that's addressed.
>
>
> What do you mean by "proxies"?
It's clear you have a type which has no instance type. So there's
something not right about the Ecore model itself. UML2 uses Ecore
models for profiles, so I think one of your profiles is not properly
resolving all its references to the feature types.
> Is there something wrong with the model or a referred resource that is
> missing?
Probably the profile has some class with a feature that references a
type that is not resolved.
> Because the model loads just fine in the Sample Reflective Ecore Model
> Editor.
If you set a NullPointerException breakpoint (the little J! icon in the
breakpoints view), you can stop where you're seeing the exception.
There you can look at the eType in the variables view and you can
inspect it to determine the proxy URI; that will tell you what resource
it's trying to reference but isn't finding.
>
> The problem occurs when I use Enumerations.
> Thanks.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Null pointer exception in EStructuralFeatureImpl.getSettingDelegate [message #1190606 is a reply to message #1187930] Sat, 16 November 2013 17:54 Go to previous messageGo to next message
Aram Hovsepyan is currently offline Aram HovsepyanFriend
Messages: 34
Registered: July 2009
Member
Ed,

Thanks for the pointers. I have found the "dodgy" profile and it was some MagicDraw customisation profile. I have removed that one, but now I have another problem. The error I get is when trying to cast from EAttributeImpl to EReference. Here is the stack trace. I've looked around for this one and there is one bug report linked to this issue. So, is this really an Eclipse bug, or is there another problem with MagicDraw export.
Thanks a lot.

Thread [main] (Suspended (exception ClassCastException))
SAXXMIHandler(XMLHandler).setAttribValue(EObject, String, String) line: 2729
SAXXMIHandler.handleObjectAttribs(EObject) line: 79
SAXXMIHandler(XMLHandler).createObjectFromFactory(EFactory, String) line: 2200
SAXXMIHandler(XMLHandler).createObjectByType(String, String, boolean) line: 1337
SAXXMIHandler(XMLHandler).createTopObject(String, String) line: 1475
SAXXMIHandler(XMLHandler).processElement(String, String, String) line: 1026
SAXXMIHandler(XMIHandler).processElement(String, String, String) line: 81
SAXXMIHandler(XMLHandler).startElement(String, String, String) line: 1008
SAXXMIHandler(XMLHandler).startElement(String, String, String, Attributes) line: 719
SAXXMIHandler(XMIHandler).startElement(String, String, String, Attributes) line: 163
SAXParserImpl$JAXPSAXParser(AbstractSAXParser).startElement(QName, XMLAttributes, Augmentations) line: 509
SAXParserImpl$JAXPSAXParser(AbstractXMLDocumentParser).emptyElement(QName, XMLAttributes, Augmentations) line: 182
XMLDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanStartElement() line: 1350
XMLDocumentScannerImpl$ContentDriver(XMLDocumentFragmentScannerImpl$FragmentContentDriver).next() line: 2778
XMLDocumentScannerImpl.next() line: 606
XMLDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanDocument(boolean) line: 510
XIncludeAwareParserConfiguration(XML11Configuration).parse(boolean) line: 848
XIncludeAwareParserConfiguration(XML11Configuration).parse(XMLInputSource) line: 777
SAXParserImpl$JAXPSAXParser(XMLParser).parse(XMLInputSource) line: 141
SAXParserImpl$JAXPSAXParser(AbstractSAXParser).parse(InputSource) line: 1213
SAXParserImpl$JAXPSAXParser.parse(InputSource) line: 649
SAXParserImpl.parse(InputSource, DefaultHandler) line: 333
XMILoadImpl(XMLLoadImpl).load(XMLResource, InputStream, Map<?,?>) line: 175
XMIResourceImpl(XMLResourceImpl).doLoad(InputStream, Map<?,?>) line: 253
XMIResourceImpl(ResourceImpl).load(InputStream, Map<?,?>) line: 1518
SAXXMIHandler(XMLHandler).getPackageForURI(String) line: 2550
SAXXMIHandler(XMLHandler).getFactoryForPrefix(String) line: 2429
SAXXMIHandler(XMLHandler).createObjectByType(String, String, boolean) line: 1306
SAXXMIHandler(XMLHandler).createTopObject(String, String) line: 1475
SAXXMIHandler(XMLHandler).processElement(String, String, String) line: 1026
SAXXMIHandler(XMIHandler).processElement(String, String, String) line: 81
SAXXMIHandler(XMLHandler).startElement(String, String, String) line: 1008
SAXXMIHandler(XMLHandler).startElement(String, String, String, Attributes) line: 719
SAXXMIHandler(XMIHandler).startElement(String, String, String, Attributes) line: 163
SAXParserImpl$JAXPSAXParser(AbstractSAXParser).startElement(QName, XMLAttributes, Augmentations) line: 509
SAXParserImpl$JAXPSAXParser(AbstractXMLDocumentParser).emptyElement(QName, XMLAttributes, Augmentations) line: 182
XMLDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanStartElement() line: 1350
XMLDocumentScannerImpl$ContentDriver(XMLDocumentFragmentScannerImpl$FragmentContentDriver).next() line: 2778
XMLDocumentScannerImpl.next() line: 606
XMLDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanDocument(boolean) line: 510
XIncludeAwareParserConfiguration(XML11Configuration).parse(boolean) line: 848
XIncludeAwareParserConfiguration(XML11Configuration).parse(XMLInputSource) line: 777
SAXParserImpl$JAXPSAXParser(XMLParser).parse(XMLInputSource) line: 141
SAXParserImpl$JAXPSAXParser(AbstractSAXParser).parse(InputSource) line: 1213
SAXParserImpl$JAXPSAXParser.parse(InputSource) line: 649
SAXParserImpl.parse(InputSource, DefaultHandler) line: 333
XMILoadImpl(XMLLoadImpl).load(XMLResource, InputStream, Map<?,?>) line: 175
XMIResourceImpl(XMLResourceImpl).doLoad(InputStream, Map<?,?>) line: 253
XMIResourceImpl(ResourceImpl).load(InputStream, Map<?,?>) line: 1518
SAXXMIHandler(XMLHandler).getPackageForURI(String) line: 2550
SAXXMIHandler(XMLHandler).getFactoryForPrefix(String) line: 2429
SAXXMIHandler(XMLHandler).createObjectByType(String, String, boolean) line: 1306
SAXXMIHandler(XMLHandler).createTopObject(String, String) line: 1475
SAXXMIHandler(XMLHandler).processElement(String, String, String) line: 1026
SAXXMIHandler(XMIHandler).processElement(String, String, String) line: 81
SAXXMIHandler(XMLHandler).startElement(String, String, String) line: 1008
SAXXMIHandler(XMLHandler).startElement(String, String, String, Attributes) line: 719
SAXXMIHandler(XMIHandler).startElement(String, String, String, Attributes) line: 163
SAXParserImpl$JAXPSAXParser(AbstractSAXParser).startElement(QName, XMLAttributes, Augmentations) line: 509
SAXParserImpl$JAXPSAXParser(AbstractXMLDocumentParser).emptyElement(QName, XMLAttributes, Augmentations) line: 182
XMLDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanStartElement() line: 1350
XMLDocumentScannerImpl$ContentDriver(XMLDocumentFragmentScannerImpl$FragmentContentDriver).next() line: 2778
XMLDocumentScannerImpl.next() line: 606
XMLDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanDocument(boolean) line: 510
XIncludeAwareParserConfiguration(XML11Configuration).parse(boolean) line: 848
XIncludeAwareParserConfiguration(XML11Configuration).parse(XMLInputSource) line: 777
SAXParserImpl$JAXPSAXParser(XMLParser).parse(XMLInputSource) line: 141
SAXParserImpl$JAXPSAXParser(AbstractSAXParser).parse(InputSource) line: 1213
SAXParserImpl$JAXPSAXParser.parse(InputSource) line: 649
SAXParserImpl.parse(InputSource, DefaultHandler) line: 333
XMILoadImpl(XMLLoadImpl).load(XMLResource, InputStream, Map<?,?>) line: 175
XMIResourceImpl(XMLResourceImpl).doLoad(InputStream, Map<?,?>) line: 253
XMIResourceImpl(ResourceImpl).load(InputStream, Map<?,?>) line: 1518
XMIResourceImpl(ResourceImpl).load(Map<?,?>) line: 1297
ResourceSetImpl.demandLoad(Resource) line: 259
ResourceSetImpl.demandLoadHelper(Resource) line: 274
ResourceSetImpl.getResource(URI, boolean) line: 406
CodeGenerator.generate(boolean) line: 122
GeneratorWizard.performFinish() line: 56
WizardDialog.finishPressed() line: 827
WizardDialog.buttonPressed(int) line: 432
Dialog$2.widgetSelected(SelectionEvent) line: 628
TypedListener.handleEvent(Event) line: 248
EventTable.sendEvent(Event) line: 84
Display.sendEvent(EventTable, Event) line: 4166
Button(Widget).sendEvent(Event) line: 1466
Button(Widget).sendEvent(int, Event, boolean) line: 1489
Button(Widget).sendEvent(int, Event) line: 1474
Button(Widget).notifyListeners(int, Event) line: 1279
Display.runDeferredEvents() line: 4012
Display.readAndDispatch() line: 3651
WizardDialog(Window).runEventLoop(Shell) line: 826
WizardDialog(Window).open() line: 802
CodeGenerator.run(IAction) line: 84
WWinPluginAction(PluginAction).runWithEvent(Event) line: 251
WWinPluginAction.runWithEvent(Event) line: 229
PluginActionCoolBarContributionItem(ActionContributionItem).handleWidgetSelection(Event, boolean) line: 584
ActionContributionItem.access$2(ActionContributionItem, Event, boolean) line: 501
ActionContributionItem$6.handleEvent(Event) line: 452
EventTable.sendEvent(Event) line: 84
Display.sendEvent(EventTable, Event) line: 4166
ToolItem(Widget).sendEvent(Event) line: 1466
ToolItem(Widget).sendEvent(int, Event, boolean) line: 1489
ToolItem(Widget).sendEvent(int, Event) line: 1474
ToolItem(Widget).notifyListeners(int, Event) line: 1279
Display.runDeferredEvents() line: 4012
Display.readAndDispatch() line: 3651
PartRenderingEngine$9.run() line: 1113
Realm.runWithDefault(Realm, Runnable) line: 332
PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 997
E4Workbench.createAndRunUI(MApplicationElement) line: 138
Workbench$5.run() line: 610
Realm.runWithDefault(Realm, Runnable) line: 332
Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 567
PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 150
IDEApplication.start(IApplicationContext) line: 124
EclipseAppHandle.run(Object) line: 196
EclipseAppLauncher.runApplication(Object) line: 110
EclipseAppLauncher.start(Object) line: 79
EclipseStarter.run(Object) line: 354
EclipseStarter.run(String[], Runnable) line: 181
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 606
Main.invokeFramework(String[], URL[]) line: 636
Main.basicRun(String[]) line: 591
Main.run(String[]) line: 1450
Main.main(String[]) line: 1426
Re: Null pointer exception in EStructuralFeatureImpl.getSettingDelegate [message #1191723 is a reply to message #1190606] Sun, 17 November 2013 06:57 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Aram,

You'll need to see what's going wrong in
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.computeFeatureKind(EStructuralFeature).
If it'a an EAttribute, its eType must be an EDataType so that method
must compute one of the first two values for the kind

protected void computeFeatureKind(EStructuralFeature feature)
{
EClassifier eClassifier = feature.getEType();

if (eClassifier instanceof EDataType)
{
if (feature.isMany())
{
featuresToKinds.put(feature, INTEGER_DATATYPE_IS_MANY);
}
else
{
featuresToKinds.put(feature, INTEGER_DATATYPE_SINGLE);
}
}

so in

if (kind == XMLHelper.DATATYPE_SINGLE || kind ==
XMLHelper.DATATYPE_IS_MANY)
{
setFeatureValue(object, feature, value, -2);
}
else
{
setValueFromId(object, (EReference)feature, value);
}

it should take the first branch, but apparently in your case it's taken
the second, so you must have an EAttribute whose eType is an EClass (or
null), neither of which are valid. So look at the feature in question,
and determine why it's got the wrong type.

On 16/11/2013 6:54 PM, Aram Hovsepyan wrote:
> Ed,
>
> Thanks for the pointers. I have found the "dodgy" profile and it was
> some MagicDraw customisation profile. I have removed that one, but now
> I have another problem. The error I get is when trying to cast from
> EAttributeImpl to EReference. Here is the stack trace. I've looked
> around for this one and there is one bug report linked to this issue.
> So, is this really an Eclipse bug, or is there another problem with
> MagicDraw export.
> Thanks a lot.
>
> Thread [main] (Suspended (exception ClassCastException))
> SAXXMIHandler(XMLHandler).setAttribValue(EObject, String, String)
> line: 2729
> SAXXMIHandler.handleObjectAttribs(EObject) line: 79
> SAXXMIHandler(XMLHandler).createObjectFromFactory(EFactory,
> String) line: 2200
> SAXXMIHandler(XMLHandler).createObjectByType(String, String,
> boolean) line: 1337
> SAXXMIHandler(XMLHandler).createTopObject(String, String) line: 1475
> SAXXMIHandler(XMLHandler).processElement(String, String, String)
> line: 1026
> SAXXMIHandler(XMIHandler).processElement(String, String, String)
> line: 81
> SAXXMIHandler(XMLHandler).startElement(String, String, String)
> line: 1008
> SAXXMIHandler(XMLHandler).startElement(String, String, String,
> Attributes) line: 719
> SAXXMIHandler(XMIHandler).startElement(String, String, String,
> Attributes) line: 163
> SAXParserImpl$JAXPSAXParser(AbstractSAXParser).startElement(QName,
> XMLAttributes, Augmentations) line: 509
> SAXParserImpl$JAXPSAXParser(AbstractXMLDocumentParser).emptyElement(QName,
> XMLAttributes, Augmentations) line: 182
> XMLDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanStartElement()
> line: 1350
> XMLDocumentScannerImpl$ContentDriver(XMLDocumentFragmentScannerImpl$FragmentContentDriver).next()
> line: 2778
> XMLDocumentScannerImpl.next() line: 606
> XMLDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanDocument(boolean)
> line: 510
> XIncludeAwareParserConfiguration(XML11Configuration).parse(boolean) line:
> 848
> XIncludeAwareParserConfiguration(XML11Configuration).parse(XMLInputSource)
> line: 777
> SAXParserImpl$JAXPSAXParser(XMLParser).parse(XMLInputSource) line:
> 141
> SAXParserImpl$JAXPSAXParser(AbstractSAXParser).parse(InputSource)
> line: 1213
> SAXParserImpl$JAXPSAXParser.parse(InputSource) line: 649
> SAXParserImpl.parse(InputSource, DefaultHandler) line: 333
> XMILoadImpl(XMLLoadImpl).load(XMLResource, InputStream, Map<?,?>)
> line: 175
> XMIResourceImpl(XMLResourceImpl).doLoad(InputStream, Map<?,?>)
> line: 253
> XMIResourceImpl(ResourceImpl).load(InputStream, Map<?,?>) line: 1518
> SAXXMIHandler(XMLHandler).getPackageForURI(String) line: 2550
> SAXXMIHandler(XMLHandler).getFactoryForPrefix(String) line: 2429
> SAXXMIHandler(XMLHandler).createObjectByType(String, String,
> boolean) line: 1306
> SAXXMIHandler(XMLHandler).createTopObject(String, String) line: 1475
> SAXXMIHandler(XMLHandler).processElement(String, String, String)
> line: 1026
> SAXXMIHandler(XMIHandler).processElement(String, String, String)
> line: 81
> SAXXMIHandler(XMLHandler).startElement(String, String, String)
> line: 1008
> SAXXMIHandler(XMLHandler).startElement(String, String, String,
> Attributes) line: 719
> SAXXMIHandler(XMIHandler).startElement(String, String, String,
> Attributes) line: 163
> SAXParserImpl$JAXPSAXParser(AbstractSAXParser).startElement(QName,
> XMLAttributes, Augmentations) line: 509
> SAXParserImpl$JAXPSAXParser(AbstractXMLDocumentParser).emptyElement(QName,
> XMLAttributes, Augmentations) line: 182
> XMLDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanStartElement()
> line: 1350
> XMLDocumentScannerImpl$ContentDriver(XMLDocumentFragmentScannerImpl$FragmentContentDriver).next()
> line: 2778
> XMLDocumentScannerImpl.next() line: 606
> XMLDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanDocument(boolean)
> line: 510
> XIncludeAwareParserConfiguration(XML11Configuration).parse(boolean) line:
> 848
> XIncludeAwareParserConfiguration(XML11Configuration).parse(XMLInputSource)
> line: 777
> SAXParserImpl$JAXPSAXParser(XMLParser).parse(XMLInputSource) line:
> 141
> SAXParserImpl$JAXPSAXParser(AbstractSAXParser).parse(InputSource)
> line: 1213
> SAXParserImpl$JAXPSAXParser.parse(InputSource) line: 649
> SAXParserImpl.parse(InputSource, DefaultHandler) line: 333
> XMILoadImpl(XMLLoadImpl).load(XMLResource, InputStream, Map<?,?>)
> line: 175
> XMIResourceImpl(XMLResourceImpl).doLoad(InputStream, Map<?,?>)
> line: 253
> XMIResourceImpl(ResourceImpl).load(InputStream, Map<?,?>) line: 1518
> SAXXMIHandler(XMLHandler).getPackageForURI(String) line: 2550
> SAXXMIHandler(XMLHandler).getFactoryForPrefix(String) line: 2429
> SAXXMIHandler(XMLHandler).createObjectByType(String, String,
> boolean) line: 1306
> SAXXMIHandler(XMLHandler).createTopObject(String, String) line: 1475
> SAXXMIHandler(XMLHandler).processElement(String, String, String)
> line: 1026
> SAXXMIHandler(XMIHandler).processElement(String, String, String)
> line: 81
> SAXXMIHandler(XMLHandler).startElement(String, String, String)
> line: 1008
> SAXXMIHandler(XMLHandler).startElement(String, String, String,
> Attributes) line: 719
> SAXXMIHandler(XMIHandler).startElement(String, String, String,
> Attributes) line: 163
> SAXParserImpl$JAXPSAXParser(AbstractSAXParser).startElement(QName,
> XMLAttributes, Augmentations) line: 509
> SAXParserImpl$JAXPSAXParser(AbstractXMLDocumentParser).emptyElement(QName,
> XMLAttributes, Augmentations) line: 182
> XMLDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanStartElement()
> line: 1350
> XMLDocumentScannerImpl$ContentDriver(XMLDocumentFragmentScannerImpl$FragmentContentDriver).next()
> line: 2778
> XMLDocumentScannerImpl.next() line: 606
> XMLDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanDocument(boolean)
> line: 510
> XIncludeAwareParserConfiguration(XML11Configuration).parse(boolean) line:
> 848
> XIncludeAwareParserConfiguration(XML11Configuration).parse(XMLInputSource)
> line: 777
> SAXParserImpl$JAXPSAXParser(XMLParser).parse(XMLInputSource) line:
> 141
> SAXParserImpl$JAXPSAXParser(AbstractSAXParser).parse(InputSource)
> line: 1213
> SAXParserImpl$JAXPSAXParser.parse(InputSource) line: 649
> SAXParserImpl.parse(InputSource, DefaultHandler) line: 333
> XMILoadImpl(XMLLoadImpl).load(XMLResource, InputStream, Map<?,?>)
> line: 175
> XMIResourceImpl(XMLResourceImpl).doLoad(InputStream, Map<?,?>)
> line: 253
> XMIResourceImpl(ResourceImpl).load(InputStream, Map<?,?>) line: 1518
> XMIResourceImpl(ResourceImpl).load(Map<?,?>) line: 1297
> ResourceSetImpl.demandLoad(Resource) line: 259
> ResourceSetImpl.demandLoadHelper(Resource) line: 274
> ResourceSetImpl.getResource(URI, boolean) line: 406
> CodeGenerator.generate(boolean) line: 122
> GeneratorWizard.performFinish() line: 56
> WizardDialog.finishPressed() line: 827
> WizardDialog.buttonPressed(int) line: 432
> Dialog$2.widgetSelected(SelectionEvent) line: 628
> TypedListener.handleEvent(Event) line: 248
> EventTable.sendEvent(Event) line: 84
> Display.sendEvent(EventTable, Event) line: 4166
> Button(Widget).sendEvent(Event) line: 1466
> Button(Widget).sendEvent(int, Event, boolean) line: 1489
> Button(Widget).sendEvent(int, Event) line: 1474
> Button(Widget).notifyListeners(int, Event) line: 1279
> Display.runDeferredEvents() line: 4012
> Display.readAndDispatch() line: 3651
> WizardDialog(Window).runEventLoop(Shell) line: 826
> WizardDialog(Window).open() line: 802
> CodeGenerator.run(IAction) line: 84
> WWinPluginAction(PluginAction).runWithEvent(Event) line: 251
> WWinPluginAction.runWithEvent(Event) line: 229
> PluginActionCoolBarContributionItem(ActionContributionItem).handleWidgetSelection(Event,
> boolean) line: 584
> ActionContributionItem.access$2(ActionContributionItem, Event,
> boolean) line: 501
> ActionContributionItem$6.handleEvent(Event) line: 452
> EventTable.sendEvent(Event) line: 84
> Display.sendEvent(EventTable, Event) line: 4166
> ToolItem(Widget).sendEvent(Event) line: 1466
> ToolItem(Widget).sendEvent(int, Event, boolean) line: 1489
> ToolItem(Widget).sendEvent(int, Event) line: 1474
> ToolItem(Widget).notifyListeners(int, Event) line: 1279
> Display.runDeferredEvents() line: 4012
> Display.readAndDispatch() line: 3651
> PartRenderingEngine$9.run() line: 1113
> Realm.runWithDefault(Realm, Runnable) line: 332
> PartRenderingEngine.run(MApplicationElement, IEclipseContext)
> line: 997
> E4Workbench.createAndRunUI(MApplicationElement) line: 138
> Workbench$5.run() line: 610
> Realm.runWithDefault(Realm, Runnable) line: 332
> Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 567
> PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 150
> IDEApplication.start(IApplicationContext) line: 124
> EclipseAppHandle.run(Object) line: 196
> EclipseAppLauncher.runApplication(Object) line: 110
> EclipseAppLauncher.start(Object) line: 79
> EclipseStarter.run(Object) line: 354
> EclipseStarter.run(String[], Runnable) line: 181
> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line:
> not available [native method]
> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
> Method.invoke(Object, Object...) line: 606
> Main.invokeFramework(String[], URL[]) line: 636
> Main.basicRun(String[]) line: 591
> Main.run(String[]) line: 1450
> Main.main(String[]) line: 1426
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Null pointer exception in EStructuralFeatureImpl.getSettingDelegate [message #1195005 is a reply to message #1191723] Mon, 18 November 2013 20:11 Go to previous message
Aram Hovsepyan is currently offline Aram HovsepyanFriend
Messages: 34
Registered: July 2009
Member
Hi Ed,

I can't figure it out. I now somehow got rid of this error but got another NPE at another spot. I have managed to somehow get rid of MagicDraw problematic profiles (although the tool complained numerous times that I shouldn't do that) and now everything works. Bottom line - UML Metamodel is in theory sufficient to create any MagicDraw profile by yourself. So the post can be closed, thanks for the valuable advices.

Cheers.
Previous Topic:Manipulating files with EMF
Next Topic:[EMF] Required XML Attributes with only one value
Goto Forum:
  


Current Time: Fri Mar 29 14:36:45 GMT 2024

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

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

Back to the top