Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Re: Could not serialize EObject via backtracking.
Re: Could not serialize EObject via backtracking. [message #721272] Thu, 01 September 2011 09:53 Go to next message
Moritz Eysholdt is currently offline Moritz EysholdtFriend
Messages: 161
Registered: July 2009
Location: Kiel, Germany
Senior Member
Hi Steven,

long time no see. Hope you're doing fine.

You object "EntityModel" can not be matched by the constraint
---
module=[Module|QualifiedName] version=STRING entities+=Entity+
---

you can understand the constraint in the same way as an Xtext grammar.

The error message does not say (yet) why exactly the object can not be
matched. Possible reasons are:
- the cross reference can not be serialized
- the cross reference is not set
- entities is empty
- value conversion for version STRING fails.

Could you dump your model using EmfFormatter.objToStr() before you
serialize it?

regards,
Moritz

On 01.09.11 11:40, steven reinisch wrote:
> hi,
>
> based on the following grammar:
>
>
> EntityModel returns system::EntityModel:
> 'entities for module' module = [system::Module | QualifiedName]
> 'version' version = STRING (entities += Entity)+
> ;
>
> Entity returns modulob::Entity:
> (annotations+=Annotation)*
> (isAbstract?='abstract')? 'entity' name=ID (':'
> super=[modulob::Entity])?'{'
> (features+=Feature)*
> '}'
> ;
>
>
> I am manipulating (changing the 'version') this model in memory:
>
>
> entities for module iPhoneApp.Reporting version "1.0"
>
> entity AnEntity {
>
> }
>
>
> and then trying to serialize the in-memory representation. But the
> serialization fails with this exception:
>
>
> java.lang.RuntimeException: Could not serialize EObject via backtracking.
> Constraint: (null) module=[Module|QualifiedName] version=STRING
> entities+=Entity+ (null)
> Semantic Object: EntityModel
> Context: EntityModel
> at
> org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic$ExceptionThrowingAcceptor.accept(ISerializationDiagnostic.java:66)
>
> at
> org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:418)
>
> at
> de.dubmas.modulob.serializer.AbstractDataDslSemanticSequencer.sequence_EntityModel(AbstractDataDslSemanticSequencer.java:176)
>
> at
> de.dubmas.modulob.serializer.AbstractDataDslSemanticSequencer.createSequence(AbstractDataDslSemanticSequencer.java:107)
>
> at
> org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:76)
> at
> org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:84)
> at
> org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:106)
> at
> org.eclipse.xtext.resource.XtextResource.doSave(XtextResource.java:286)
>
>
> I have no clue how to fix this. Does anyone have a suggestion?
>
> regards,
>
> steven
Re: Could not serialize EObject via backtracking. [message #721332 is a reply to message #721272] Thu, 01 September 2011 13:44 Go to previous messageGo to next message
steven reinisch is currently offline steven reinischFriend
Messages: 33
Registered: July 2009
Member
hi moritz,

as long as I can work with xtext I'm fine Smile .

I can dump my object with EmfFormatter.objToStr():

EntityModel {
    attr EString version '1.0'
    cref Entity entities [
        0: Entity {
            attr EString name 'AnEntity'
        }
    ]
    ref Module module ref: Module@platform:/resource/iPhoneApp/src/iPhoneApp/iPhoneApp.mosys#//@modules.0
}


The cross reference is set and 'entities' is not empty.

How can check if value conversion for version STRING fails or the cross reference cannot be serialized?

regards,

steven
Re: Could not serialize EObject via backtracking. [message #721391 is a reply to message #721332] Thu, 01 September 2011 15:53 Go to previous messageGo to next message
Moritz Eysholdt is currently offline Moritz EysholdtFriend
Messages: 161
Registered: July 2009
Location: Kiel, Germany
Senior Member
Hi Steven,

for the backtracking algorithm, you can check in the debugger whether
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.TraceItem.cloneAndConsume(ISemState)
returns null for an assignment that should actually be serialized.
This also covers the value conversion scenario.

Another possible cause is that your TransientValueService determines a
value to be transient even though it's needed by the grammar.

regards,
Moritz

On 01.09.11 15:44, steven reinisch wrote:
> hi moritz,
>
> as long as I can work with xtext I'm fine :) .
>
> I can dump my object with EmfFormatter.objToStr():
>
>
> EntityModel {
> attr EString version '1.0'
> cref Entity entities [
> 0: Entity {
> attr EString name 'AnEntity'
> }
> ]
> ref Module module ref:
> Module@platform:/resource/iPhoneApp/src/iPhoneApp/iPhoneApp.mosys#//@modules.0
>
> }
>
>
> The cross reference is set and 'entities' is not empty.
>
> How can check if value conversion for version STRING fails or the cross
> reference cannot be serialized?
>
> regards,
>
> steven
>
Re: Could not serialize EObject via backtracking. [message #721566 is a reply to message #721391] Fri, 02 September 2011 06:35 Go to previous messageGo to next message
steven reinisch is currently offline steven reinischFriend
Messages: 33
Registered: July 2009
Member
hi moritz,

I checked the debugger and TraceItem.cloneAndConsume(ISemState) returns null for the crossreference to a Module instance:

public TraceItem cloneAndConsume(ISemState state) {
   int index = nextIndex[state.getFeatureID()];
   if (index >= obj.getValueCount(state.getFeatureID()))
      return null;//program exists at this branch

...
}


So, how can I fix this issue?

thx,

steven
Re: Could not serialize EObject via backtracking. [message #721609 is a reply to message #721566] Fri, 02 September 2011 09: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
hi Steven,

could you check if "obj.getValueCount(state.getFeatureID())" has
returned 0 in the scenario that you have described below?

If that is true, the serializer assumes that no values for "module" are
available because the TransientValueService has marked the EReference as
transient in
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.SerializableObject.SerializableObject(EObject,
INodesForEObjectProvider)

regards,
Moritz


On 02.09.11 08:35, steven reinisch wrote:
> hi moritz,
>
> I checked the debugger and TraceItem.cloneAndConsume(ISemState) returns
> null for the crossreference to a Module instance:
>
>
> public TraceItem cloneAndConsume(ISemState state) {
> int index = nextIndex[state.getFeatureID()];
> if (index >= obj.getValueCount(state.getFeatureID()))
> return null;//program exists at this branch
>
> ..
> }
>
>
> So, how can I fix this issue?
>
> thx,
>
> steven
Re: Could not serialize EObject via backtracking. [message #721615 is a reply to message #721609] Fri, 02 September 2011 10:26 Go to previous message
steven reinisch is currently offline steven reinischFriend
Messages: 33
Registered: July 2009
Member
Moritz Eysholdt wrote on Fri, 02 September 2011 05:31
hi Steven,

could you check if "obj.getValueCount(state.getFeatureID())" has
returned 0 in the scenario that you have described below?

If that is true, the serializer assumes that no values for "module" are
available because the TransientValueService has marked the EReference as
transient in
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.SerializableObject.SerializableObject(EObject,
INodesForEObjectProvider)


That was the hint! The EReference 'module' had 'Transient = true' in my .ecore.
Changing it to 'false' lets the serialization run smoothly!

I owe you a beer moritz! .. saved my weekend Smile

regards,

steven



Previous Topic:[Serializer 2.0] Hidden Tokens?
Next Topic:[Xtend2] How to integrate a Java Bufferedreader in *.xtend file
Goto Forum:
  


Current Time: Tue Apr 23 14:47:17 GMT 2024

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

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

Back to the top