NullPointerException in LazyLinker: EPackage is null for EClass from no-namespace XML model [message #695891] |
Tue, 12 July 2011 18:59 |
Mirko Raner Messages: 125 Registered: July 2009 Location: New York City, NY |
Senior Member |
|
|
Hi all,
I've been banging my head against this problem on and off for a couple of days, so I thought I run it by the community:
I have an Xtext language that has a reference to an additional external Ecore model. This model is generated from an XSD schema that describes the data format of the external model. Notably, the XML format for the external content has no namespace (it is a legacy format, and unfortunately that fact can't be helped at this point).
I got the ScopeProvider implemented that brings the external model into scope at the right places, and when I use content assist I see the correct elements from the external model. However, immediately after selecting a completion the editor reported an NPE, essentially because the model element's EClass has essentially a null EPackage. I customized the XMLHelper to set the no-namespace package and to make sure that getType(EFactory, String) works correctly and doesn't create duplicate EClasses during XML deserialization. Still, somehow the LazyLinker comes across EClasses that return null for getEPackage(), and I get the following exception:
org.eclipse.emf.common.util.WrappedException: java.lang.NullPointerException
at org.eclipse.xtext.util.OnChangeEvictingCache.execWithoutCacheClear(OnChangeEvictingCache.java:65)
at org.eclipse.xtext.linking.lazy.LazyLinker.doLinkModel(LazyLinker.java:89)
at org.eclipse.xtext.linking.impl.AbstractCleaningLinker.linkModel(AbstractCleaningLinker.java:28)
at org.eclipse.xtext.resource.XtextResource.doLinking(XtextResource.java:247)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLinking(LazyLinkingResource.java:70)
at org.eclipse.xtext.resource.XtextResource.updateInternalState(XtextResource.java:213)
at org.eclipse.xtext.resource.XtextResource.doLoad(XtextResource.java:147)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLoad(LazyLinkingResource.java:63)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1494)
at org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.loadResource(XtextDocumentProvider.java:120)
at org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.setDocumentContent(XtextDocumentProvider.java:103)
at org.eclipse.ui.editors.text.StorageDocumentProvider.createDocument(StorageDocumentProvider.java:229)
at org.eclipse.ui.editors.text.FileDocumentProvider.createElementInfo(FileDocumentProvider.java:735)
at org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.createElementInfo(XtextDocumentProvider.java:131)
at org.eclipse.ui.texteditor.AbstractDocumentProvider.connect(AbstractDocumentProvider.java:400)
at org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput(AbstractTextEditor.java:4056)
at org.eclipse.ui.texteditor.StatusTextEditor.doSetInput(StatusTextEditor.java:217)
at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.doSetInput(AbstractDecoratedTextEditor.java:1444)
at org.eclipse.ui.editors.text.TextEditor.doSetInput(TextEditor.java:169)
at org.eclipse.xtext.ui.editor.XtextEditor.doSetInput(XtextEditor.java:149)
at org.eclipse.ui.texteditor.AbstractTextEditor$19.run(AbstractTextEditor.java:3043)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:759)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:756)
at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2600)
at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3061)
at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3088)
at org.eclipse.xtext.ui.editor.XtextEditor.init(XtextEditor.java:169)
at org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:798)
at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:647)
at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.internal.EditorAreaHelper.setVisibleEditor(EditorAreaHelper.java:271)
at org.eclipse.ui.internal.EditorManager.setVisibleEditor(EditorManager.java:1429)
at org.eclipse.ui.internal.EditorManager$5.runWithException(EditorManager.java:942)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3586)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3279)
at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
at org.eclipse.ui.internal.Workbench$31.runWithException(Workbench.java:1567)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3586)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3279)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2548)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Caused by: java.lang.NullPointerException
at org.eclipse.emf.ecore.util.EcoreUtil.create(EcoreUtil.java:3247)
at org.eclipse.xtext.linking.lazy.LazyLinker.createProxy(LazyLinker.java:173)
at org.eclipse.xtext.linking.lazy.LazyLinker.createAndSetProxy(LazyLinker.java:158)
at org.eclipse.xtext.linking.lazy.LazyLinker.installProxies(LazyLinker.java:127)
at org.eclipse.xtext.linking.lazy.LazyLinker.installProxies(LazyLinker.java:109)
at org.eclipse.xtext.linking.lazy.LazyLinker$2.process(LazyLinker.java:96)
at org.eclipse.xtext.linking.lazy.LazyLinker$2.process(LazyLinker.java:1)
at org.eclipse.xtext.util.concurrent.IUnitOfWork$Void.exec(IUnitOfWork.java:36)
at org.eclipse.xtext.util.OnChangeEvictingCache.execWithoutCacheClear(OnChangeEvictingCache.java:63)
... 68 more
Any idea what I'm missing here? We previously integrated similar no-namespace XML models by hacking the resource loading mechanism and add a namespace on the fly, but we weren't really happy with that solution.
Thanks,
Mirko
|
|
|
Re: NullPointerException in LazyLinker: EPackage is null for EClass from no-namespace XML model [message #695933 is a reply to message #695891] |
Tue, 12 July 2011 21:24 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Mirko,
which Xtext version do you use? It looks like EReference#getType returns
a proxy which indicates a missing entry in the plugin.xml.
Can you confirm that your EPackage is available in the EPackage.Registry?
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
On 12.07.11 20:59, Mirko Raner wrote:
> Hi all,
>
> I've been banging my head against this problem on and off for a couple
> of days, so I thought I run it by the community:
> I have an Xtext language that has a reference to an additional external
> Ecore model. This model is generated from an XSD schema that describes
> the data format of the external model. Notably, the XML format for the
> external content has no namespace (it is a legacy format, and
> unfortunately that fact can't be helped at this point).
> I got the ScopeProvider implemented that brings the external model into
> scope at the right places, and when I use content assist I see the
> correct elements from the external model. However, immediately after
> selecting a completion the editor reported an NPE, essentially because
> the model element's EClass has essentially a null EPackage. I customized
> the XMLHelper to set the no-namespace package and to make sure that
> getType(EFactory, String) works correctly and doesn't create duplicate
> EClasses during XML deserialization. Still, somehow the LazyLinker comes
> across EClasses that return null for getEPackage(), and I get the
> following exception:
>
> org.eclipse.emf.common.util.WrappedException:
> java.lang.NullPointerException
> at
> org.eclipse.xtext.util.OnChangeEvictingCache.execWithoutCacheClear(OnChangeEvictingCache.java:65)
>
> at
> org.eclipse.xtext.linking.lazy.LazyLinker.doLinkModel(LazyLinker.java:89)
> at
> org.eclipse.xtext.linking.impl.AbstractCleaningLinker.linkModel(AbstractCleaningLinker.java:28)
>
> at
> org.eclipse.xtext.resource.XtextResource.doLinking(XtextResource.java:247)
> at
> org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLinking(LazyLinkingResource.java:70)
>
> at
> org.eclipse.xtext.resource.XtextResource.updateInternalState(XtextResource.java:213)
>
> at org.eclipse.xtext.resource.XtextResource.doLoad(XtextResource.java:147)
> at
> org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLoad(LazyLinkingResource.java:63)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1494)
>
> at
> org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.loadResource(XtextDocumentProvider.java:120)
>
> at
> org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.setDocumentContent(XtextDocumentProvider.java:103)
>
> at
> org.eclipse.ui.editors.text.StorageDocumentProvider.createDocument(StorageDocumentProvider.java:229)
>
> at
> org.eclipse.ui.editors.text.FileDocumentProvider.createElementInfo(FileDocumentProvider.java:735)
>
> at
> org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.createElementInfo(XtextDocumentProvider.java:131)
>
> at
> org.eclipse.ui.texteditor.AbstractDocumentProvider.connect(AbstractDocumentProvider.java:400)
>
> at
> org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput(AbstractTextEditor.java:4056)
>
> at
> org.eclipse.ui.texteditor.StatusTextEditor.doSetInput(StatusTextEditor.java:217)
>
> at
> org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.doSetInput(AbstractDecoratedTextEditor.java:1444)
>
> at org.eclipse.ui.editors.text.TextEditor.doSetInput(TextEditor.java:169)
> at org.eclipse.xtext.ui.editor.XtextEditor.doSetInput(XtextEditor.java:149)
> at
> org.eclipse.ui.texteditor.AbstractTextEditor$19.run(AbstractTextEditor.java:3043)
>
> at
> org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
>
> at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
> at
> org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:759)
>
> at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
> at
> org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:756)
> at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2600)
> at
> org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3061)
>
> at
> org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3088)
>
> at org.eclipse.xtext.ui.editor.XtextEditor.init(XtextEditor.java:169)
> at org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:798)
> at
> org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:647)
>
> at
> org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
>
> at
> org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
>
> at
> org.eclipse.ui.internal.EditorAreaHelper.setVisibleEditor(EditorAreaHelper.java:271)
>
> at
> org.eclipse.ui.internal.EditorManager.setVisibleEditor(EditorManager.java:1429)
>
> at
> org.eclipse.ui.internal.EditorManager$5.runWithException(EditorManager.java:942)
>
> at
> org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
>
> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
> at
> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
>
> at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3586)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3279)
> at
> org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
>
> at
> org.eclipse.ui.internal.Workbench$31.runWithException(Workbench.java:1567)
> at
> org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
>
> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
> at
> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
>
> at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3586)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3279)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2548)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
> at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
>
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
> at
> org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
>
> 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:619)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
> Caused by: java.lang.NullPointerException
> at org.eclipse.emf.ecore.util.EcoreUtil.create(EcoreUtil.java:3247)
> at
> org.eclipse.xtext.linking.lazy.LazyLinker.createProxy(LazyLinker.java:173)
> at
> org.eclipse.xtext.linking.lazy.LazyLinker.createAndSetProxy(LazyLinker.java:158)
>
> at
> org.eclipse.xtext.linking.lazy.LazyLinker.installProxies(LazyLinker.java:127)
>
> at
> org.eclipse.xtext.linking.lazy.LazyLinker.installProxies(LazyLinker.java:109)
>
> at org.eclipse.xtext.linking.lazy.LazyLinker$2.process(LazyLinker.java:96)
> at org.eclipse.xtext.linking.lazy.LazyLinker$2.process(LazyLinker.java:1)
> at
> org.eclipse.xtext.util.concurrent.IUnitOfWork$Void.exec(IUnitOfWork.java:36)
>
> at
> org.eclipse.xtext.util.OnChangeEvictingCache.execWithoutCacheClear(OnChangeEvictingCache.java:63)
>
> ... 68 more
>
> Any idea what I'm missing here? We previously integrated similar
> no-namespace XML models by hacking the resource loading mechanism and
> add a namespace on the fly, but we weren't really happy with that solution.
>
> Thanks,
>
> Mirko
>
|
|
|
Re: NullPointerException in LazyLinker: EPackage is null for EClass from no-namespace XML model [message #695941 is a reply to message #695933] |
Tue, 12 July 2011 21:55 |
Mirko Raner Messages: 125 Registered: July 2009 Location: New York City, NY |
Senior Member |
|
|
Thanks for the hint, Sebastian.
My plugin.xml contains the org.eclipse.emf.ecore.generated_package extension for the external model, but I'm not sure whether I got the uri attribute right. With XML models that have a proper namespace I usually used the namespace URI as the package URI, but I wasn't sure what to use in this case. I tried some made-up URI, the platform resource URI of the model (i.e., platform:/resource/com.intuit.interview.iedit.styles/src/com/intuit/interview/iedit/styles/models/graphic.xsd#/), and the empty string, but none seemed to work. With using the empty string, my additional concern is that there are actually multiple external models without namespaces that I need to integrate with my main Xtext model.
Do you have any guidance on what URIs I should use to register the EPackages?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03050 seconds