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

ClassCastException: with documentLink in catalog XMLCatalogDocumentLinkParticipant #932

Closed
angelozerr opened this issue Nov 11, 2020 · 0 comments · Fixed by #944
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@angelozerr
Copy link
Contributor

Open the given XML file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN" "https://www.oasis-open.org/committees/entity/release/1.1/catalog.dtd" >
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <!-- W3C schema -->
 
    <uri name="urn:speedata.de:2009/publisher/en" uri="layoutschema-en.xsd"/>
 
</catalog>

The document link doesn't work for the uri attribute and you can see the error message:

[Error - 18:33:14] Request textDocument/documentLink failed.
  Message: Internal error.
  Code: -32603 
java.util.concurrent.CompletionException: java.lang.ClassCastException: class org.eclipse.lemminx.dom.DOMDocumentType cannot be cast to class org.eclipse.lemminx.dom.DOMElement (org.eclipse.lemminx.dom.DOMDocumentType and org.eclipse.lemminx.dom.DOMElement are in unnamed module of loader 'app')
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
	at java.base/java.util.concurrent.CompletableFuture.biApply(CompletableFuture.java:1238)
	at java.base/java.util.concurrent.CompletableFuture$BiApply.tryFire(CompletableFuture.java:1205)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Caused by: java.lang.ClassCastException: class org.eclipse.lemminx.dom.DOMDocumentType cannot be cast to class org.eclipse.lemminx.dom.DOMElement (org.eclipse.lemminx.dom.DOMDocumentType and org.eclipse.lemminx.dom.DOMElement are in unnamed module of loader 'app')
	at org.eclipse.lemminx.extensions.catalog.CatalogUtils.getCatalogEntries(CatalogUtils.java:67)
	at org.eclipse.lemminx.extensions.catalog.XMLCatalogDocumentLinkParticipant.findDocumentLinks(XMLCatalogDocumentLinkParticipant.java:36)
	at org.eclipse.lemminx.services.XMLDocumentLink.findDocumentLinks(XMLDocumentLink.java:38)
	at org.eclipse.lemminx.services.XMLLanguageService.findDocumentLinks(XMLLanguageService.java:232)
	at org.eclipse.lemminx.XMLTextDocumentService.lambda$documentLink$12(XMLTextDocumentService.java:363)
	at java.base/java.util.concurrent.CompletableFuture.biApply(CompletableFuture.java:1236)
	... 7 more

If you remove DOCTYPE, it works good.

To fix theproblem we should check the node is an element

angelozerr pushed a commit to angelozerr/lemminx that referenced this issue Dec 8, 2020
XMLCatalogDocumentLinkParticipant

Fixes eclipse#932

Signed-off-by: azerr <azerr@redhat.com>
@angelozerr angelozerr self-assigned this Dec 8, 2020
@angelozerr angelozerr added the bug Something isn't working label Dec 8, 2020
@angelozerr angelozerr added this to the 0.15.0 milestone Dec 8, 2020
datho7561 pushed a commit that referenced this issue Dec 8, 2020
XMLCatalogDocumentLinkParticipant

Fixes #932

Signed-off-by: azerr <azerr@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant