Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext error when used as a tool plugin(An xt.linking.lazy.LazyLinkingResource error occurs when running an Xtext project as a plugin. In its standalone version it works correctly.)
Xtext error when used as a tool plugin [message #1853904] Thu, 21 July 2022 21:11 Go to next message
Julia Robles is currently offline Julia RoblesFriend
Messages: 4
Registered: April 2021
Junior Member
Hello,

I'm trying to integrate a standalone project I made with Xtext and EMF as a plugin. The project (github) converts models in XMI to the textual modelling language USE and vice versa. The goal is to integrate this conversion as a plugin (github of plugins) of the USE tool (github). Regarding the import from XMI to USE there is no problem, as it does not use Xtext. The problem lies in the export. When exporting it, the following error appears:

USE version 6.0.0, Copyright (C) 1999-2021 University of Bremen
use> Filename: C:\Users\julia\Documents\use-6.0.0\examples\Others\CarRental\CarRental2.use
File: C:\Users\julia\Downloads
The USE file "CarRental2.use" will be converted to UML...
0    [AWT-EventQueue-0] ERROR xt.linking.lazy.LazyLinkingResource  - resolution of uriFragment '|26' failed.
java.lang.StringIndexOutOfBoundsException: String index out of range: 3219
        at java.lang.String.substring(String.java:1963)
        at org.eclipse.xtext.nodemodel.impl.AbstractNode.getText(AbstractNode.java:157)
        at org.eclipse.xtext.nodemodel.util.NodeModelUtils.getTokenText(NodeModelUtils.java:413)
        at org.eclipse.xtext.linking.impl.LinkingHelper.getCrossRefNodeAsString(LinkingHelper.java:59)
        at org.eclipse.xtext.linking.impl.DefaultLinkingService.getCrossRefNodeAsString(DefaultLinkingService.java:126)
        at org.eclipse.xtext.linking.impl.DefaultLinkingService.getLinkedObjects(DefaultLinkingService.java:100)
        at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:247)
        at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:222)
        at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:223)
        at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:209)
        at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:269)
        at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eResolveProxy(BasicEObjectImpl.java:1477)
        at modelConverter.use_language.use.impl.ContextsTypeImpl.getClassname(ContextsTypeImpl.java:75)
        at modelConverter.use_language.generator.USEGenerator.lambda$2(USEGenerator.java:212)
        at org.eclipse.xtext.xbase.lib.internal.BooleanFunctionDelegate.apply(BooleanFunctionDelegate.java:41)
        at com.google.common.collect.Iterators$6.computeNext(Iterators.java:617)
        at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:145)
        at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:140)
        at com.google.common.collect.Iterators$6.computeNext(Iterators.java:615)
        at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:145)
        at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:140)
        at modelConverter.use_language.generator.USEGenerator.compileClass(USEGenerator.java:272)
        at modelConverter.use_language.generator.USEGenerator.compileType(USEGenerator.java:215)
        at modelConverter.use_language.generator.USEGenerator.compileModel(USEGenerator.java:147)
        at modelConverter.use_language.generator.USEGenerator.doGenerate(USEGenerator.java:111)
        at org.eclipse.xtext.generator.GeneratorDelegate.doGenerate(GeneratorDelegate.java:43)
        at org.eclipse.xtext.generator.GeneratorDelegate.generate(GeneratorDelegate.java:34)
        at main.model.usetouml.General.generateUML(Unknown Source)
        at main.model.Generators.fromUSEtoUML(Unknown Source)
        at main.plugin.XMIHandlerPlugin.exportToXMI(Unknown Source)
        at main.plugin.gui.XMIHandlerView.initGUI(Unknown Source)
        at main.plugin.gui.XMIHandlerView.<init>(Unknown Source)
        at main.plugin.gui.ActionExportXMI.performAction(Unknown Source)
        at org.tzi.use.runtime.gui.impl.PluginAction.actionPerformed(Unknown Source)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
        at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
        at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:882)
        at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:926)
        at java.awt.Component.processMouseEvent(Component.java:6539)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
        at java.awt.Component.processEvent(Component.java:6304)
        at java.awt.Container.processEvent(Container.java:2239)
        at java.awt.Component.dispatchEventImpl(Component.java:4889)
        at java.awt.Container.dispatchEventImpl(Container.java:2297)
        at java.awt.Component.dispatchEvent(Component.java:4711)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
        at java.awt.Container.dispatchEventImpl(Container.java:2283)
        at java.awt.Window.dispatchEventImpl(Window.java:2746)
        at java.awt.Component.dispatchEvent(Component.java:4711)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
        at java.awt.EventQueue.access$500(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:709)
        at java.awt.EventQueue$3.run(EventQueue.java:703)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
        at java.awt.EventQueue$4.run(EventQueue.java:733)
        at java.awt.EventQueue$4.run(EventQueue.java:731)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)



This error does NOT appear when converting the same USE file to XMI with the standalone tool, it only appears when using the plugin. The conversion is performed correctly in the standalone version.

I think it might be some kind of incompatibility of Xtext with the USE tool. I was told that USE worked better with Java 8 so I have modified everything to make the plugin work correctly in that version. However, the error persists. I saw a similar error in this forum question but I don't think it has much to do with it or I don't understand the solution.

I'm really stuck with this error and I can't figure out what it is. I hope someone can help me with this.

You can see the actual code at github. In the dist folder you have the last compilation I made of the plugin (it is added to the USE plugins folder).

Thank you in advance!
Re: Xtext error when used as a tool plugin [message #1853906 is a reply to message #1853904] Fri, 22 July 2022 04:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14428
Registered: July 2009
Senior Member
the code mentions USEStandaloneSetup;
as the name says it is not meant to be used inside eclipse.
in eclipse you are not allowed to use it.

here is the options you have to obtain an injector in eclipse
https://www.eclipse.org/Xtext/documentation/302_configuration.html#obtaining-an-injector
https://koehnlein.blogspot.com/2012/11/xtext-tip-how-do-i-get-guice-injector.html

besides the executableextensionfactory way something like

IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(URI.createURI("dummy.mydsl")).get(Injector.class);
or
IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(URI.createURI("dummy.mydsl")).get(ResourceSet.class);

might work.



Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 22 July 2022 04:37]

Report message to a moderator

Re: Xtext error when used as a tool plugin [message #1853909 is a reply to message #1853906] Fri, 22 July 2022 06:54 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7564
Registered: July 2009
Senior Member
Hi

I put

assert !EMFPlugin.IS_ECLIPSE_RUNNING;

in my StandaloneSetup.doSetup to ensure that the use-in-IDE howler is avoided. (Bug 340408 might have made this problem go away, but it was WONTFIXed.)

If fixing the StandaloneSetup call doesn't help, the String index out of range: 3219 suggests that you two alternative text versions to substring and the wrong one is in use. This can occur when a concurrent Xtext activity happens, possibly via a builder. This can often be solved by correct use of the IUnitOfWork API which must be used to inhibit concurrency. If totally confused, a few 'printf's with associated System.identityHashCode calls may help you understand your two alternatives.

Regards

Ed Willink
Previous Topic:How to get parent scope for nested block?
Next Topic:Supporting method overloading
Goto Forum:
  


Current Time: Tue Jan 31 06:16:36 GMT 2023

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

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

Back to the top