Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Exception with ResourceSetBasedResourceDescriptions occurs(After parsing model open editor causes this Exception)
Exception with ResourceSetBasedResourceDescriptions occurs [message #655755] Tue, 22 February 2011 14:58 Go to next message
goerkem is currently offline goerkemFriend
Messages: 20
Registered: October 2009
Junior Member
I parse my model and saves changed information this way:

ResourceSet rs = new XtextResourceSet();
XtextResource res = null;
		
try {
res = (XtextResource) rs.getResource(URI.createFileURI("myfile"), true);
}
catch(RuntimeException rte) {...}
...
res.save(null);



Afterthere every time I open the affected file (which i saved before) I get following Exception:

2011-02-22 15:46:01,359 [Worker-11] ERROR org.eclipse.xtext.builder.impl.XtextBuilder - Passed org.eclipse.xtext.resource.IResourceDescriptions not of type org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions
java.lang.IllegalStateException: Passed org.eclipse.xtext.resource.IResourceDescriptions not of type org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions
	at org.eclipse.xtext.resource.containers.ResourceSetBasedAllContainersStateProvider.get(ResourceSetBasedAllContainersStateProvider.java:43)
	at org.eclipse.xtext.resource.containers.StateBasedContainerManager.getState(StateBasedContainerManager.java:68)
	at org.eclipse.xtext.resource.containers.StateBasedContainerManager.internalGetContainerHandle(StateBasedContainerManager.java:88)
	at org.eclipse.xtext.resource.containers.StateBasedContainerManager.getVisibleContainers(StateBasedContainerManager.java:49)
	at org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager.collectVisibleResources(DefaultResourceDescriptionManager.java:142)
	at org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager.isAffected(DefaultResourceDescriptionManager.java:120)
	at org.eclipse.xtext.builder.clustering.ClusteringUpdater.queueAffectedResourceDescriptions(ClusteringUpdater.java:188)
	at org.eclipse.xtext.builder.clustering.ClusteringUpdater.transitiveUpdate(ClusteringUpdater.java:94)
	at org.eclipse.xtext.builder.builderState.AbstractBuilderState.transitiveUpdate(AbstractBuilderState.java:158)
	at org.eclipse.xtext.builder.clustering.ClusteringBuilderState.collectResources(ClusteringBuilderState.java:79)
	at org.eclipse.xtext.builder.clustering.ClusteringBuilderState.doUpdate(ClusteringBuilderState.java:51)
	at org.eclipse.xtext.builder.builderState.AbstractBuilderState.update(AbstractBuilderState.java:108)
	at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:151)


I found out that context param is instance of CurrentDescriptions and not ResourceSetBasedResourceDescriptions as required:
public IAllContainersState get(IResourceDescriptions context) {
if (context instanceof ResourceSetBasedResourceDescriptions) {..return..}
throw new IllegalStateException...
}

How can I avoid this exception?
Re: Exception with ResourceSetBasedResourceDescriptions occurs [message #655914 is a reply to message #655755] Wed, 23 February 2011 09:30 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
I suspect you execute your code from within an Eclipse aware JVM. In
this case, you should rather use the IResourceSetProvider to instantiate
your XtextResourceSet. Note that it requires to hand in an IProject,
which is necessary to derive the org.eclipse.xtext.resource.IContainer
information for the index.

The ResourceSetBasedDescriptions should be used if you want to define
your universe of visible elements by loading resources into a resource
set, which is the default in the non Eclipse scenario.

Am 22.02.11 15:58, schrieb goerkem:
> I parse my model and saves changed information this way:
>
> ResourceSet rs = new XtextResourceSet();
> XtextResource res = null;
>
> try {
> res = (XtextResource) rs.getResource(URI.createFileURI("myfile"), true);
> }
> catch(RuntimeException rte) {...}
> ..
> res.save(null);
>
>
> Afterthere every time I open the affected file (which i saved before) I
> get following Exception:
>
> 2011-02-22 15:46:01,359 [Worker-11] ERROR
> org.eclipse.xtext.builder.impl.XtextBuilder - Passed
> org.eclipse.xtext.resource.IResourceDescriptions not of type
> org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDesc riptions
> java.lang.IllegalStateException: Passed
> org.eclipse.xtext.resource.IResourceDescriptions not of type
> org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDesc riptions
> at
> org.eclipse.xtext.resource.containers.ResourceSetBasedAllCon tainersStateProvider.get(ResourceSetBasedAllContainersStateP rovider.java:43)
>
> at
> org.eclipse.xtext.resource.containers.StateBasedContainerMan ager.getState(StateBasedContainerManager.java:68)
>
> at
> org.eclipse.xtext.resource.containers.StateBasedContainerMan ager.internalGetContainerHandle(StateBasedContainerManager.j ava:88)
>
> at
> org.eclipse.xtext.resource.containers.StateBasedContainerMan ager.getVisibleContainers(StateBasedContainerManager.java:49 )
>
> at
> org.eclipse.xtext.resource.impl.DefaultResourceDescriptionMa nager.collectVisibleResources(DefaultResourceDescriptionMana ger.java:142)
>
> at
> org.eclipse.xtext.resource.impl.DefaultResourceDescriptionMa nager.isAffected(DefaultResourceDescriptionManager.java:120)
>
> at
> org.eclipse.xtext.builder.clustering.ClusteringUpdater.queue AffectedResourceDescriptions(ClusteringUpdater.java:188)
>
> at
> org.eclipse.xtext.builder.clustering.ClusteringUpdater.trans itiveUpdate(ClusteringUpdater.java:94)
>
> at
> org.eclipse.xtext.builder.builderState.AbstractBuilderState. transitiveUpdate(AbstractBuilderState.java:158)
>
> at
> org.eclipse.xtext.builder.clustering.ClusteringBuilderState. collectResources(ClusteringBuilderState.java:79)
>
> at
> org.eclipse.xtext.builder.clustering.ClusteringBuilderState. doUpdate(ClusteringBuilderState.java:51)
>
> at
> org.eclipse.xtext.builder.builderState.AbstractBuilderState. update(AbstractBuilderState.java:108)
>
> at
> org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBui lder.java:151)
>
> I found out that context param is instance of CurrentDescriptions and
> not ResourceSetBasedResourceDescriptions as required:
>
> public IAllContainersState get(IResourceDescriptions context) {
> if (context instanceof ResourceSetBasedResourceDescriptions) {..return..}
> throw new IllegalStateException...
> }
> How can I avoid this exception?


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: Exception with ResourceSetBasedResourceDescriptions occurs [message #655927 is a reply to message #655914] Wed, 23 February 2011 10:55 Go to previous messageGo to next message
goerkem is currently offline goerkemFriend
Messages: 20
Registered: October 2009
Junior Member
so you mean i should try something like:

MyDsl.doSetup();
XtextResourceSetProvider xrstp = new XtextResourceSetProvider();
ResourceSet rs = xrstp.get(myProject);


in this case Provider<XtextResourceSet> resourceSetProvider is always null?
Re: Exception with ResourceSetBasedResourceDescriptions occurs [message #656012 is a reply to message #655927] Wed, 23 February 2011 18:06 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3109
Registered: July 2009
Senior Member
Please refer to the documentation on google guice for details but your
code should basically look like this:

@Inject
XtextResourceSetProvider provider;

void doStuff(IProject p) {
rs = provider.get(p);
..
}

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 23.02.11 11:56, schrieb goerkem:
> so you mean i should try something like:
>
>
> MyDsl.doSetup();
> XtextResourceSetProvider xrstp = new XtextResourceSetProvider();
> ResourceSet rs = xrstp.get(myProject);
>
>
> in this case Provider<XtextResourceSet> resourceSetProvider is always null?
Re: Exception with ResourceSetBasedResourceDescriptions occurs [message #656116 is a reply to message #655755] Thu, 24 February 2011 09:55 Go to previous messageGo to next message
goerkem is currently offline goerkemFriend
Messages: 20
Registered: October 2009
Junior Member
Yes, this was exact my question.
The provider is always null, if i invoke doStuff-function. I don't know exactly how and where i should bind it not to get empty object.
Re: Exception with ResourceSetBasedResourceDescriptions occurs [message #656356 is a reply to message #656116] Fri, 25 February 2011 09:24 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Dependency injection just works on instances that are themselves created
using DI. If you instantiate your element with an explicit constructor
call, no fields will be injected.

Am 24.02.11 10:55, schrieb goerkem:
> Yes, this was exact my question.
> The provider is always null, if i invoke doStuff-function. I don't know
> exactly how and where i should bind it not to get empty object.


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: Exception with ResourceSetBasedResourceDescriptions occurs [message #932743 is a reply to message #655755] Thu, 04 October 2012 11:36 Go to previous messageGo to next message
Charles Bonneau is currently offline Charles BonneauFriend
Messages: 32
Registered: February 2010
Location: Belgium
Member
Hello,
I have the same error when trying to convert a XMI resource (Containing a EMF model) into a Xtext resource. But in my case, I'm already using Guice's DI mechanism.
Here is my code:
Injector injector = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet outResourceSet = injector.getInstance(XtextResourceSet.class);
[...]
Resource outResource = outResourceSet.createResource(outResourceURI);
outResource.getContents().addAll(inContent);
outResource.save(null);

And I'm getting the same Exception
java.lang.IllegalStateException: Passed org.eclipse.xtext.builder.clustering.CurrentDescriptions not of type org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions
	at org.eclipse.xtext.resource.containers.ResourceSetBasedAllContainersStateProvider.get(ResourceSetBasedAllContainersStateProvider.java:35)
	at org.eclipse.xtext.resource.containers.StateBasedContainerManager.getState(StateBasedContainerManager.java:70)
	at org.eclipse.xtext.resource.containers.StateBasedContainerManager.internalGetContainerHandle(StateBasedContainerManager.java:95)
	at org.eclipse.xtext.resource.containers.StateBasedContainerManager.getVisibleContainers(StateBasedContainerManager.java:48)
	at org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager.isAffected(DefaultResourceDescriptionManager.java:133)
	at org.eclipse.xtext.builder.clustering.ClusteringBuilderState.queueAffectedResources(ClusteringBuilderState.java:440)
	at org.eclipse.xtext.builder.clustering.ClusteringBuilderState.doUpdate(ClusteringBuilderState.java:257)
	at org.eclipse.xtext.builder.builderState.AbstractBuilderState.update(AbstractBuilderState.java:105)
	at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:159)
	at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:141)
	at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:91)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


What am I doing wrong ?

Best regards,

Charles
Re: Exception with ResourceSetBasedResourceDescriptions occurs [message #932820 is a reply to message #932743] Thu, 04 October 2012 13:11 Go to previous message
Charles Bonneau is currently offline Charles BonneauFriend
Messages: 32
Registered: February 2010
Location: Belgium
Member
I think I found the problem.
It was because I'm using MyDSLStandaloneSetup in an AbstractHandler (in a Bundle).
Replacing
Injector injector = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();

by
Injector injector = Guice.createInjector(new MyDslRuntimeModule());

solved the issue.
I found some clues here : https://bugs.eclipse.org/bugs/show_bug.cgi?format=multiple&id=326024

BR,

Charles
Previous Topic:problem for define my dsl
Next Topic:DSL serialization in multiple resources with cross references
Goto Forum:
  


Current Time: Sun Apr 18 00:31:23 GMT 2021

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

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

Back to the top