Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » NullPointerException in LazyLinker: EPackage is null for EClass from no-namespace XML model
NullPointerException in LazyLinker: EPackage is null for EClass from no-namespace XML model [message #695891] Tue, 12 July 2011 18:59 Go to next message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 98
Registered: July 2009
Location: New York City, NY
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 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
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 Go to previous messageGo to next message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 98
Registered: July 2009
Location: New York City, NY
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?
Re: NullPointerException in LazyLinker: EPackage is null for EClass from no-namespace XML model [message #695942 is a reply to message #695933] Tue, 12 July 2011 21:57 Go to previous messageGo to next message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 98
Registered: July 2009
Location: New York City, NY
Member
Oh, sorry... to answer your question: we're using Xtext 1.0.1, if that helps.
Thanks!
Re: NullPointerException in LazyLinker: EPackage is null for EClass from no-namespace XML model [message #695975 is a reply to message #695942] Wed, 13 July 2011 00:37 Go to previous message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 98
Registered: July 2009
Location: New York City, NY
Member
Okay, here's a funky hack that seems to be working (and, yeah, it's a total hack):
In the plug-in activator of the Xtext runtime plug-in:
        Registry registry = Registry.INSTANCE;
        Object pkg = registry.get("platform:/resource/com.intuit.interview.iedit.styles/src/com/intuit/interview/iedit/styles/models/graphic.xsd");
        URL entry = context.getBundle().getEntry("/");
        registry.put(entry.toString().replace("bundleentry:", "bundleresource:") + "../../com.intuit.interview.iedit.styles/src/com/intuit/interview/iedit/styles/models/graphic.xsd", pkg);
and, in the plugin.xml of the external model plug-in:
 <extension point="org.eclipse.emf.ecore.generated_package">
  <package uri="platform:/resource/com.intuit.interview.iedit.styles/src/com/intuit/interview/iedit/styles/models/graphic.xsd"
   class="com.intuit.interview.iedit.styles.graphic.GraphicPackage"
   genModel="src/com/intuit/interview/iedit/styles/models/graphic.genmodel">
  </package>
 </extension>
Now, this code obviously does not at all look like a real solution; I just added it to illustrate the problem. Can someone set me straight about what I should be really doing? Wink
Thanks!
Previous Topic:Editor can't be initalized. Unresolved proxy
Next Topic:XtextCellEditor usable in a JFace Tableviewer?
Goto Forum:
  


Current Time: Wed Sep 23 04:49:41 GMT 2020

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

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

Back to the top