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

XML validation errors (incomplete project-based XSD schemas resolution?) #447

Closed
mauromol opened this issue Apr 14, 2020 · 11 comments
Closed

Comments

@mauromol
Copy link

Using STS4 4.6.0 in Eclipse.
In #108 project-based XSD schema resolution was implemented. I'm pretty sure I saw this working in other places, but I have a XML file using Spring Integration namespace XML elements for which this resolution seems to (partially) fail.
I have Spring Integration 4.3.21 in the classpath (both core and http modules) and snippets like these:

<int:header-enricher
    input-channel="preAuthRequestChannel"
    output-channel="restServiceRequestChannel">
    <int:header name="myHeader"
        expression="someGreatExpression" />
</int:header-enricher>

The above is marked with this error:

cvc-complex-type.3.2.2: Attribute 'expression' is not allowed to appear in element 'int:header'.

Similar errors are given on <int-http:outbound-gateway> attributes like http-method-expression or request-factory.
I'm using the unversioned namespaces:

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	default-lazy-init="true"
	xmlns:int-http="http://www.springframework.org/schema/integration/http"
	xmlns:int="http://www.springframework.org/schema/integration"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
		http://www.springframework.org/schema/integration/http https://www.springframework.org/schema/integration/http/spring-integration-http.xsd">

If I replace the unversioned XSDs with the versioned (4.3) ones, those errors go away. But I would like to avoid it.
The Spring Boot language server log doesn't show any error/exception. The XML where I have this problem seems to be detected as well as any updates to it:

17:22:07.712 [pool-4-thread-1] INFO  o.s.i.v.boot.app.SpringSymbolIndex - Update document [xml changed]: file:///home/mauro/svn/DCS-SHOP-trunk/shop-commons/src/main/resources/context/myfile-foo.xml

Basic XML code assist for attribute names work (even for those attributes that are marked in red!), as well as further STS4 code assist within <bean> attributes (like class or property).

If I right click on the editor and choose "Validate", I get "The validation completed with no errors or warnings", yet I have those errors in the left vertical ruler and attributes are underlined in red.

I tried to:

  • restart Eclipse
  • clean that project
  • close and reopen that project

without success.

Any idea on what is going on?

@martinlippert
Copy link
Member

Let me check if I can reproduce this locally.

Side note: The project-related XML namespace resolution is not part of the language server, that had to be implemented outside of it as a direct extension to the existing XML infrastructure of the IDE, in this case Eclipse.

@martinlippert
Copy link
Member

I tried this with the latest Spring Integration guide and tried various things that you describe in the integration.xml file and it seems to work fine there. So there must be an important difference between my guide project and yours.

There are two things that we could try:

  • you import the Integration guide via the wizard in STS and modify the existing integration.xml file so that it contains the problematic elements - to see if that works or not.
  • or you zip a sample project that doesn't work on your end, so that I can take a detailed look at your project to see what is going wrong.

What do you think?

@mauromol
Copy link
Author

Hi Martin,
the second option is unfortunately complex, because I'm experiencing this in a large proprietary project. Regarding the first option, could you please give me some more help? I don't find any STS wizard in Eclipse Import... dialog. Maybe I am missing some STS4 component in my Eclipse installation... Is it part of the "Spring Tool Suite 4 Branding Feature"?

@mauromol
Copy link
Author

It seems like I was able to reproduce:
TestSTS.zip

This is a small Eclipse+Gradle project. If you open src/main/resources/foo-cms.xml in it, you'll see the errors. Here is a screenshot:

immagine

What's interesting is that the errors are reported in the Markers view under the category "Language Servers", and not under XML or such.
Right click -> Validate brings a "the validation completed with no errors or warnings".

I can't find anything relevant (at least to me) in the Language Server log. Here is the contents:

12:25:14.936 [Simple-Language-Server main thread] INFO  o.s.i.v.b.jdt.ls.JdtLsProjectCache - Project Created: file:/home/mauro/workspace/rolling/DCS-SHOP-trunk/TestSTS
12:25:14.937 [Simple-Language-Server main thread] INFO  o.s.i.v.b.jdt.ls.JdtLsProjectCache - Classpath has 31 entries
12:25:14.937 [Simple-Language-Server main thread] INFO  o.s.i.v.b.jdt.ls.JdtLsProjectCache - listeners registered: 7
12:25:14.937 [Simple-Language-Server main thread] INFO  o.s.i.v.b.j.u.CompilationUnitCache - CU Cache: created project TestSTS
12:25:14.937 [Simple-Language-Server main thread] INFO  o.s.i.v.boot.app.SpringSymbolIndex - project created event: TestSTS
12:25:14.937 [Simple-Language-Server main thread] INFO  o.s.i.v.b.a.BootLanguageServerInitializer - A project changed TestSTS, triggering reconcile on all project's open documents
12:25:16.428 [ForkJoinPool.commonPool-worker-2] INFO  o.s.i.v.b.j.l.v.SpringProcessDescriptor - language server process found, do not connect: 7426
12:27:17.325 [Simple-Language-Server main thread] INFO  o.s.i.v.b.jdt.ls.JdtLsProjectCache - Project Changed: file:/home/mauro/workspace/rolling/DCS-SHOP-trunk/TestSTS
12:27:17.325 [Simple-Language-Server main thread] INFO  o.s.i.v.b.jdt.ls.JdtLsProjectCache - Classpath has 42 entries
12:27:17.325 [Simple-Language-Server main thread] INFO  o.s.i.v.b.j.u.CompilationUnitCache - CU Cache: changed project TestSTS
12:27:17.325 [Simple-Language-Server main thread] INFO  o.s.i.v.boot.app.SpringSymbolIndex - project changed event: TestSTS
12:27:17.325 [Simple-Language-Server main thread] INFO  o.s.i.v.b.a.BootLanguageServerInitializer - A project changed TestSTS, triggering reconcile on all project's open documents
12:27:17.328 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan java files for symbols for project: TestSTS - no. of files: 1
12:27:17.329 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan java files, AST parse, pass 1 for files: 1
12:27:18.991 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan java files for symbols for project: TestSTS took ms: 1663
12:27:18.992 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - Found 0 XML files to scan in 1ms
12:27:18.992 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan xml files for symbols for project: TestSTS - no. of files: 0
12:27:18.995 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan xml files for symbols for project: TestSTS took ms: 4
12:27:44.034 [Simple-Language-Server main thread] INFO  o.s.i.v.b.jdt.ls.JdtLsProjectCache - Project Changed: file:/home/mauro/workspace/rolling/DCS-SHOP-trunk/TestSTS
12:27:44.034 [Simple-Language-Server main thread] INFO  o.s.i.v.b.jdt.ls.JdtLsProjectCache - Classpath has 40 entries
12:27:44.034 [Simple-Language-Server main thread] INFO  o.s.i.v.b.j.u.CompilationUnitCache - CU Cache: changed project TestSTS
12:27:44.034 [Simple-Language-Server main thread] INFO  o.s.i.v.boot.app.SpringSymbolIndex - project changed event: TestSTS
12:27:44.034 [Simple-Language-Server main thread] INFO  o.s.i.v.b.a.BootLanguageServerInitializer - A project changed TestSTS, triggering reconcile on all project's open documents
12:27:44.035 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan java files for symbols for project: TestSTS - no. of files: 1
12:27:44.036 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan java files, AST parse, pass 1 for files: 1
12:27:44.135 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan java files for symbols for project: TestSTS took ms: 100
12:27:44.135 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - Found 0 XML files to scan in 0ms
12:27:44.135 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan xml files for symbols for project: TestSTS - no. of files: 0
12:27:44.138 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan xml files for symbols for project: TestSTS took ms: 3
12:29:30.697 [Simple-Language-Server main thread] INFO  o.s.i.v.c.l.u.SimpleTextDocumentService - Closed: file:///home/mauro/workspace/rolling/DCS-SHOP-trunk/TestSTS/src/main/resources/originalname-cms.xml
12:29:44.499 [pool-4-thread-1] INFO  o.s.i.v.boot.app.SpringSymbolIndex - Update document [xml changed]: file:///home/mauro/workspace/rolling/DCS-SHOP-trunk/TestSTS/src/main/resources/foo-cms.xml
12:29:54.875 [pool-4-thread-1] INFO  o.s.i.v.boot.app.SpringSymbolIndex - Update document [xml changed]: file:///home/mauro/workspace/rolling/DCS-SHOP-trunk/TestSTS/src/main/resources/foo-cms.xml
12:30:33.635 [pool-4-thread-1] INFO  o.s.i.v.boot.app.SpringSymbolIndex - Update document [xml changed]: file:///home/mauro/workspace/rolling/DCS-SHOP-trunk/TestSTS/src/main/resources/foo-cms.xml
12:30:42.852 [pool-4-thread-1] INFO  o.s.i.v.boot.app.SpringSymbolIndex - Update document [xml changed]: file:///home/mauro/workspace/rolling/DCS-SHOP-trunk/TestSTS/src/main/resources/foo-cms.xml
12:30:51.453 [pool-4-thread-1] INFO  o.s.i.v.boot.app.SpringSymbolIndex - Update document [xml changed]: file:///home/mauro/workspace/rolling/DCS-SHOP-trunk/TestSTS/src/main/resources/foo-cms.xml
12:31:01.341 [pool-4-thread-1] INFO  o.s.i.v.boot.app.SpringSymbolIndex - Update document [xml changed]: file:///home/mauro/workspace/rolling/DCS-SHOP-trunk/TestSTS/src/main/resources/foo-cms.xml
12:31:31.870 [pool-4-thread-1] INFO  o.s.i.v.boot.app.SpringSymbolIndex - Update document [xml changed]: file:///home/mauro/workspace/rolling/DCS-SHOP-trunk/TestSTS/src/main/resources/foo-cms.xml

@martinlippert
Copy link
Member

Do you have additional language servers running in your IDE? Like something that also reacts to XML files, like an XML language server from the Wild Web Developer package, for example?

You can check that in the Preferences -> Language Server. Is there is another language server associated with XML files, that might the source of those errors showing up - in that case, you should maybe disable that other one... :-)

For some background: the XML language server from Wild Web Developer doesn't take our project-specific namespace resolving into account. Our project-specific namespace resolving is implemented as extension for the WTP package in Eclipse.

But we have plans to extend the XML language server from Wild Web with our project-specific namespace resolving, but that will not happen soon.

@mauromol
Copy link
Author

Good catch Martin... disabling Wild Web Developer language servers and closing and reopening the editor made the errors go away...
Yes, as I stated elsewhere I find the current situation between WTP and Wild Web Developer plugins quite confusing, from a user point of view I would have liked both projects to collaborate to offer a good coherent solution rather than overlapping functionalities from both, with all the consequent risks.

Just out of my curiosity, why isn't the project-related XML namespace resolution part of Spring Boot language server? Probably because, if it were, you would not be able to override the default WTP XML editor behaviour wrt namespace resolution?

@martinlippert
Copy link
Member

The namespace resolution is done when the tooling parses the XML source. So wherever that happens, we need to inject our extension for this mechanism.

WTP does this inside of its own XML parsing and validation mechanism, so we had to extent that mechanism using the WTP API.

Wild Web Developer does this parsing and validation inside of the Wild Web Developer XML language server, so for that case we need to implement an extension for that specific XML language server, using its specific API.

@mauromol
Copy link
Author

Hi @martinlippert, I saw the new entry in the "Known limitations and issues" that points here, as discussed in #354 (comment).
My question is then: should this be reopened or a new issue be created in order to track the resolution of this issue, in light of the new STS4 setup? Thank you.

@martinlippert
Copy link
Member

@mauromol We have an internal issue that is tracking the progress towards the project-related XSD namespace resolution, but I think it would be better to have a public GitHub issue for that. I will create one and move the relevant parts over to that one, which is still in progress. We are slowly getting there, but identified a few issues that prevented our implementation to make it into the 4.9.0 release.

@mauromol
Copy link
Author

Thanks a lot @martinlippert! I will watch that new issue when it is available.

@martinlippert
Copy link
Member

@mauromol Here you are... :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants