Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment'
Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1716443] Thu, 03 December 2015 21:35 Go to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
I have a fresh install of Luna and just grabbed Xtext 2.9. I was trying to migrate a 3.7.2 Project that used Xtextz 2.2 to Luna/Xtext2.9 and ran into many frustrating unhandled ui loop exceptions that constantly froze Luna.

So I tried to create a new Xtext Project from my existing ecore model. [I should add that I created this ecore model, some I'm importing it and not generating it from any existing grammar]

I'm running into issues right away.

My GenerateMyDsl.mwe2 can't resolve stuff that would seem like the Xtext wizard and generators should handle on their own. Examples:

Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment'
Couldn't resolve reference to JvmIdentifiableElement 'fragment'
Couldn't resolve reference to JvmIdentifiableElement 'standaloneSetup
Couldn't resolve reference to JvmIdentifiableElement 'loadedResource

The content of the mwe2 file is also drastically different than before (which might be expected from migrating to Xtext 2.2 to 2.9)

Any idea what I'm missing?


[Updated on: Fri, 04 December 2015 03:27]

Report message to a moderator

Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1716454 is a reply to message #1716443] Fri, 04 December 2015 03:06 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
I think I must obviously be missing a plugin. Here's the "broken" lines from the Xtext generated GenerateMyDsl.mwe2 file:

standaloneSetup = {
loadedResource = "platform:/resource/<MyProject>/model/<MyModel>.genmodel"
}

fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment2 auto-inject {}

fragment = adapter.FragmentAdapter {
fragment = ecore2xtext.FormatterFragment {}


My xtext.common.types is very new 2.9.0.v210512010527

My model Project has Xtext nature set.

The dependencies between my previous working xtext project and thew newest one are quite different - primarily most of the Xtext 2.9 dependencies are found in the Automated Management of Dependency section (and hence not in the Manifest file.

Confused.

[Updated on: Fri, 04 December 2015 03:06]

Report message to a moderator

Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1716455 is a reply to message #1716454] Fri, 04 December 2015 03:25 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
I have made my Project containing the ecore model dependent upon xbase.lib. I am not sure why other than random hits on JVMType problems seems to resolve for other people when they do this.

When I added that dependency, I see a new line appear in my, still broken in the same way, mwe2 file:

fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment2 auto-inject {}

[Updated on: Fri, 04 December 2015 03:25]

Report message to a moderator

Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1716471 is a reply to message #1716455] Fri, 04 December 2015 08:48 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Hi Brandon,

unfortunately the Ecore2Xtext wizard is broken in 2.9.0. There is already a bug for that:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=483088

Here's the 3 changes you need to do:

- in your workflow
- import org.eclipse.xtext.generator.*
- replace the standaloneSetup block with referencedResource = "uriOfReferencedEcoreModel"
- in your Manifest.MF
- add a dependency to org.eclipse.xtext.generator

Cheers,
Stefan
Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1716513 is a reply to message #1716471] Fri, 04 December 2015 13:23 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Thanks Stefan!

Just some additional info:
- My workflow already had import org.eclipse.xtext.xtext.generator.* and I added import org.eclipse.xtext.generator.*
- I placed referencedResource = "uriOfReferencedEcoreModel" in the workflow
- fragment = adapter.FragmentAdapter {
fragment = ecore2xtext.FormatterFragment {}
}

was still unable to resolve. I commented it out for now.
- My Manifest.MF already contained: org.eclipse.xtext.generator


So I'm now able to run the workflow and progress. Thank you for your help.

Unfortunately, and this isn't your problem, but I'm back to having Luna throw unhandled event loops again from the e4 workbench randomly after about 4-10 key presses. Very frustrating that a year old release of Eclipse is having unstable workbench behavior right out of the box.

Looking forward to learning more about Xtext! Thanks!

[Updated on: Fri, 04 December 2015 13:24]

Report message to a moderator

Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1716531 is a reply to message #1716513] Fri, 04 December 2015 15:38 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Hi Brandon,

your Manifest does not have 'org.eclipse.xtext.generator', please add it. It has 'org.eclipse.xtext.xtext.generator' (note the extra 'xtext' Wink

After you add that, the FormatterFragment will work.

Cheers,
Stefan
Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1716571 is a reply to message #1716531] Sat, 05 December 2015 02:53 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
You are correct! I have added the 'org.eclipse.xtext.generator' properly now as a dependency.

I can see these lines are now clean in my workflow:

referencedResource = "<My Ns URI>/model/<My Model>.ecore"

fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment2 auto-inject {}

fragment = adapter.FragmentAdapter {
fragment = ecore2xtext.FormatterFragment {}
}


Progress!

Then retrogression:

First errors on standalone setup:

345 [main] INFO lipse.emf.mwe.utils.StandaloneSetup - Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!
532 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher - org/eclipse/xtext/ecore/EcoreSupportStandaloneSetup
java.lang.NoClassDefFoundError: org/eclipse/xtext/ecore/EcoreSupportStandaloneSetup
at org.eclipse.xtext.xtext.generator.XtextGeneratorResourceSetInitializer.ensureResourceCanBeLoaded(XtextGeneratorResourceSetInitializer.java:93)

So I changed out my URI and went with this format:

referencedResource = "platform:/resource/<MY Project>/model/<My Model>.ecore"

Same problems.

Then I tried to set referencedResource to my _genmodel_

referencedResource = "platform:/resource/<My Project>/model/<MY Model>.genmodel"

Progress!

Then retrogression:

15588 [main] INFO text.xtext.generator.XtextGenerator - Generating common infrastructure
15604 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher - Problems running workflow org.xtext.example.mydsl1.GenerateMyDsl:
[ERROR]: GeneratorException: (Element: -UNKNOWN-; Reported by: XtextGenerator)
java.lang.IllegalArgumentException: Cannot determine the package name of 'java.util.Map.Entry'. Please use the TypeReference(packageName, className) constructor
at org.eclipse.xtext.xtext.generator.model.TypeReference.getPackageName(TypeReference.java:176)
at org.eclipse.xtext.xtext.generator.model.TypeReference.<init>(TypeReference.java:70)
at org.eclipse.xtext.xtext.generator.model.TypeReference.<init>(TypeReference.java:66)
at org.eclipse.xtext.xtext.generator.model.TypeReference.<init>(TypeReference.java:62)
at org.eclipse.xtext.xtext.generator.model.TypeReference.<init>(TypeReference.java:145)
at org.eclipse.xtext.xtext.generator.model.JavaFileAccess$JavaTypeAwareStringConcatenation.getStringRepresentation(JavaFileAccess.java:62)

I am declaring a a java.util.Map$Entry in my ecore mode the way I have done for years. Additionally, Xtext 2.2 was able to deal with it.

I probably generated my genmodel and model code using EMF 2.7. I don't think java.util.Map$Entry has changed in 2.10 EMF, but I'm not sure.

Thanks for all the help.
Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1716678 is a reply to message #1716571] Mon, 07 December 2015 13:25 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Hi Brandon,

I added the last problem to the ticket we opened. There is nothing wrong with your model. We will fix that in 2.9.1. Sorry for the inconvenience.

Cheers,
Stefan
Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1716828 is a reply to message #1716678] Tue, 08 December 2015 12:39 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Thanks very much for your help and analysis. Until 2.9.1 is ready, is there an update site for 2.8.4? I've only been able to track down an archive zip file.
Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1716833 is a reply to message #1716828] Tue, 08 December 2015 12:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
did you uncheck the "show only latest" option in eclipse. it hides older versions from the update site (the normal one should contain alls versions)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1716845 is a reply to message #1716833] Tue, 08 December 2015 14:18 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
That was my problem. I can now see 2.8.4. Thanks guys!
Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1717191 is a reply to message #1716845] Thu, 10 December 2015 15:55 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Hi Brandon,

could you elaborate on how you used java.util.Map$Entry in your ecore model?
Ideally as a comment on this ticket : https://bugs.eclipse.org/bugs/show_bug.cgi?id=483088
I'd like to reproduce and fix the issue.

thanks,
Sven
Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1720905 is a reply to message #1716678] Thu, 21 January 2016 18:14 Go to previous messageGo to next message
Alfonso de la Vega is currently offline Alfonso de la VegaFriend
Messages: 18
Registered: January 2016
Junior Member
Hello,

As I have a problem similar to Brandon's I will ask it here.

I am running Xtext 2.9.1 on Eclipse Mars and I am finding problems when creating projects from existing metamodels using Maven or Gradle configurations.

When I try to generate Xtext artifacts from eclipse run configurations, it works fine, as it was announced to be fixed in 2.9.1.

However, when I try to build the project using Maven or Gradle (for example, trying to run the new web editor via the gradle jettyrun task), I see the same dependency failure problem:

.../org.xtext.example.mydsl.parent$ ./gradlew jettyrun
:org.xtext.example.mydsl:generateXtextLanguage
0 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher - [XtextLinkingDiagnostic: null:41 Couldn't resolve reference to JvmType 'org.eclipse.xtext.generator.adapter.FragmentAdapter'., XtextLinkingDiagnostic: null:42 Couldn't resolve reference to JvmIdentifiableElement 'fragment'., XtextLinkingDiagnostic: null:42 Couldn't resolve reference to JvmType 'org.eclipse.xtext.generator.ecore2xtext.FormatterFragment'.]
java.lang.IllegalStateException: [XtextLinkingDiagnostic: null:41 Couldn't resolve reference to JvmType 'org.eclipse.xtext.generator.adapter.FragmentAdapter'., XtextLinkingDiagnostic: null:42 Couldn't resolve reference to JvmIdentifiableElement 'fragment'., XtextLinkingDiagnostic: null:42 Couldn't resolve reference to JvmType 'org.eclipse.xtext.generator.ecore2xtext.FormatterFragment'.]
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:88)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
:org.xtext.example.mydsl:generateXtextLanguage FAILED

Steps to reproduce this problem:
1. Create a new xtext project from an existing metamodel.
2. Select web integration and gradle as build system
3. Run a gradle task (for example, gradlew jettyrun)

Both org.eclipse.xtext.generator and org.eclipse.xtext.xtext.generator are included by default in the dsl manifest.

Am I missing some extra configuration I need to apply?

Thank you very much,
Alfonso.

Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1720919 is a reply to message #1720905] Thu, 21 January 2016 19:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
dependencies {
	mwe2 "org.eclipse.emf:org.eclipse.emf.mwe2.launch:2.8.3"
	mwe2 "org.eclipse.xtext:org.eclipse.xtext.xtext.generator:${xtextVersion}"
	mwe2 "org.eclipse.xtext:org.eclipse.xtext.generator:${xtextVersion}"
	mwe2 "org.eclipse.xtext:org.eclipse.xtext.xtext:${xtextVersion}"
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1720921 is a reply to message #1720919] Thu, 21 January 2016 20:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
p.s:

of course you have to add dependendes to your "existing metamodel project" as well and/or add it the gradle build


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1720923 is a reply to message #1720921] Thu, 21 January 2016 20:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
p.p.s can you file another bug please

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1720982 is a reply to message #1720923] Fri, 22 January 2016 09:41 Go to previous messageGo to next message
Alfonso de la Vega is currently offline Alfonso de la VegaFriend
Messages: 18
Registered: January 2016
Junior Member
Hello Christian,

Thank you for your quick response.

I have generated the following bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=486323

As it is explained there, the inclusion of the dependencies you mentioned solved my initial problem, but now I have problems with the dependencies to my "existing metamodel project" as you mentioned:

219 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher - Problems running workflow org.xtext.example.mydsl.GenerateMyDsl: java.io.IOException: The path '/metamodel/Entity.genmodel' is unmapped

Dependencies to this project appear in the MANIFEST.MF file, but it seems that is not enough for gradle to be aware of them.

As I am new to Gradle/Maven Tycho, I cannot figure out a way to make this work. Any suggestions?

Again thank you very much for your help.
Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1720985 is a reply to message #1720982] Fri, 22 January 2016 09:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
did you build a jar containing the model/generated stuff, and the classes of the existing metamodel and addded it to the path of the mwe and runtime of the dsl project (in build.gradle)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 22 January 2016 10:05]

Report message to a moderator

Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1721011 is a reply to message #1720982] Fri, 22 January 2016 14:51 Go to previous messageGo to next message
Miro Spönemann is currently offline Miro SpönemannFriend
Messages: 78
Registered: March 2015
Location: Kiel, Germany
Member

Alfonso de la Vega wrote on Fri, 22 January 2016 09:41

...now I have problems with the dependencies to my "existing metamodel project" as you mentioned:

219 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher - Problems running workflow org.xtext.example.mydsl.GenerateMyDsl: java.io.IOException: The path '/metamodel/Entity.genmodel' is unmapped

Dependencies to this project appear in the MANIFEST.MF file, but it seems that is not enough for gradle to be aware of them.


The Gradle build generated by the Xtext project wizard can be used as a starting point, but of course it cannot automatically detect the structure of your other projects and integrate with that. You will have to set up the Gradle build yourself in such a case. A quick first step could be the following.

  • Move the existing metamodel project into the parent project generated by the wizard and add it to the settings.gradle
  • Set up a basic build.gradle in the metamodel project:
    dependencies {
    	compile "org.eclipse.xtext:org.eclipse.xtext:${xtextVersion}"
    }

    (actually a dependency to EMF would be enough, but that would not work with the existing setup of the Gradle project)
  • Add dependencies to the metamodel project in the dsl runtime project.
Re: Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment' [message #1721023 is a reply to message #1721011] Fri, 22 January 2016 16:15 Go to previous message
Alfonso de la Vega is currently offline Alfonso de la VegaFriend
Messages: 18
Registered: January 2016
Junior Member
Thank you very much for your responses.

I finally managed to get it running.
Previous Topic:Using parser fragments with imported metamodel
Next Topic:problems with formatter2 in Xtext 2.9
Goto Forum:
  


Current Time: Sun Sep 22 12:48:43 GMT 2024

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

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

Back to the top