Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Is there a workaround for using Guice 4.x with Xtext 2.21 ?(gradle project trying to move to guice 4 fails)
Is there a workaround for using Guice 4.x with Xtext 2.21 ? [message #1833058] Thu, 01 October 2020 09:51 Go to next message
Eclipse UserFriend
Hello Xtexters,

currently xtext does not come with guice 4 but 3 which is incompatible with java 8. So error messages are very hard to debug (sometimes next to impossible in a sufficiently big enough code-base).

Is there any configuration or workaround so that I can get meaningful error messages in the eclipse console other than

Exception: com.google.inject.internal.util.$ComputationException thrown from the UncaughtExceptionHandler in thread "main"


?

I tried to include guice 4 as a compile dependency into my gradle subprojects, but this resulted in errors I could not resolve.

Regards,
Jan Hermes

[Updated on: Thu, 01 October 2020 09:51] by Moderator

Re: Is there a workaround for using Guice 4.x with Xtext 2.21 ? [message #1833060 is a reply to message #1833058] Thu, 01 October 2020 10:38 Go to previous messageGo to next message
Eclipse UserFriend
hi, what do you mean by "i could not resolve"
Re: Is there a workaround for using Guice 4.x with Xtext 2.21 ? [message #1833061 is a reply to message #1833060] Thu, 01 October 2020 11:03 Go to previous messageGo to next message
Eclipse UserFriend
I should have just included the errors here, but I thought the whole setup was so messed up that I considered it to be unhelpful.

So what I did was trying to put the guice dependency into the build.gradle file for the subprojects:

configure(subprojects.findAll { it.name.startsWith('de.fraunhofer') }) {

	ext.xtextVersion = '2.21.0'
	repositories {
		maven {
			url 'https://oss.sonatype.org/content/repositories/snapshots'
		}
		jcenter()
	}
	
	apply plugin: 'java'
	dependencies {
		compile platform("org.eclipse.xtext:xtext-dev-bom:${xtextVersion}")
		// here I added guice 4
		compile platform('com.google.inject:guice:4.2.3')
		compile platform("com.google.inject.extensions:guice-assistedinject:4.2.3")
	}

       // and so on ....


After this modification I get an exception:

Starting with a lot of exceptions similar to this:

Caused by: java.lang.NoClassDefFoundError: com/google/inject/internal/util/$Maps
	at com.google.inject.assistedinject.BindingCollector.<init>(BindingCollector.java:34)
	at com.google.inject.assistedinject.FactoryModuleBuilder.<init>(FactoryModuleBuilder.java:206)
	at de.fraunhofer.iosb.pslp.PslpRuntimeModule.configureLibraryAccessFactory(PslpRuntimeModule.java:84)


Followed by this topic exception:

Exception in thread "main" com.google.inject.ProvisionException: Unable to provision, see the following errors:


Followed by a bunch of

1) No implementation for org.example.mydsl.FooComponent was bound.


The base-setup I'm using for my project is your/itemis' language server example from here:
xtext-languageserver-example
Re: Is there a workaround for using Guice 4.x with Xtext 2.21 ? [message #1833062 is a reply to message #1833061] Thu, 01 October 2020 11:09 Go to previous message
Eclipse UserFriend
Ok I think found my mistake, sorry for taking your time :)

Somewhere in my gradle dependencies there was still a statement including guice extensions with the wrong version:
compile platform("com.google.inject.extensions:guice-assistedinject:3.0")

I updated this to 4.2.3 and away are the cryptic error messages.

Sometimes when you ask something, you try to document what you did that produced the error, and in the process of documenting alone you find the mistake. :D
Previous Topic:Xtext Or jetbrains MPS Which one should i use?
Next Topic:Why is MyDslFactory.eINSTANCE the common way to get a factory?
Goto Forum:
  


Current Time: Sun Jul 06 14:35:35 EDT 2025

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

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

Back to the top