Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cant get it to do anything, Java exceptions in lsp4xml.log #183

Closed
prof7bit opened this issue Sep 26, 2019 · 8 comments
Closed

cant get it to do anything, Java exceptions in lsp4xml.log #183

prof7bit opened this issue Sep 26, 2019 · 8 comments
Assignees
Labels
bug Something isn't working completion validation
Milestone

Comments

@prof7bit
Copy link

prof7bit commented Sep 26, 2019

Either the documentation is incomplete and missing to explain how to actually activate it or there is a bug and it won't do anything.

I have associated a file extension with a schema

"xml.fileAssociations": [
    {
        "systemId": "http://www.io-link.com/IODD/2010/10/IODD1.1.xsd",
        "pattern": "**/*IODD1.1.xml"
    }
]

but if I load one of these xml files it won't do any validation, I can intentionally insert unknown tags or even syntactic errors and save the document but there is no indication that anything is being validated at all or anything with the configuration is wrong or that there are any errors in my xml document.

@prof7bit
Copy link
Author

prof7bit commented Sep 26, 2019

I'm also seeing lots of exceptions in lsp4xml.log

Sep 26, 2019 2:40:15 PM org.eclipse.lsp4xml.extensions.contentmodel.participants.diagnostics.XMLValidator doDiagnostics
SCHWERWIEGEND: Unexpected XMLValidator error
java.lang.NullPointerException
	at org.eclipse.lsp4xml.extensions.contentmodel.participants.XMLSchemaErrorCode.toLSPRange(XMLSchemaErrorCode.java:171)
	at org.eclipse.lsp4xml.extensions.contentmodel.participants.diagnostics.LSPErrorReporterForXML.toLSPRange(LSPErrorReporterForXML.java:58)
	at org.eclipse.lsp4xml.services.extensions.diagnostics.AbstractLSPErrorReporter.internalToLSPRange(AbstractLSPErrorReporter.java:139)
	at org.eclipse.lsp4xml.services.extensions.diagnostics.AbstractLSPErrorReporter.reportError(AbstractLSPErrorReporter.java:80)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaWarning(Unknown Source)
	at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument1(Unknown Source)
	at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(Unknown Source)
	at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.findSchemaGrammar(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.eclipse.lsp4xml.extensions.contentmodel.participants.diagnostics.XMLValidator.doDiagnostics(XMLValidator.java:114)
	at org.eclipse.lsp4xml.extensions.contentmodel.participants.diagnostics.ContentModelDiagnosticsParticipant.doDiagnostics(ContentModelDiagnosticsParticipant.java:46)
	at org.eclipse.lsp4xml.services.XMLDiagnostics.doExtensionsDiagnostics(XMLDiagnostics.java:83)
	at org.eclipse.lsp4xml.services.XMLDiagnostics.doDiagnostics(XMLDiagnostics.java:51)
	at org.eclipse.lsp4xml.services.XMLLanguageService.doDiagnostics(XMLLanguageService.java:150)
	at org.eclipse.lsp4xml.services.XMLLanguageService.publishDiagnostics(XMLLanguageService.java:159)
	at org.eclipse.lsp4xml.XMLTextDocumentService.validate(XMLTextDocumentService.java:434)
	at org.eclipse.lsp4xml.XMLTextDocumentService.lambda$triggerValidationFor$23(XMLTextDocumentService.java:427)
	at java.util.concurrent.CompletableFuture.uniAccept(CompletableFuture.java:656)
	at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:632)
	at java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:443)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

@prof7bit prof7bit changed the title cant get it to do anything (and there is no documentation on correct usage also) cant get it to do anything, Java exceptions in lsp4xml.log Sep 26, 2019
@angelozerr
Copy link
Contributor

Could you share your XML file please.

@prof7bit
Copy link
Author

prof7bit commented Sep 26, 2019

IO-Link-01-DirectParamsDevice-20130515-IODD1.1.zip

This is an official examle IODD file from the IO-Link specification (industrial automation protocol), vendors describe their devices with such files so the master can configure the port accordingly and load the correct software modules for this device.

@prof7bit
Copy link
Author

I am on Ubuntu Linux:

bernd@bernd:~/.lsp4xml $ java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~18.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

bernd@bernd:~/.lsp4xml $ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.3 LTS
Release:        18.04
Codename:       bionic
bernd@bernd:~/.lsp4xml $ 

@angelozerr
Copy link
Contributor

Thank you, I can reproduce your NPE problem. I will investigate your problem.

@angelozerr
Copy link
Contributor

@prof7bit after studying your usecase, I have found 2 little bugs that I will fix it, but you can benefit with validation and completion.

At first you don't need xml.fileAssociation since you bind your XML with XML Schema (according your sample):

<IODevice xmlns="http://www.io-link.com/IODD/2010/10" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.io-link.com/IODD/2010/10 IODD1.1.xsd">

This declaration means that you have the XML Schema IODD1.1.xsd in the same folder than your XML file.

If you unzip the following folder
io-link-xml.zip

you can open your the XML file of the folder and validation, completion, hover, etc should work.

IOLInkDemo

Normaly, you could write too:

<IODevice xmlns="http://www.io-link.com/IODD/2010/10" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.io-link.com/IODD/2010/10 https://io-link.com/IODD/2010/10/IODD1.1.xsd">

To bind your XML file with https://io-link.com/IODD/2010/10/IODD1.1.xsd but validation , completion doesn't work because:

  • this XML Schema includes https://io-link.com/IODD/2010/10/IODD-Primitives1.1.xsd which imports xml.xsd <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/> which is wrong because https://io-link.com/IODD/2010/10/xml.xsd doesn't exists (you should see this error on the root). LSP4XML manages a cache in .lsp4xml folder (by default in your home folder) and if you copy/paste the xml.xsd file (that you can see in the attached zip) validation should work. But completion will not work since there is a bug that I must fix it (completion should use XML Schema from cache).

You could write your own XML catalog too to avoid setting your XSD files in the same folder your XML files. I suggest you that you read documentation about XML catalogs.

@angelozerr
Copy link
Contributor

@fbricon this PR eclipse-lemminx/lemminx#569 should fix NPE #183 (comment)

I will prepare an another PR for completion cache bug.

@angelozerr
Copy link
Contributor

I will prepare an another PR for completion cache bug.

Done with eclipse-lemminx/lemminx#570

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working completion validation
Projects
None yet
Development

No branches or pull requests

2 participants