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

Spring XML config content assist not working #542

Closed
mauromol opened this issue Sep 25, 2020 · 12 comments
Closed

Spring XML config content assist not working #542

mauromol opened this issue Sep 25, 2020 · 12 comments

Comments

@mauromol
Copy link

mauromol commented Sep 25, 2020

I'm here to struggle again to make XML support in STS4 working...
Now I'm working on another project and I can't get XML support to work.
I'm using Eclipse 2020-09 (4.17.0) with STS 4.8.0 (Spring XML Namespace Support 3.9.14.202009150957-RELEASE).
Under Window | Preferences | Language Servers I disabled WWD XML Language Server (due to #415), while Spring XML Config File language server is enabled.
Under Window | Preferences | Language Servers | Spring Language Servers, Spring Boot option is checked.
Under Window | Preferences | Language Servers | Spring Language Servers | Spring XML Config, Content Assist in editor is checked.

Yet, when I try to invoke content assist like in <bean class="Str|">, I don't get any suggestion at all.
When I invoke content assist there, no output is produced at all either in the Spring Boot Language Server Console or in the Eclipse log.
If I look at the contents of the Spring Boot Language Server log from the beginning, no mention to my XML files is present, suggesting they weren't detected at all. However, the cool thing is that if I uncheck the Spring XML Config File language server in Window | Preferences | Language Servers, this gets printed in the Spring Boot Language Server log:

16:34:30.482 [Simple-Language-Server main thread] INFO  o.s.i.v.c.l.u.SimpleTextDocumentService - Closed: file:///home/mauro/svn/DCS-POST-trunk/post-core/src/main/resources/config/integration/applicationContext-integration-newsletter-submit-hub-ftp.xml
16:34:30.482 [Simple-Language-Server main thread] INFO  o.s.i.v.c.l.u.SimpleTextDocumentService - Closed: file:///home/mauro/svn/DCS-POST-trunk/post-core/src/main/resources/config/integration/applicationContext-integration-common.xml

So, they were detected in some way instead.
Now, if I enable again Spring XML Config File language server in Window | Preferences | Language Servers, no new output is produced and content assist doesn't work yet.

Please tell me what I can do to help you diagnose what is going on.

@mauromol
Copy link
Author

Here is the Spring Boot Language Server log from Eclipse start up to when I invoke code assist.
sbls.txt

Here is the Eclipse log in the same fragment:
eclipse.txt

Please note there's 2 hours offset between these logs because of a timezone problem with the version of Eclipse I'm using (Flatpak - flathub/org.eclipse.Java#17).

@BoykoAlex
Copy link
Contributor

What is the layout of your projects? As far as i can see you have 3 projects:

  • post-core
  • post-client
  • post-commons

Where are the XML files? Are they all in post-commons?
Did you modify the Scan XML in Folders for Symbols? (Spring XML Config preference page) I assume you have everything check-marked on that page.

It is odd indeed that CA invocation is not recorded in the server log... It would usually be logged like this:
15:54:39.755 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling

Also it is odd that non of the XML files were scanned for spring symbols... which makes me wonder where they are in your projects... Usually java files are indexed for symbols and XML files as well since you've enabled XML support... Thus you should be having something like this in the log:

15:37:39.130 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan java files for symbols for project: test-xml-hyperlinks - no. of files: 4
15:37:39.151 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan java files used cached data: test-xml-hyperlinks - no. of cached symbols retrieved: 2
15:37:39.151 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan java files restored cached dependency data: 0 - no. of cached dependencies: {}
15:37:39.152 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan java files for symbols for project: test-xml-hyperlinks took ms: 22
15:37:39.155 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - Found 4 XML files to scan in 3ms
15:37:39.155 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan xml files for symbols for project: test-xml-hyperlinks - no. of files: 4
15:37:39.161 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan xml files used cached data: test-xml-hyperlinks - no. of cached symbols retrieved: 3
15:37:39.161 [pool-2-thread-1] INFO  o.s.i.v.b.j.utils.SpringIndexerJava - scan xml files for symbols for project: test-xml-hyperlinks took ms: 9

I see you have java files indexed but no XML files indexed it seems... Therefore, I'm curious about your projects layout

@BoykoAlex
Copy link
Contributor

Also what is the header for your Spring XML files?

I have:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">

What is yours?

@mauromol
Copy link
Author

Hi Alex, sorry for the delay.
The layout of the projects is:

  • DCS-POST (folder called "master" on disk) - this is a general project, not a Java project
  • post-commons (library)
  • post-client (library, depends on post-commons)
  • post-core (Spring Boot app, depends on post-commons)

XML files are in post-core, under src/main/resources/config.integration. "Scan XML in Folders for Symbols" is set to "src/main" and it seems like it's not editable. Both "Content assist in editor" and "Hyperlinks in editor" are checked.

The header for one of those XML files is:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:int="http://www.springframework.org/schema/integration"
	xmlns:int-jpa="http://www.springframework.org/schema/integration/jpa"
	xmlns:int-sftp="http://www.springframework.org/schema/integration/sftp"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
			http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
			http://www.springframework.org/schema/integration/jpa https://www.springframework.org/schema/integration/jpa/spring-integration-jpa.xsd
			http://www.springframework.org/schema/integration/sftp https://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd">

@BoykoAlex
Copy link
Contributor

It just looks like Spring XML support is completely off. At the same time your Boot LS log states that indexer configuration has been updated a few times since I'm seeing lines (in other words I'd expect the log to have something about scanning XML files):

16:47:33.356 [pool-4-thread-1] INFO  o.s.i.v.boot.app.SpringSymbolIndex - update settings of spring indexer - start
16:47:33.361 [pool-4-thread-1] INFO  o.s.i.v.boot.app.SpringSymbolIndex - update settings of spring indexer - done

Try perhaps changing the Scan XML in Folders for Symbols - it should be an editable text field... change it to src/main/resources maybe and record what the log states once you apply the preferences change. When the setting is changed Boot LS would re-populate XML symbols index (if Spring XML Indexer is around of course)

Also, it'd be interesting if you could simplify one of the XML (or create a new XML file) files to one bean only only... Perhaps there is something in the XML file Boot LS silently didn't like.

There is a sample test project we have in STS4 repo: /Users/aboyko/git/sts4/headless-services/spring-boot-language-server/src/test/resources/test-projects/test-xml-hyperlinks. I'm curious if it's going to work for you in your workspace... There is an XML file: /Users/aboyko/git/sts4/headless-services/spring-boot-language-server/src/test/resources/test-projects/test-xml-hyperlinks/src/main/webapp/WEB-INF/spring/root-context.xml` - wonder if you get CA and hyperlinks for it.

I've tried your XML header and moved my XML file to match the location of your XML files but it didn't trigger any issues...

@mauromol
Copy link
Author

mauromol commented Sep 30, 2020

Hi Alex, really, the whole page Language Server | Spring Language Servers | Spring Boot Language Server | Spring XML Config is read-only: I can neither change the "Scan XML in Folders for Symbols" text field, nor clear the two other flags. Probably here lies the common source of my problems. Do you have any clue on why I see this?
Please note that the other Spring options in other configuration pages are freely editable.

@martinlippert
Copy link
Member

Those settings are editable only after enabling the overall "Enable Spring XML config files support", which should appear above the other checkboxes that you mentioned on the same preference page.

@mauromol
Copy link
Author

mauromol commented Sep 30, 2020

Oh, well, I really feel ashamed... for some unknown reason my brain was not seeing the first row of that page "Enable Spring XML Config File Support".... Aided by the fact that I'm using a dark theme and a non-excellent monitor, I didn't see that was an unchecked checkbox rather than a configuration page title, so I now checked that option and some XML-related log entries started to appear in the log. I realised this as soon as I opened Eclipse on another workspace where code assist in XML files works. I'm really sorry for your time wasting...

On the interesting note, I had to restart Eclipse, even after enabling that option, to make code assist work, otherwise I was just having some "UI freeze" errors in the Eclipse log and "No Spring XML Content Assist", but I can't reproduce again this behaviour right now.

Thanks for your help, as always, and sorry again.

@martinlippert
Copy link
Member

@mauromol No worries, glad to hear that it is working now... :-)

@ayyappa9866
Copy link

I am using Spring Mvc 6.1.2 .. I am using xml Configuration in this project but it is not working..
package com.ayyappa;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@controller
public class AddController {
@RequestMapping("add")
public String add() {
return "welcome.jsp";
}
}

Archetype Created Web Application ayyappa org.springframework.web.servlet.DispatcherServlet ayyappa /


4.0.0
com.ayyappa
webmvc4
war
0.0.1-SNAPSHOT
webmvc4 Maven Webapp
http://maven.apache.org


junit
junit
3.8.1
test



org.springframework
spring-webmvc
6.1.2


javax.servlet
jstl
1.2

</dependencies>
<build>
	<finalName>webmvc4</finalName>
</build>

<ctx:annotation-config></ctx:annotation-config>
<ctx:component-scan base-package="com.ayyappa"></ctx:component-scan>

@BoykoAlex
Copy link
Contributor

If your app isn't working, i.e. not picking up your xml config (is this correct?) then you'd better of raising this as a question on SO: https://stackoverflow.com/questions/tagged/spring.
If you believe that the IDE is misbehaving you'd have to be more specific about where and why you think the issue is IDE... For example you could launch your app's JAR file or perform spring-boot-run via maven and if that works but launching from the IDE does not then it smells like the tools issue.

@martinlippert
Copy link
Member

And if some specific content-assist is not working (you mentioned this in the title of the issue), it would be good if you could share a sample project and describe on more detail where exactly the content-assist is not working and what you would expect from it.

Also, keep in mind that the support for Spring XML config files in Spring Tools 4 is not enabled by default. You have to enable the overall support as well as the content-assist in the preferences. But that preference refers to the tooling features (like content-assist) only, it is completely unrelated to running the Spring application and what happens at runtime.

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

4 participants