Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XtextResource.save(outputStream,options) throw a Exception(XtextResource.save(outputStream,options) throw a Exception)
XtextResource.save(outputStream,options) throw a Exception [message #690808] Thu, 30 June 2011 08:58 Go to next message
zwzhao Missing name is currently offline zwzhao Missing nameFriend
Messages: 3
Registered: June 2011
Junior Member
i am a xtext new member.when i use this ,find a problem.
i use XtextResource.save(OutputStream outputStream, Map<?, ?> options) it occur a Exception .
my code is :
URI uri = URI.createFileURI(path);
Resource resource = new ResourceSetImpl().getResource(uri, true);
processType = (ProcessType) resource.getContents().get(0);
...
XtextResource xResource = (XtextResource) processType.eResource();
...
SerializerOptions op = new SerializerOptions(false, true);
map.put(XtextResource.OPTION_SERIALIZATION_OPTIONS, op);
xResource.save(new FileOutputStream("d:\\b.txt"), map);

note:the path file is script4_0.1.jobscript which is attached.

the Exception is :

org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Serialization failed
<# of serialized tokens>: <EObject path> "<serializable fragment, starting from the end>":
-> <possible reasons for not continuing>
736:ProcessType.context[0]->ContextType'Default': "ContextType { NAME: Default , CONFIRMATIONNEED: fal...":
-> ProcessType_ContextAssignment_2: All 1 values of ProcessType.context have been consumed. More are needed to continue here.
-> ProcessType_ProcessTypeAction_0: n/a
732:ProcessType.context[0]->ContextType'Default': "ContextType { , CONFIRMATIONNEED: false } addParame...":
-> ContextType_ContextTypeAction_0: n/a
731:ProcessType.context[0]->ContextType'Default': "ContextType { NAME: Default } addParameters { addEl...":
-> ContextType_ContextTypeAction_0: n/a
728:ProcessType.context[0]->ContextType'Default': "ContextType { } addParameters { addElementParameter...":
-> ContextType_ContextTypeAction_0: n/a
721:ProcessType.parameters->ParametersType: ", COMP_DEFAULT_FILE_DIR : D:/Eclipse_helios/eclipse...":
-> ParametersType_ElementParameterAssignment_4_1: All 70 values of ParametersType.elementParameter have been consumed. More are needed to continue here.
712:ProcessType.parameters->ParametersType: ", COMP_DEFAULT_FILE_DIR : D:/Eclipse_helios/eclipse...":
-> ParametersType_ElementParameterAssignment_4_1: All 70 values of ParametersType.elementParameter have been consumed. More are needed to continue here.
711:ProcessType.parameters->ParametersType: "addElementParameters { PRODUCT_ROOT_DIR : D:/Eclips...":
-> ParametersType_ParametersTypeAction_0: n/a
703:ProcessType.parameters->ParametersType: ", COMP_DEFAULT_FILE_DIR : D:/Eclipse_helios/eclipse...":
-> ParametersType_ElementParameterAssignment_4_1: All 70 values of ParametersType.elementParameter have been consumed. More are needed to continue here.
702:ProcessType.parameters->ParametersType: "addElementParameters { COMP_DEFAULT_PROJECT_DIR : D...":
-> ParametersType_ParametersTypeAction_0: n/a
694:ProcessType.parameters->ParametersType: ", COMP_DEFAULT_FILE_DIR : D:/Eclipse_helios/eclipse...":
-> ParametersType_ElementParameterAssignment_4_1: All 70 values of ParametersType.elementParameter have been consumed. More are needed to continue here.
at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeConstructor.serialize(AbstractParseTreeConstructor.java:676)
at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeConstructor.serialize(AbstractParseTreeConstructor.java:683)
at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeConstructor.serializeSubtree(AbstractParseTreeConstructor.java:706)
at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Serializer.java:55)
at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Serializer.java:61)
at org.eclipse.xtext.resource.XtextResource.doSave(XtextResource.java:287)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1406)
at org.talend.metalanguage.jobscript.CreateXtextProcessService.convertDesignerEditorInput(CreateXtextProcessService.java:176)
at org.talend.designer.core.ui.AbstractMultiPageTalendEditor.pageChange(AbstractMultiPageTalendEditor.java:497)
at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:290)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:2743)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1429)
at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:257)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.talend.rcp.intro.Application.start(Application.java:128)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

Best Regards,
zwzhao
Re: XtextResource.save(outputStream,options) throw a Exception [message #690917 is a reply to message #690808] Thu, 30 June 2011 12:16 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
Hi zwzhao,

the member has to be populated with valid values for its references and
attributes according to your grammar.

Consider the following example:

NamedThing:
'thing' name=ID (desc=STRING)? attr+=Attr (attr+=Attr)?
(left?='left'|right?='right);

If you create a NamedThing in memory, it has to have a name (mandatory
feature), it may have a desc and it must have at least one element in
its attr-list but no more than two. Either left or right have to be true
but at least one of both has to be false. Most grammars introduce more
constraints which are not that obvious as in this example.

The exception indicates that your created member is incomplete.

Does that answer your question?

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

On 30.06.11 10:58, zwzhao wrote:
> i am a xtext new member.when i use this ,find a problem.
> i use XtextResource.save(OutputStream outputStream, Map<?, ?> options) it occur a Exception .
> my code is :
> URI uri = URI.createFileURI(path);
> Resource resource = new ResourceSetImpl().getResource(uri, true);
> processType = (ProcessType) resource.getContents().get(0);
> ...
> XtextResource xResource = (XtextResource) processType.eResource();
> ...
> SerializerOptions op = new SerializerOptions(false, true);
> map.put(XtextResource.OPTION_SERIALIZATION_OPTIONS, op);
> xResource.save(new FileOutputStream("d:\\b.txt"), map);
>
> note:the path file is script4_0.1.jobscript which is attached.
>
> the Exception is :
>
> org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Serialization failed
> <# of serialized tokens>:<EObject path> "<serializable fragment, starting from the end>":
> -> <possible reasons for not continuing>
> 736:ProcessType.context[0]->ContextType'Default': "ContextType { NAME: Default , CONFIRMATIONNEED: fal...":
> -> ProcessType_ContextAssignment_2: All 1 values of ProcessType.context have been consumed. More are needed to continue here.
> -> ProcessType_ProcessTypeAction_0: n/a
> 732:ProcessType.context[0]->ContextType'Default': "ContextType { , CONFIRMATIONNEED: false } addParame...":
> -> ContextType_ContextTypeAction_0: n/a
> 731:ProcessType.context[0]->ContextType'Default': "ContextType { NAME: Default } addParameters { addEl...":
> -> ContextType_ContextTypeAction_0: n/a
> 728:ProcessType.context[0]->ContextType'Default': "ContextType { } addParameters { addElementParameter...":
> -> ContextType_ContextTypeAction_0: n/a
> 721:ProcessType.parameters->ParametersType: ", COMP_DEFAULT_FILE_DIR : D:/Eclipse_helios/eclipse...":
> -> ParametersType_ElementParameterAssignment_4_1: All 70 values of ParametersType.elementParameter have been consumed. More are needed to continue here.
> 712:ProcessType.parameters->ParametersType: ", COMP_DEFAULT_FILE_DIR : D:/Eclipse_helios/eclipse...":
> -> ParametersType_ElementParameterAssignment_4_1: All 70 values of ParametersType.elementParameter have been consumed. More are needed to continue here.
> 711:ProcessType.parameters->ParametersType: "addElementParameters { PRODUCT_ROOT_DIR : D:/Eclips...":
> -> ParametersType_ParametersTypeAction_0: n/a
> 703:ProcessType.parameters->ParametersType: ", COMP_DEFAULT_FILE_DIR : D:/Eclipse_helios/eclipse...":
> -> ParametersType_ElementParameterAssignment_4_1: All 70 values of ParametersType.elementParameter have been consumed. More are needed to continue here.
> 702:ProcessType.parameters->ParametersType: "addElementParameters { COMP_DEFAULT_PROJECT_DIR : D...":
> -> ParametersType_ParametersTypeAction_0: n/a
> 694:ProcessType.parameters->ParametersType: ", COMP_DEFAULT_FILE_DIR : D:/Eclipse_helios/eclipse...":
> -> ParametersType_ElementParameterAssignment_4_1: All 70 values of ParametersType.elementParameter have been consumed. More are needed to continue here.
> at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeConstructor.serialize(AbstractParseTreeConstructor.java:676)
> at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeConstructor.serialize(AbstractParseTreeConstructor.java:683)
> at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeConstructor.serializeSubtree(AbstractParseTreeConstructor.java:706)
> at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Serializer.java:55)
> at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Serializer.java:61)
> at org.eclipse.xtext.resource.XtextResource.doSave(XtextResource.java:287)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1406)
> at org.talend.metalanguage.jobscript.CreateXtextProcessService.convertDesignerEditorInput(CreateXtextProcessService.java:176)
> at org.talend.designer.core.ui.AbstractMultiPageTalendEditor.pageChange(AbstractMultiPageTalendEditor.java:497)
> at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:290)
> at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
> at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:2743)
> at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1429)
> at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:257)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
> at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
> at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
> at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
> at org.talend.rcp.intro.Application.start(Application.java:128)
> at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
>
> Best Regards,
> zwzhao
>
Previous Topic:Is it a bug of Xtext
Next Topic:Bind an action to CTRL and mouse click in XText
Goto Forum:
  


Current Time: Sun Sep 27 18:23:15 GMT 2020

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

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

Back to the top