[Xtext] NPE in ResourceDescriptionsProvider.createResourceDescriptions() after update to 2.9 / 2.10 [message #1736133] |
Mon, 27 June 2016 00:22 |
Torsten Juergeleit Messages: 18 Registered: July 2009 |
Junior Member |
|
|
I'm trying to update a standalone generator (using ImportURIScopingFragment and SimpleNamesFragment) from Xtext version 2.8.4 to 2.9.2 or 2.10.0.
Without any modifications other than changing the Xtext version in Maven POM and target definition I'm ending up with NPEs while loading / validating models with imports, e.g.
org.eclipse.emf.common.util.WrappedException: java.lang.NullPointerException
at org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider.createResourceDescriptions(ResourceDescriptionsProvider.java:159)
at org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider.getResourceDescriptions(ResourceDescriptionsProvider.java:113)
at org.eclipse.xtext.scoping.impl.AbstractGlobalScopeProvider.getResourceDescriptions(AbstractGlobalScopeProvider.java:37)
at org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider.getResourceDescriptions(ImportUriGlobalScopeProvider.java:66)
at org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider.getScope(ImportUriGlobalScopeProvider.java:75)
at org.eclipse.xtext.scoping.impl.AbstractGlobalScopeProvider.getScope(AbstractGlobalScopeProvider.java:50)
at org.eclipse.xtext.scoping.impl.AbstractGlobalScopeDelegatingScopeProvider.getGlobalScope(AbstractGlobalScopeDelegatingScopeProvider.java:46)
at org.eclipse.xtext.scoping.impl.AbstractGlobalScopeDelegatingScopeProvider.getGlobalScope(AbstractGlobalScopeDelegatingScopeProvider.java:42)
at org.eclipse.xtext.scoping.impl.SimpleLocalScopeProvider.getScope(SimpleLocalScopeProvider.java:62)
at org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.delegateGetScope(AbstractDeclarativeScopeProvider.java:72)
at org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.getScope(AbstractDeclarativeScopeProvider.java:104)
at org.eclipse.xtext.linking.impl.DefaultLinkingService.getScope(DefaultLinkingService.java:59)
at org.eclipse.xtext.linking.impl.DefaultLinkingService.getLinkedObjects(DefaultLinkingService.java:119)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:247)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:222)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doResolveLazyCrossReference(LazyLinkingResource.java:189)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReference(LazyLinkingResource.java:148)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReferences(LazyLinkingResource.java:134)
at org.eclipse.xtext.EcoreUtil2.resolveLazyCrossReferences(EcoreUtil2.java:498)
at org.eclipse.xtext.validation.ResourceValidatorImpl.resolveProxies(ResourceValidatorImpl.java:161)
at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:74)
at org.sculptor.generator.workflow.SculptorGeneratorWorkflow$2.apply(SculptorGeneratorWorkflow.java:229)
at org.sculptor.generator.workflow.SculptorGeneratorWorkflow$2.apply(SculptorGeneratorWorkflow.java:219)
at org.eclipse.xtext.xbase.lib.IteratorExtensions.forall(IteratorExtensions.java:278)
at org.eclipse.xtext.xbase.lib.IterableExtensions.forall(IterableExtensions.java:237)
at org.sculptor.generator.workflow.SculptorGeneratorWorkflow.validateResources(SculptorGeneratorWorkflow.java:281)
at org.sculptor.generator.workflow.SculptorGeneratorWorkflow.run(SculptorGeneratorWorkflow.java:108)
at org.sculptor.generator.SculptorGeneratorRunner.run(SculptorGeneratorRunner.java:50)
Here it seems that in ResourceDescriptionsProvider
result = ChunkedResourceDescriptions.findInEmfObject(resourceSet);
if (result == null) {
result = createResourceDescriptions();
}
no result was return from findInEmfObject() and no IResourceDescriptions instance was injected in
@Inject(optional = true)
private Provider<IResourceDescriptions> resourceDescriptions;
Now I'm wondering which changes are necessary to update from the global scope implementation of Xtext 2.8 to the one of version 2.9.
/Torsten
[Updated on: Mon, 27 June 2016 00:27] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
Re: [Xtext] NPE in ResourceDescriptionsProvider.createResourceDescriptions() after update to 2.9 / 2 [message #1736298 is a reply to message #1736260] |
Tue, 28 June 2016 10:15 |
Torsten Juergeleit Messages: 18 Registered: July 2009 |
Junior Member |
|
|
Christian Dietrich wrote on Tue, 28 June 2016 03:24I am not sure what your child injector intends but why not Module.overrides(...)
The parent injector provides the configuration subsystem needed for newing a module which is used to initialize the child injector.
Ok, I dropped the idea of reusing an already initialized configuration in a child injector and refactored the injector setup as follows:
public class SculptorGeneratorSetup extends SculptordslStandaloneSetup {
@Override
public Injector createInjector() {
ConfigurationProvider configurationProvider = Guice.createInjector(new ConfigurationProviderModule()).getInstance(ConfigurationProvider.class);
try {
return Guice.createInjector(new ConfigurationProviderModule(), new SculptordslRuntimeModule(),
new ChainOverrideAwareModule(configurationProvider, DslTransformation.class, Transformation.class,
Class.forName("org.sculptor.generator.template.RootTmpl")));
} catch (ClassNotFoundException e) {
throw new RuntimeException("Emergency - 'RootTmpl' not available on classpath");
}
}
}
Now the configuration subsystem is instantiated twice. But without using a child injector the binding of Xtext 2.9+ works
Next I reintroduced the child injector as follows:
public class SculptorGeneratorSetup extends SculptordslStandaloneSetup {
@Override
public Injector createInjector() {
ConfigurationProvider configurationProvider = Guice.createInjector(new ConfigurationProviderModule()).getInstance(ConfigurationProvider.class);
try {
return Guice.createInjector().createChildInjector(new ConfigurationProviderModule(), new SculptordslRuntimeModule(),
new ChainOverrideAwareModule(configurationProvider, DslTransformation.class, Transformation.class,
Class.forName("org.sculptor.generator.template.RootTmpl")));
} catch (ClassNotFoundException e) {
throw new RuntimeException("Emergency - 'RootTmpl' not available on classpath");
}
}
}
Now the NPE due to unbound IResourceDescriptions is back again
So it seems that the inner workings of Xtext 2.9+ have been changed with regards to Guice interceptor handling. Maybe Xtext is internally using interceptor injection now.
I'll check this with Xtext 2.8.
/Torsten
|
|
|
Powered by
FUDForum. Page generated in 0.04626 seconds