Skip to main content



      Home
Home » Modeling » TMF (Xtext) » NoClassDefFoundError for INameEnvironment
NoClassDefFoundError for INameEnvironment [message #1719325] Thu, 07 January 2016 04:14 Go to next message
Eclipse UserFriend
I have encountered a NoClasDefFound error for org.eclipse.jdt.internal.compiler.env.INameEnviroment when trying to test compilation in an XBase project. Interestingly, when the error prints, it uses forward slashes, not periods in the qualified class name. Not sure if that has something to do with the issue.

I can replicate it with the "default" hello world project which is set up with a new XText project.

Here, all I've done is extended Xbase in my grammar:

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.xbase.Xbase


and instated the simple example jvmModelInferrer that comes commented out:

	def dispatch void infer(Model element, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {
		// Here you explain how your model is mapped to Java elements, by writing the actual translation code.
		
	     // An implementation for the initial hello world example could look like this:
   		acceptor.accept(element.toClass("my.company.greeting.MyGreetings")) [
   			for (greeting : element.greetings) {
   				members += greeting.toMethod("hello" + greeting.name, typeRef(String)) [
   					body = '''
							return "Hello «greeting.name»";
   					'''
   				]
   			}
   		]
	}


I then implemented this shell of a compiler test:
@RunWith(XtextRunner)
@InjectWith(MyDslInjectorProvider)
class MyDslCompilerTest {

	@Inject public TemporaryFolder temporaryFolder 
	@Inject extension CompilationTestHelper
	
	@Test
	def void testBasicCompilation() {
		'''
			Hello Xtext!
		'''.compile []
	}
}


When I run this test, I get the following error. Thanks for any guidance!


com.google.inject.ProvisionException: Guice provision errors:

1) Error injecting constructor, java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/compiler/env/INameEnvironment
  at org.eclipse.xtext.xbase.compiler.OnTheFlyJavaCompiler2.<init>(Unknown Source)
  at org.eclipse.xtext.xbase.compiler.OnTheFlyJavaCompiler2.class(Unknown Source)
  while locating org.eclipse.xtext.xbase.compiler.OnTheFlyJavaCompiler2
    for field at org.eclipse.xtext.xbase.compiler.CompilationTestHelper.javaCompiler(Unknown Source)
  while locating org.eclipse.xtext.xbase.compiler.CompilationTestHelper
    for field at org.xtext.example.mydsl.tests.MyDslCompilerTest._compilationTestHelper(Unknown Source)
  while locating org.xtext.example.mydsl.tests.MyDslCompilerTest

1 error
	at com.google.inject.internal.Errors.throwProvisionExceptionIfErrorsExist(Errors.java:451)
	at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:65)
	at com.google.inject.internal.InjectorImpl.injectMembers(InjectorImpl.java:944)
	at org.eclipse.xtext.junit4.XtextRunner.createTest(XtextRunner.java:33)
	at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
	at org.eclipse.xtext.junit4.XtextRunner.superMethodBlock(XtextRunner.java:64)
	at org.eclipse.xtext.junit4.XtextRunner.methodBlock(XtextRunner.java:44)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/compiler/env/INameEnvironment
	at org.eclipse.xtext.xbase.compiler.OnTheFlyJavaCompiler2.<init>(OnTheFlyJavaCompiler2.java:40)
	at org.eclipse.xtext.xbase.compiler.OnTheFlyJavaCompiler2.<init>(OnTheFlyJavaCompiler2.java:36)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
	at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:85)
	at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
	at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
	at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
	at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
	at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
	at com.google.inject.Scopes$1$1.get(Scopes.java:65)
	at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
	at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:53)
	at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:110)
	at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:94)
	at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
	at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:53)
	at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:110)
	at com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:75)
	at com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:73)
	at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024)
	at com.google.inject.internal.MembersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:73)
	at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:60)
	... 21 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.jdt.internal.compiler.env.INameEnvironment
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 46 more




Re: NoClassDefFoundError for INameEnvironment [message #1719334 is a reply to message #1719325] Thu, 07 January 2016 05:35 Go to previous messageGo to next message
Eclipse UserFriend
did you add a dependency to jdt.core?
Re: NoClassDefFoundError for INameEnvironment [message #1719409 is a reply to message #1719334] Thu, 07 January 2016 12:18 Go to previous messageGo to next message
Eclipse UserFriend
Ok, I clearly need to get in the mindset of dependency injection.

Thanks again Smile

Out of curiosity, how would I have traced up from that missing class to determine I needed to depend on jdt.core specifically?
Re: NoClassDefFoundError for INameEnvironment [message #1719464 is a reply to message #1719409] Fri, 08 January 2016 03:34 Go to previous message
Eclipse UserFriend
@Larry how would I have traced up from that missing class to determine I needed to depend on jdt.core specifically?

just my 2 cent:
because of the: "org/eclipse/jdt/internal/..." ?
Previous Topic:Strange error message in generator plugin
Next Topic:Accessing XText project classes from the runtime eclipse
Goto Forum:
  


Current Time: Fri Jul 04 17:47:36 EDT 2025

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

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

Back to the top