Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » createSAXParseException on Windows(A createSAXParseException only on Windows System on Linux works fine)
createSAXParseException on Windows [message #1781912] Wed, 14 February 2018 15:30 Go to next message
M V is currently offline M VFriend
Messages: 31
Registered: July 2017
Member
I have an Xtext application in an E4 RCP. There I call the Xtext parser from different things to have sources in an EMF.

Under linux in the RCP and in my units test on the Jenkins build server also linux it works fine.

But not on a Windows system it does not work. My first thought was that I have a problem with decoding. The sources are also UTF-8, I have attached the stack trace and the location of my code where I call it.

  
@Inject
  protected XtextResourceSet resourceSet;

  private void parseInputStream() {
    URI uri = URI.createURI(file.getFullPath().toString());
    resource = resourceSet.getResource(uri, false);
   
    if (resource == null) {
      resource = resourceSet.createResource(uri);
    }

    final Map<Object, Object> loadOptions = resourceSet.getLoadOptions();
    loadOptions.put(XtextResource.OPTION_ENCODING, "UTF-8");
    resource.load(in, resourceSet.getLoadOptions()); // <-- Stacktrace entry Point
  }


Quote:
during parsing: C:\Users\user\Desktop\de.company.rcp.rcp.product-win32.win32.x86_64\workspace\Library\tia_import\plcsoft\Main.awl
IOException: Content ist nicht zulässig in Prolog.

at de.company.rcp.common.source.parser.Parser.parseInputStream(Parser.java:155)
at de.company.rcp.common.source.parser.Parser.parse(Parser.java:78)
at de.company.rcp.common.source.parser.XTextAWLParser.parse(XTextAWLParser.java:24)
at de.company.rcp.common.source.parser.XTextParser.parse(XTextParser.java:37)
at de.company.rcp.common.source.parser.XTextParser.parseAwl(XTextParser.java:24)
at de.company.rcp.datamodel.importer.generation.source.SourceCrossPathGeneration.getPossibleCrossCallAwl(SourceCrossPathGeneration.java:128)
at de.company.rcp.datamodel.importer.generation.source.SourceCrossPathGeneration.getAllCrossLinkedSourcePathes(SourceCrossPathGeneration.java:95)
at de.company.rcp.datamodel.importer.generation.source.SourceCrossPathGeneration.generate(SourceCrossPathGeneration.java:50)
at de.company.rcp.datamodel.importer.generation.source.SourceCrossPathGeneration.generate(SourceCrossPathGeneration.java:1)
at de.company.rcp.datamodel.importer.importer.Import.runGenerator(Import.java:87)
at de.company.rcp.datamodel.importer.importer.ImportPlcSource.generateCrossSourcePath(ImportPlcSource.java:77)
at de.company.rcp.datamodel.importer.importer.ImportPlcSource.doImport(ImportPlcSource.java:49)
at de.company.rcp.datamodel.importer.wizard.ImportWizard.importPlcSource(ImportWizard.java:147)
at de.company.rcp.datamodel.importer.wizard.ImportWizard.access$2(ImportWizard.java:146)
at de.company.rcp.datamodel.importer.wizard.ImportWizard$1.execute(ImportWizard.java:104)
at org.eclipse.ui.actions.WorkspaceModifyOperation.lambda$0(WorkspaceModifyOperation.java:107)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:128)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:437)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:353)
at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:980)
at de.company.rcp.datamodel.importer.wizard.ImportWizard.performFinish(ImportWizard.java:135)
at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:778)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:417)
at org.eclipse.jface.dialogs.Dialog.lambda$0(Dialog.java:619)
at org.eclipse.swt.events.SelectionListener$1.widgetSelected(SelectionListener.java:81)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4428)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4238)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3817)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:818)
at org.eclipse.jface.window.Window.open(Window.java:794)
at de.company.rcp.datamodel.importer.handlers.ImporterHandler.execute(ImporterHandler.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:305)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:239)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:494)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:487)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:431)
at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.handleWidgetSelection(AbstractContributionItem.java:446)
at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.lambda$2(AbstractContributionItem.java:472)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4428)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4238)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3817)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1150)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1039)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
at de.company.rcp.rcp.Application.start(Application.java:30)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
Caused by: org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Content ist nicht zulässig in Prolog.
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:195)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
at de.company.rcp.common.source.parser.Parser.parseInputStream(Parser.java:153)
... 76 more
Caused by: org.xml.sax.SAXParseExceptionpublicId: c:\Users\user\Desktop\de.company.rcp.rcp.product-win32.win32.x86_64\workspace\Library\tia_import\plcsoft\Main.awl; systemId: file:///c:/Users/user/Desktop/de.company.rcp.rcp.product-win32.win32.x86_64/workspace/Library/tia_import/plcsoft/Main.awl; lineNumber: 1; columnNumber: 1; Content ist nicht zulässig in Prolog.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
... 79 more
Re: createSAXParseException on Windows [message #1781915 is a reply to message #1781912] Wed, 14 February 2018 15:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12229
Registered: July 2009
Senior Member
do you read an xml file or a text(dsl) file?

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: createSAXParseException on Windows [message #1781934 is a reply to message #1781915] Wed, 14 February 2018 19:04 Go to previous messageGo to next message
M V is currently offline M VFriend
Messages: 31
Registered: July 2017
Member
a text file, under the linux build of the rcp is it no problem.
Re: createSAXParseException on Windows [message #1781935 is a reply to message #1781934] Wed, 14 February 2018 19:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12229
Registered: July 2009
Senior Member
For me this looks like standalone setup or the registration in eclipse is not correctly or something destroys the registries
So you should have a look why a xml resource is created and not a yourdsl Xtext resource


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 14 February 2018 19:22]

Report message to a moderator

Re: createSAXParseException on Windows [message #1781936 is a reply to message #1781935] Wed, 14 February 2018 19:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12229
Registered: July 2009
Senior Member
Besides this non of your stacktrace shows default Xtext behaviour

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: createSAXParseException on Windows [message #1781954 is a reply to message #1781936] Thu, 15 February 2018 07:08 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6037
Registered: July 2009
Senior Member
HI

"Content ist nicht zulässig in Prolog" or rather "Content is not allowed in Prolog" is very commonly associated with requesting default EMF XML resource loading to process text (e.g Xtext DSL) resources. This usually occurs because of a failure to register the correct DSL-aware resource factory.

However Windows/Linux problems are more commonly associated with line endings/case-dependence/backslash anomalies. Your file name file:///c:/... is Windows-specific. It makes me uncomfortable because I recognize that the ///'s are very hard to get right. I never know what is right so I never use that form. However the "content not allowed" suggests that perhaps a file was opened successfully.

I have no idea how to ensure error messages appear in German. You have successfully achieved this. I wonder if in doing so you corrupted a file extension registration.

Without a repro or full stack trace diagnosis hard. All we can tell is that while parsing an unnamed DSL, a *.awl file failed. This failure was presumably an import. We have no clue why this import did not use a DSL parser. I suspect that the problem is in your import handler.

Beware that the platform/EMF content type analysis causes text files to be read as XML giving exactly the error you see. Normally the consequent exception is caught as part of a not-XML diagnosis. However when debugging you can find yourself confused by this normal exception.

You need to understand why file:///c:/Users/user/Desktop/de.company.rcp.rcp.product-win32.win32.x86_64/workspace/Library/tia_import/plcsoft/Main.awl is being loaded as XML. Is the XML attempt an error, or is the failure to handle the exception an error?

Regards

Ed Willink
Re: createSAXParseException on Windows [message #1781966 is a reply to message #1781954] Thu, 15 February 2018 11:28 Go to previous messageGo to next message
M V is currently offline M VFriend
Messages: 31
Registered: July 2017
Member
Hi, thanks for the help so far.

I try to find out why there File is loading as XML. So debug on Linux an Windows parallel to find the differences.

resource = resourceSet.getResource(uri, false);  // <-- Null on both
if (resource == null) {
     resource = resourceSet.createResource(uri); // <-- different
}


After this code I have in resource var:

On Linux: org.eclipse.xtext.linking.lazy.LazyLinkingResource
On Windows: org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl

so far, at the moment I have no idea why this is so. Is there a a point where I can see the registration for the parser.

Thank for your help
Re: createSAXParseException on Windows [message #1781970 is a reply to message #1781966] Thu, 15 February 2018 11:57 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6037
Registered: July 2009
Senior Member
Hi

The difference strongly suggests that your extension/protocol/content-type has not been registered on Windows. Presumably you are using extension-based resource discrimination so you need to see what the ResourceSet.getResourceFactory().getExternsionFactory() contains for both your resourceSet and the Resource.Registry.INSTANCE to which your resourceSet delegates. I generally single step through createResource to understand why it gives me whatever ResourceFactory it does.

However before single stepping you might check your source file folder to confirm that you do not have any uppercase/lowercase file name confusions. e.g. if on Windows you have a *.AWL file as a consequence of an inappropriate Linux to Windows file copy, everything is explained.

Regards

Ed Willink
Re: createSAXParseException on Windows [message #1781978 is a reply to message #1781970] Thu, 15 February 2018 12:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12229
Registered: July 2009
Senior Member
iwonder e.g. how you create/injetc the class that does this.

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: createSAXParseException on Windows [message #1781984 is a reply to message #1781978] Thu, 15 February 2018 13:26 Go to previous messageGo to next message
M V is currently offline M VFriend
Messages: 31
Registered: July 2017
Member
Christian Dietrich wrote on Thu, 15 February 2018 12:16
iwonder e.g. how you create/injetc the class that does this.

    
final Injector injector = AwlInjector.getInstance().getInjector();
...
injector.injectMembers(generator);


Ed Willink wrote on Thu, 15 February 2018 11:57
Hi

The difference strongly suggests that your extension/protocol/content-type has not been registered on Windows. Presumably you are using extension-based resource discrimination so you need to see what the ResourceSet.getResourceFactory().getExternsionFactory() contains for both your resourceSet and the Resource.Registry.INSTANCE to which your resourceSet delegates. I generally single step through createResource to understand why it gives me whatever ResourceFactory it does.

However before single stepping you might check your source file folder to confirm that you do not have any uppercase/lowercase file name confusions. e.g. if on Windows you have a *.AWL file as a consequence of an inappropriate Linux to Windows file copy, everything is explained.

Regards

Ed Willink


After all, the solution was simple, but not so simple to find.

Quote:

Resource.Factory resourceFactory = getResourceFactoryRegistry().getFactory(uri, contentType);

Windows:
org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl@56fb87cd
Linux:
org.eclipse.xtext.resource.XtextResourceFactory@53d87c9

extensionToFactoryMap
Windows:
key: awl
value: org.eclipse.emf.ecore.plugin.RegistryReader$ResourceFactoryDescriptor@231e5af
Linux:
key: awl
value: org.eclipse.emf.ecore.plugin.RegistryReader$ResourceFactoryDescriptor@3b89bccf

return of uri.fileExtension()
Windows
-- null
Linux
awl


The URI is not parsed right on Windows I has URI$Opaque and on Linux URI$Hierarchical after add "file:///" all work fine on Windows. Now I know to fix it!

Big Thanks for your great Support!

[Updated on: Thu, 15 February 2018 13:33]

Report message to a moderator

Re: createSAXParseException on Windows [message #1781986 is a reply to message #1781984] Thu, 15 February 2018 13:44 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6037
Registered: July 2009
Senior Member
Hi

Adding file:/// may be a solution but it is a bad OS-specific one. Perhaps you should have called URI.createFileURI(,...) to do this portably.

Regards

Ed Willink
Previous Topic:Tracking Init, Read, Write accesses to a field
Next Topic:XReturnExpression type deduction in inferrer
Goto Forum:
  


Current Time: Wed Sep 19 18:15:10 GMT 2018

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

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

Back to the top