Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Couldn't resolve reference to EPackage
Couldn't resolve reference to EPackage [message #650571] Tue, 25 January 2011 14:50 Go to next message
Rafael Angarita is currently offline Rafael AngaritaFriend
Messages: 94
Registered: November 2010
Member
Hello everybody,

I have a Xtext project with several languages and many cross-references among them. Recently, I removed the src-gen folder from the SVN and of course, the .ecore files with it. The reason for it, is that I woud not like to version any generated code.

Now I can't run the workflow unless I comment the cross-references and generate the .ecore files again. I have read post related to this issue but it is not clear to me.

This is the exception showed when I try to run the workflow of my example:

940  [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems instantiating module org.xtext.example.test.MyDslB: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: Problems instantiating module org.xtext.example.test.MyDslB: java.lang.reflect.InvocationTargetException
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:73)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
Caused by: org.eclipse.emf.common.util.WrappedException: java.lang.reflect.InvocationTargetException
	at org.eclipse.emf.mwe2.language.factory.SettingProviderImpl$1$1.setValue(SettingProviderImpl.java:56)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalApplyAssignments(Mwe2ExecutionEngine.java:127)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.inCase(Mwe2ExecutionEngine.java:102)
	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:272)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalSwitch(Mwe2ExecutionEngine.java:56)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalApplyAssignments(Mwe2ExecutionEngine.java:126)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.inCase(Mwe2ExecutionEngine.java:102)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:272)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalSwitch(Mwe2ExecutionEngine.java:56)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalApplyAssignments(Mwe2ExecutionEngine.java:126)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.inCase(Mwe2ExecutionEngine.java:102)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:272)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalSwitch(Mwe2ExecutionEngine.java:56)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.inCase(Mwe2ExecutionEngine.java:69)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:272)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalSwitch(Mwe2ExecutionEngine.java:56)
	at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.create(Mwe2ExecutionEngine.java:52)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:71)
	... 3 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.eclipse.emf.mwe2.language.factory.SettingProviderImpl$1$1.setValue(SettingProviderImpl.java:54)
	... 35 more
Caused by: java.lang.IllegalStateException: Problem parsing 'classpath:/org/xtext/example/test/MyDslB.xtext':[XtextLinkingDiagnostic: null:2 Couldn't resolve reference to EPackage 'platform:/resource/org.xtext.example.test/src-gen/org/xtext/example/test/MyDslA.ecore'., XtextLinkingDiagnostic: null:23 Couldn't resolve reference to EClassifier 'Domain'., TransformationDiagnostic: null:23 Cannot find type for '[mydsla::Domain]'. (ErrorCode: NoSuchTypeAvailable)]
	at org.eclipse.xtext.generator.LanguageConfig.setUri(LanguageConfig.java:112)
	... 40 more



the workflow:

module org.xtext.example.test.MyDslB

import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*

var grammarURI = "classpath:/org/xtext/example/test/MyDslB.xtext"
var file.extensions = "mydslB"
var projectName = "org.xtext.example.test"
var runtimeProject = "../${projectName}"

Workflow {
    bean = StandaloneSetup {
		platformUri = "${runtimeProject}/.."
	}

	component = DirectoryCleaner {
		directory = "${runtimeProject}/src-gen"
	}

	component = DirectoryCleaner {
		directory = "${runtimeProject}.ui/src-gen"
	}

	component = Generator {
		pathRtProject = runtimeProject
		pathUiProject = "${runtimeProject}.ui"
		projectNameRt = projectName
		projectNameUi = "${projectName}.ui"
		
		language = {
			uri = "classpath:/org/xtext/example/test/MyDslA.xtext"
			fileExtensions = "mydslA"

			// Java API to access grammar elements (required by several other fragments)
			fragment = grammarAccess.GrammarAccessFragment {}

			// generates Java API for the generated EPackages 
			fragment = ecore.EcoreGeneratorFragment {
			// referencedGenModels = "uri to genmodel, uri to next genmodel"
			}

			// the serialization component
			fragment = parseTreeConstructor.ParseTreeConstructorFragment {}

			// a custom ResourceFactory for use with EMF 
			fragment = resourceFactory.ResourceFactoryFragment {
				fileExtensions = "mydslA"
			}

			// The antlr parser generator fragment.
			fragment = parser.antlr.XtextAntlrGeneratorFragment {
			//  options = {
			//		backtrack = true
			//	}
			}

			// java-based API for validation 
			fragment = validation.JavaValidatorFragment {
				composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
				composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
				// registerForImportedPackages = true
			}

			// scoping and exporting API
			// fragment = scoping.ImportURIScopingFragment {}
			 fragment = exporting.SimpleNamesFragment {}

			// scoping and exporting API 
			fragment = scoping.ImportNamespacesScopingFragment {}
			//fragment = exporting.QualifiedNamesFragment {}
			fragment = builder.BuilderIntegrationFragment {}

			// formatter API 
			fragment = formatting.FormatterFragment {}

			// labeling API 
			fragment = labeling.LabelProviderFragment {}

			// outline API 
			fragment = outline.TransformerFragment {}
			fragment = outline.OutlineNodeAdapterFactoryFragment {}
			fragment = outline.QuickOutlineFragment {}

			// quickfix API 
			fragment = quickfix.QuickfixProviderFragment {}

			// content assist API  
			fragment = contentAssist.JavaBasedContentAssistFragment {}

			// generates a more lightweight Antlr parser and lexer tailored for content assist  
			fragment = parser.antlr.XtextAntlrUiGeneratorFragment {}

			// project wizard (optional) 
			// fragment = projectWizard.SimpleProjectWizardFragment {
			// 		generatorProjectName = "${projectName}.generator" 
			//		modelFileExtension = file.extensions
			// }
		}
		
		language = {
			uri = grammarURI
			fileExtensions = file.extensions

			// Java API to access grammar elements (required by several other fragments)
			fragment = grammarAccess.GrammarAccessFragment {}

			// generates Java API for the generated EPackages 
			fragment = ecore.EcoreGeneratorFragment {
				referencedGenModels = "platform:/resource/org.xtext.example.test/src-gen/org/xtext/example/test/MyDslA.genmodel"
			}

			// the serialization component
			fragment = parseTreeConstructor.ParseTreeConstructorFragment {}

			// a custom ResourceFactory for use with EMF 
			fragment = resourceFactory.ResourceFactoryFragment {
				fileExtensions = file.extensions
			}

			// The antlr parser generator fragment.
			fragment = parser.antlr.XtextAntlrGeneratorFragment {
			//  options = {
			//		backtrack = true
			//	}
			}

			// java-based API for validation 
			fragment = validation.JavaValidatorFragment {
				composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
				composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
				// registerForImportedPackages = true
			}

			// scoping and exporting API
			// fragment = scoping.ImportURIScopingFragment {}
			 fragment = exporting.SimpleNamesFragment {}

			// scoping and exporting API 
			fragment = scoping.ImportNamespacesScopingFragment {}
			//fragment = exporting.QualifiedNamesFragment {}
			fragment = builder.BuilderIntegrationFragment {}

			// formatter API 
			fragment = formatting.FormatterFragment {}

			// labeling API 
			fragment = labeling.LabelProviderFragment {}

			// outline API 
			fragment = outline.TransformerFragment {}
			fragment = outline.OutlineNodeAdapterFactoryFragment {}
			fragment = outline.QuickOutlineFragment {}

			// quickfix API 
			fragment = quickfix.QuickfixProviderFragment {}

			// content assist API  
			fragment = contentAssist.JavaBasedContentAssistFragment {}

			// generates a more lightweight Antlr parser and lexer tailored for content assist  
			fragment = parser.antlr.XtextAntlrUiGeneratorFragment {}

			// project wizard (optional) 
			// fragment = projectWizard.SimpleProjectWizardFragment {
			// 		generatorProjectName = "${projectName}.generator" 
			//		modelFileExtension = file.extensions
			// }
		}
	}
}



and the grammars:

grammar org.xtext.example.test.MyDslA with org.eclipse.xtext.common.Terminals

generate myDslA "http://www.xtext.org/example/test/MyDslA"


Domain:
	'Name' ':' name=ID
;





grammar org.xtext.example.test.MyDslB with org.eclipse.xtext.common.Terminals
import "platform:/resource/org.xtext.example.test/src-gen/org/xtext/example/test/MyDslA.ecore" as mydsla
generate myDslB "http://www.xtext.org/example/test/MyDslB"


Attribute:
	'Name' ':' name=ID
	'Domain : ' (domainA+=DomainA)+
	'DataType' ':' datatype=DataType
	'DomainFromA : ' domainFromA=DomainFromA
;


DataType:
	domain=[DomainA]
	;
DomainA:
	name=ID
;

DomainFromA:
	domain=[mydsla::Domain]
;


Thank you very much for your help.

Re: Couldn't resolve reference to EPackage [message #650639 is a reply to message #650571] Tue, 25 January 2011 19:26 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

just a stab in the dark... Would it help to split the Generator component into two, so that the code for MydslA gets generated before the grammar file for MydslB gets parsed?

Alex
Re: Couldn't resolve reference to EPackage [message #1146515 is a reply to message #650639] Sun, 20 October 2013 07:36 Go to previous message
Hirdesh Agrawal is currently offline Hirdesh AgrawalFriend
Messages: 13
Registered: October 2013
Junior Member
Dear All,

I need your favor or suggestion regarding migrate the xtext version from 1.0.1 to 2.3.0 in custom application.

I followed all following process for migrate the xtext version.
1. Delete the old plug-ins and update the latest plug-ins in target platform.
2. Update the Plug-in Dependencies and Import Statements.
3. Introduction of the Qualified Name.
4. Changes in the index and in find references.
5. Rewritten Node Model.
6. AutoEditStrategy.
7. Other Noteworthy API Changes
To consider the above steps, I started the work with Eclipse-4.2, Which has a xtext-2.3.0 dependency. Successfully I completed the all above steps and removed the compilation error.

Problem: After that I start the testing and getting below error Messages:
[XtextLinkingDiagnostic: null:6 Couldn't resolve reference to Material 'MPS_RECUR'.,
XtextLinkingDiagnostic: null:9 Couldn't resolve reference to Cstic 'NUM_OF_ALLOC'.,
XtextLinkingDiagnostic: null:15 Couldn't resolve reference to Cstic 'INSTANCE_NUM'.,
XtextLinkingDiagnostic: null:14 Couldn't resolve reference to Class 'ALLOC'.]
Previous Topic:Infix scoping issue
Next Topic:Migration of Xtext1.0 to Xtext2.3, Methods not found
Goto Forum:
  


Current Time: Sat Dec 05 01:08:09 GMT 2020

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

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

Back to the top