Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Exception during serialisation
Exception during serialisation [message #557250] Mon, 06 September 2010 09:33 Go to next message
Eclipse UserFriend
Hi !
I have two models (there is a separate resource/file for each one). The second model can reference the objects of the first.

For a use case I generate both models programmatically. The generation of the first model works without problems. The generation of the second aborts with an exception, when I add a reference to an object from the first model and save the resource.

Does anyone have any idea what might be missing me ?

Here is the exception message:

Caused by: org.eclipse.xtext.parsetree.reconstr.XtextSerializationExcep tion: Could not serialize cross reference from UserInterface.declarations[0]->InstanceLayout'NEMU.cml'.groups[0]- >GroupSAP'_100TAB'.widgets[0]->CsticCML.cml to PIProduct'NEMU'.statements[0]->Tab'_100TAB'.parameters[0]->Parameter'SWconf'
at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor$AssignmentToken.serializeInternal(AbstractParseTr eeConstructor.java:254)
at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor$AbstractToken.serialize(AbstractParseTreeConstruc tor.java:155)
at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor.write(AbstractParseTreeConstructor.java:739)
at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor.write(AbstractParseTreeConstructor.java:734)
at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor.write(AbstractParseTreeConstructor.java:734)
at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor.write(AbstractParseTreeConstructor.java:734)
at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor.write(AbstractParseTreeConstructor.java:734)
at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor.serializeSubtree(AbstractParseTreeConstructor.jav a:721)
at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Se rializer.java:55)
at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Se rializer.java:61)
at org.eclipse.xtext.resource.XtextResource.doSave(XtextResourc e.java:287)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1406)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:993)
at com.ccc.ccc.ccc.migration.old2new.Transformation.execute(Tra nsformation.java:222)
at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(Worksp aceModifyOperation.java:106)
at org.eclipse.core.internal.resources.Workspace.run(Workspace. java:1975)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run(Workspac eModifyOperation.java:118)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:464)
... 52 more


Thanks in advance
Re: Exception during serialisation [message #557355 is a reply to message #557250] Tue, 07 September 2010 06:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14718
Registered: July 2009
Senior Member
Hello Aleksey,

seralizing such references works usually well. See this trivial example:

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
	elements+=Element*
;

Element:
	"element" name=ID ("extends" extends=[Element])?
;


MyDslStandaloneSetup.doSetup();
ResourceSet resourceSet = new ResourceSetImpl();
Resource r1 = resourceSet.createResource(URI.createFileURI("./a.mydsl"));
Resource r2 = resourceSet.createResource(URI.createFileURI("./b.mydsl"));
Model m1 = MyDslFactory.eINSTANCE.createModel();
Element e1 = MyDslFactory.eINSTANCE.createElement();
e1.setName("e1");
m1.getElements().add(e1);
Model m2 = MyDslFactory.eINSTANCE.createModel();
Element e2 = MyDslFactory.eINSTANCE.createElement();
e2.setName("e2");
m2.getElements().add(e2);
e2.setExtends(e1);
r1.getContents().add(e1);
r2.getContents().add(e2);
r1.save(null);
r2.save(null);


Can you tell more about your grammar / customizations to be able to give more advice?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Exception during serialisation [message #557413 is a reply to message #557355] Tue, 07 September 2010 10:56 Go to previous messageGo to next message
Eclipse UserFriend
Hello Christian,

thank you for your answer.

You are righ but i have described the situation a little bit wrong Cool - i have 2 different grammars and a file for each one.

There is a little snippet at http://depositfiles.com/files/5og5usw0a .

You can download the archive file and import the projects in it into your workspace - there are 5 projects, 4 projects created by Xtext and one containing an action for Package Explorer.

Please try this action out - you will get org.eclipse.xtext.parsetree.reconstr.XtextSerializationExcep tion with a message displayed in the console view.

Re: Exception during serialisation [message #557451 is a reply to message #557413] Tue, 07 September 2010 13:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14718
Registered: July 2009
Senior Member
Hi,

this should do the trick

(1) using runtime and not ui modules serializer
(2) using normalized uris

Injector injectorGreeings = Guice.createInjector(new GreetingsDslRuntimeModule());
		final ResourceSet set = new ResourceSetImpl();
		
		XtextResource greetingsResource = (XtextResource) set.createResource(set.getURIConverter().normalize(URI.createFileURI(project.getFile("GreetCol.greetings").getLocation().toString())));
		XtextResource namesResource = (XtextResource) set.createResource(set.getURIConverter().normalize(URI.createFileURI(project.getFile("NamesCol.names").getLocation().toString())));
		
		greetingsResource.setSerializer(injectorGreeings.getInstance(Serializer.class));


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Exception during serialisation [message #557457 is a reply to message #557451] Tue, 07 September 2010 14:06 Go to previous message
Eclipse UserFriend
thank you Christian,

works very well !
Previous Topic:Removing elements from Model
Next Topic:Open xtext script file in my studio's editor, error emerges
Goto Forum:
  


Current Time: Thu Sep 26 13:16:45 GMT 2024

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

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

Back to the top