Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » EObjectDescription could be found in Scope during serialization in an osgi environnement(EObjectDescription could be found in Scope during serialization in an osgi environnement)
EObjectDescription could be found in Scope during serialization in an osgi environnement [message #880182] Fri, 01 June 2012 15:10 Go to next message
CRASNIER Stéphane is currently offline CRASNIER StéphaneFriend
Messages: 13
Registered: May 2012
Junior Member
Hi all !

I have the following exception "java.lang.RuntimeException: No EObjectDescription could be found in Scope" when I try to serialize a programmatically created model in an eclipse plugin (i.e. : osgi environnement).

The stacktrace can be found at the end of this message.

The IResourceSetProvider is injected in an handler through the ExecutableExtensionFactory of my language, an extension point being declared like that :
<extension
         point="org.eclipse.ui.handlers">
      <handler class="mylanguage.ui.MyLanguageExecutableExtensionFactory:mylanguage.serializer.handler.MyHandler"
            commandId="mylanguage.ui.MyCommand">


This handler is part of my xtext ui plugin. The model is serialized by another plugin. The IResourceSetProvider is a parameter of the called method. The ResourSet is used to create the resource and get the existing resources referenced by this new resource :
ResourceSet resourceSet = provider.get(project);

for (int i = 0; i < graphe.getUses().getUse().size(); i++) {
    // Load the referenced resources.
    Resource res = resourceSet.getResource(modeleUriAux, true);
						// res.load(null);
}	
// Serialize the resource.
resource = resourceSet.createResource(modeleUri);
resource.getContents().add(graphe);
resource.save(Collections.EMPTY_MAP);


BTW, the modeleURI is a file based URI (i.e. : a path like file://).

Do you have any idea why the reference cannot be found please ?

Thank you very much in advance !

Stéphane

PS :

The stacktrace is :
java.lang.RuntimeException: No EObjectDescription could be found in Scope [...]
Semantic Object: [...]
at org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic$ExceptionThrowingAcceptor.accept(ISerializationDiagnostic.java:70)
	at org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer.getCrossReferenceNameFromScope(CrossReferenceSerializer.java:143)
	at org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer.serializeCrossRef(CrossReferenceSerializer.java:116)
	at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.getToken(SequenceFeeder.java:448)
	at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:214)
	at ...
Re: EObjectDescription could be found in Scope during serialization in an osgi environnement [message #880329 is a reply to message #880182] Fri, 01 June 2012 21:31 Go to previous messageGo to next message
Moritz Eysholdt is currently offline Moritz EysholdtFriend
Messages: 161
Registered: July 2009
Location: Kiel, Germany
Senior Member
this means that in your programmatically created model there is a cross reference pointing to some object for which the scope created by your scopepreovider does not provide a name.

I.e. the serializer doesn't know which name to serializer for that cross reference.

hth,
Moritz
Re: EObjectDescription could be found in Scope during serialization in an osgi environnement [message #880481 is a reply to message #880329] Sat, 02 June 2012 05:05 Go to previous messageGo to next message
CRASNIER Stéphane is currently offline CRASNIER StéphaneFriend
Messages: 13
Registered: May 2012
Junior Member
Thanks for your reply Moritz !

I think you're right and I come to the same conclusion but I don't understand why.

Moreover, I've forgotten 2 things :
1 - In a standalone environnement, all is all right and well serialized, initializing the environnement trough the MyLanguageStandaloneSetup().createInjectorAndDoEMFRegistration(). That's why I think there is certainly something wrong with my "OSGI initialization"
2 - Debugging, I realize that in the ImportScope class, the importScope attribute is null so that an empty scope is created in the getImportFrom() method, having no element inside. It seems that in the IScope getLocalElementsScope(IScope parent, final EObject context, final EReference reference) method of the ImportedNamespaceAwareLocalScopeProvider, the bold marked instruction is called to create this import scope (line 180) with the null importscope parameter :
	protected IScope getLocalElementsScope(IScope parent, final EObject context,
			final EReference reference) {
		IScope result = parent;
		ISelectable allDescriptions = getAllDescriptions(context.eResource());
		QualifiedName name = getQualifiedNameOfLocalElement(context);
		boolean ignoreCase = isIgnoreCase(reference);
		final List<ImportNormalizer> namespaceResolvers = getImportedNamespaceResolvers(context, ignoreCase);
		if (!namespaceResolvers.isEmpty()) {
			if (isRelativeImport() && name!=null) {
				ImportNormalizer localNormalizer = new ImportNormalizer(name, true, ignoreCase); 
				result = createImportScope(result, singletonList(localNormalizer), allDescriptions, reference.getEReferenceType(), isIgnoreCase(reference));
			}
[b]			result = createImportScope(result, namespaceResolvers, null, reference.getEReferenceType(), isIgnoreCase(reference));
[/b]		}
		if (name!=null) {
			ImportNormalizer localNormalizer = new ImportNormalizer(name, true, ignoreCase); 
			result = createImportScope(result, singletonList(localNormalizer), allDescriptions, reference.getEReferenceType(), isIgnoreCase(reference));
		}
		return result;
	}

Here, I'm beginning to get lost:) It means that the name is null as I provide my own namespaceResolvers with my scope provider. The name is retrieved through getQualifiedNameOfLocalElement(context). I'm digging in this direction and in my custom scope provider direction (which just overrides getImportedNamespaceResolvers to add the needed namespaceresolvers) but I feel that it's the wrong way...

So I hope to be more precise with these elements. If you have any other clue, it would be great !

Thanks again Moritz !

Stéphane
Re: EObjectDescription could be found in Scope during serialization in an osgi environnement [message #1065555 is a reply to message #880481] Wed, 26 June 2013 13:31 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi all,

I try below code but not defined singletonList.I added jaxen jar file.Do I create method ? I do not understand:(Sad


CRASNIER Stéphane wrote on Sat, 02 June 2012 01:05
Thanks for your reply Moritz !

I think you're right and I come to the same conclusion but I don't understand why.

Moreover, I've forgotten 2 things :
1 - In a standalone environnement, all is all right and well serialized, initializing the environnement trough the MyLanguageStandaloneSetup().createInjectorAndDoEMFRegistration(). That's why I think there is certainly something wrong with my "OSGI initialization"
2 - Debugging, I realize that in the ImportScope class, the importScope attribute is null so that an empty scope is created in the getImportFrom() method, having no element inside. It seems that in the IScope getLocalElementsScope(IScope parent, final EObject context, final EReference reference) method of the ImportedNamespaceAwareLocalScopeProvider, the bold marked instruction is called to create this import scope (line 180) with the null importscope parameter :
	protected IScope getLocalElementsScope(IScope parent, final EObject context,
			final EReference reference) {
		IScope result = parent;
		ISelectable allDescriptions = getAllDescriptions(context.eResource());
		QualifiedName name = getQualifiedNameOfLocalElement(context);
		boolean ignoreCase = isIgnoreCase(reference);
		final List<ImportNormalizer> namespaceResolvers = getImportedNamespaceResolvers(context, ignoreCase);
		if (!namespaceResolvers.isEmpty()) {
			if (isRelativeImport() && name!=null) {
				ImportNormalizer localNormalizer = new ImportNormalizer(name, true, ignoreCase); 
				result = createImportScope(result, singletonList(localNormalizer), allDescriptions, reference.getEReferenceType(), isIgnoreCase(reference));
			}
[b]			result = createImportScope(result, namespaceResolvers, null, reference.getEReferenceType(), isIgnoreCase(reference));
[/b]		}
		if (name!=null) {
			ImportNormalizer localNormalizer = new ImportNormalizer(name, true, ignoreCase); 
			result = createImportScope(result, singletonList(localNormalizer), allDescriptions, reference.getEReferenceType(), isIgnoreCase(reference));
		}
		return result;
	}

Here, I'm beginning to get lost:) It means that the name is null as I provide my own namespaceResolvers with my scope provider. The name is retrieved through getQualifiedNameOfLocalElement(context). I'm digging in this direction and in my custom scope provider direction (which just overrides getImportedNamespaceResolvers to add the needed namespaceresolvers) but I feel that it's the wrong way...

So I hope to be more precise with these elements. If you have any other clue, it would be great !

Thanks again Moritz !

Stéphane
Re: EObjectDescription could be found in Scope during serialization in an osgi environnement [message #1266411 is a reply to message #880481] Fri, 07 March 2014 12:11 Go to previous message
Yann Thierry-Mieg is currently offline Yann Thierry-MiegFriend
Messages: 3
Registered: March 2014
Junior Member
Hi all,

Since I've encountered this error as well here is how I solved it in my case.

In fact the problem was that the scope provider I wrote was not getting invoked in a Guice aware serialization (Exactly like the OP describes). This was in fact due to use of XBase, its generator fragment contributes a SerializerScopeProvider that could be different (why ??) from the normal IScopeProvider registered through "bind" method of the RuntimeModule.

Solution is to add the following to overload this behavior in my MyDSLRuntimeModule :

@Override
public Class<? extends IScopeProvider> bindIScopeProvider() {
return MyDSLScopeProvider.class;
}

@Override
public void configureSerializerIScopeProvider(Binder binder) {
binder.bind(org.eclipse.xtext.scoping.IScopeProvider.class).annotatedWith(org.eclipse.xtext.serializer.tokens.SerializerScopeProviderBinding.class).to(MyDSLScopeProvider.class);
}

The bindIScopeProvider is normal and expected, but the configureSerializerIScopeProvider was really difficult to track down.
My advice is to avoid XBase altogether if you can, the XBaseGeneratorFragment is kind of bloated and induces too many side effects to count. Since the documentation is, well, what it is, and that XBase varies a lot from release to realease it's hard to build stable code with it.

gl&hf

Yann

Previous Topic:How to dynamically create instance without "dangling reference"?
Next Topic:Serialization in xtext
Goto Forum:
  


Current Time: Thu Mar 28 15:39:46 GMT 2024

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

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

Back to the top