redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.08k stars 438 forks source link

Very slow update/refresh with Gradle multi project including non Java project with large number of files #1362

Closed jsaulou closed 3 years ago

jsaulou commented 4 years ago

Hi,

I'm using a multi project build with a Spring Boot backend and an Angular frontend. The Gradle build is used to create a jar for the frontend that serves as a dependency for the Spring Boot project. Each project has its own build.gradle file. No issues there.

The problem is that the Java Language Server spends a large of amount of time (~15 minutes) updating and refreshing the root project. It seems that this is due to the large amount of files in the frontend project (node_modules) because removing this directory considerably improves the refresh time. Also, completely removing the frontend project makes everything work quickly as expected.

The refresh is slow even when the frontend project is not referenced at all in the Gradle build (not declared as a subproject and not referenced as a dependency).

Using the Gradle CLI, everything works normally. Configuration is fast.

I tried to remove the build.gradle files from the frontend project and configure it from the root project's build.gradle but same result.

Is the Language Server indexing or browsing all the files from the frontend project even though it is not a Java project? Is there any way to make it ignore files or directories or non Java projects?

Thanks for your pointers.

Environment
a-st commented 4 years ago

We recently added a frontend component to one of our submodules and I can confirm this behaviour.

snjeza commented 4 years ago

@jsaulou @a-st could you try to set the following property:

"java.import.exclusions": [
        "**/node_modules/**",
        "**/.metadata/**",
        "**/archetype-resources/**",
        "**/META-INF/maven/**",
    ],
fbricon commented 4 years ago

@snjeza I think the problem is invoking IResource.refresh on projects containing large subdirectories. I'm not aware of ways to exclude directories from resource.refresh in Eclipse API

a-st commented 4 years ago

@snjeza Thanks a lot, I've added the settings to my settings.json and restarted vscode. Actually it takes quite long to finish this step

image

jsaulou commented 4 years ago

Thanks @snjeza for the tip but I had already tried that. I think I tried all combinations of exclusions like java.import.exclusions, files.watcherExclude, files.exclude. This is definitely better but still quite slow compared to a "standard" project (I think files.watcherExclude, files.exclude make the biggest difference). I'm pretty sure all files are refreshed in a way.

Also, I make use of Gradle's includeBuild in other projects referencing this project with large folders, and I have no idea how this would be treated by the extension. The settings defined in the large project cannot be applied then I guess.


Finally, I noticed that when using includeBuild, the extension will sometimes refresh a project that it shouldn't. For instance, let's say I have projects A and B.

A uses B with includeBuild. B has no dependency on A.

Well, sometimes, when opening or synchronizing B Gradle configuration, the extension will refresh project A. Not every time. I wonder if it's only when A is also opened and there is some kind of Gradle daemon mixup or something. I'm just speculating. Anyway, this might be another discussion.

snjeza commented 4 years ago

@a-st @jsaulou You can try to add the following code:

eclipse {
    project { 
        resourceFilter {
        matcher {
            id = 'org.eclipse.core.resources.regexFilterMatcher'
            arguments = "node_modules|.git"
        }
    }
  }
}

to your build.gradle file.

buildship doesn't support Eclipse resource filters. See https://github.com/eclipse/buildship/issues/271 You can add them to your .project file using the following command:

./gradlew eclipse
jsaulou commented 4 years ago

Thank you so much @snjeza!

I've tried it and it makes a world of difference. It now only takes ~30s to update/sync the Gradle configuration.

a-st commented 4 years ago

I manually added the regexFilterMatcher to .project, which also solved the perfomance issues. Thank you very much @snjeza and @fbricon!

<projectDescription>
  <filteredResources>
    <filter>
      <matcher>
        <id>org.eclipse.core.resources.regexFilterMatcher</id>
        <arguments>node_modules</arguments>
      </matcher>
    </filter>
  </filteredResources>
</projectDescription>
Slay3r commented 4 years ago

@snjeza I have a similar issue. I have a root project. One sub-project which is using 'java' and 'application' in the build.gradle file (Spring Boot Server). 11 sub-projects which are 'java-library's. Every sub-project have its own build.gradle file.

The Spring Boot Server is referencing to the 11 sub-project(libraries).

Every time I open vscode the extension starts to synchronize with gradle like in a earlier post. This takes up to 5 minutes which is really annoying.

"node_modules" are not included in my project.

Any Idea how to fix? Thanks in advance.

.project file which got generated:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>projetcxxxxxx.emf</name>
    <comment>Project projetcxxxxxx.emf created by Buildship.</comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
        <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
    </natures>
</projectDescription>

.classpath file which got generated:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" output="bin/main" path="src/main/java">
        <attributes>
            <attribute name="gradle_scope" value="main"/>
            <attribute name="gradle_used_by_scope" value="main,test"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
    <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
    <classpathentry kind="output" path="bin/default"/>
</classpath>
jsaulou commented 4 years ago

Hi @Slay3r,

If this can help, for me, the issue was not specifically a node_modules folder but rather a large number of files in some projects. If you have projects with large number of files, try what @snjeza said in the his previous comment.

Slay3r commented 4 years ago

Hi @jsaulou, thanks for answering.

After adding the eclipse plugin and the command provided by @snjeza I could improve the Language Server startup time.

I am building emf plugins and in the emf edit package were folders with a lot of icons. I excluded those folders.

Its now from 3 minutes down to 1 minute. I think its still too long because my project is not that big but it's a step in the right direction. Thanks.

andywarren86 commented 4 years ago

I also recently noticed a large increase in the time required to synchronise the project. I too have a project with a nested node_modules folder. While ignoring node_modules as per above comments helped, it was still taking a while. I reverted the plugin back to v61 and sync speed dropped back to only a few seconds.

Has anything changed in v62 that could have caused this?

Slay3r commented 4 years ago

Like @andywarren86 I switched back to version 0.61.0. The startup time is a lot better.

snjeza commented 4 years ago

@Slay3r @andywarren86 could you check https://github.com/snjeza/vscode-test/raw/master/java-0.62.2.vsix

snjeza commented 4 years ago

@Slay3r @andywarren86 @a-st Please see https://github.com/redhat-developer/vscode-java/issues/1463#issuecomment-638957729

devyhia commented 4 years ago

I have the same issue with v62; Reverting back to v61 sped up things a lot.

snjeza commented 4 years ago

@devyhia could you check https://github.com/snjeza/vscode-test/raw/master/java-0.62.4.vsix

snjeza commented 4 years ago

Fixed with https://github.com/eclipse/eclipse.jdt.ls/commit/200d352d1215dd2fe925e4a81c3b64d55d9ac617

freelancer1845 commented 4 years ago

I have a very similar problem (also taking time away to refresh resource folders (node_modules)). The difference is that I'm using maven.

I tried to add the filter to .project.

<filteredResources>
    <filter>
        <matcher>
            <id>org.eclipse.core.resources.regexFilterMatcher</id>
            <arguments>node_modules</arguments>
        </matcher>
    </filter>
</filteredResources>

My setup is the following:

root
|+++ backend (spring-boot java project)
|---|--- pom.xml
|---|--- ...
|
|+++ frontend (angular project)
|---|--- pom.xml (for build automation)
|---|--- ...
|
|+++ pom.xml (includes backend and frontend as modules)
|--- project_name.code-workspace
|--- .project
|--- ...

I organize everything using a vscode workspace.

When I add the filter the Language Server crashes. This is not the full log file but the part where the NPE is thrown.

My Extensionversion is 0.63.0

Log / Stacktrace ```` !ENTRY org.eclipse.jdt.ls.core 4 0 2020-06-26 14:18:00.144 !MESSAGE FrameworkEvent ERROR !STACK 0 org.osgi.framework.BundleException: Exception in org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin.start() of bundle org.eclipse.jdt.ls.core. at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:864) at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:792) at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1015) at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:365) at org.eclipse.osgi.container.Module.doStart(Module.java:605) at org.eclipse.osgi.container.Module.start(Module.java:468) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1845) at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1838) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1743) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1665) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) Caused by: java.lang.NoClassDefFoundError: org/eclipse/jdt/core/JavaCore at org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager.initialize(PreferenceManager.java:79) at org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager.(PreferenceManager.java:70) at org.eclipse.jdt.ls.core.internal.preferences.StandardPreferenceManager.(StandardPreferenceManager.java:44) at org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin.start(JavaLanguageServerPlugin.java:173) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:843) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1) at java.base/java.security.AccessController.doPrivileged(AccessController.java:554) at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:835) ... 14 more Caused by: java.lang.ClassNotFoundException: An error occurred while automatically activating bundle org.eclipse.jdt.core (41). at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:126) at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:571) at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:346) at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:398) at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:41) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:473) at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:171) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ... 22 more Caused by: org.osgi.framework.BundleException: Error starting module. osgi.identity; type="osgi.bundle"; version:Version="3.22.0.v20200530-2032"; osgi.identity="org.eclipse.jdt.core"; singleton:="true" [id=41] at org.eclipse.osgi.container.Module.doStart(Module.java:614) at org.eclipse.osgi.container.Module.start(Module.java:468) at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:493) at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117) ... 29 more Caused by: java.lang.NoClassDefFoundError: org/eclipse/core/resources/IResource at org.eclipse.jdt.core.JavaCore.(JavaCore.java:222) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) at org.eclipse.osgi.internal.framework.BundleContextImpl.loadBundleActivator(BundleContextImpl.java:826) at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:778) at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1015) at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:365) at org.eclipse.osgi.container.Module.doStart(Module.java:605) ... 32 more Caused by: java.lang.ClassNotFoundException: An error occurred while automatically activating bundle org.eclipse.core.resources (21). at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:126) at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:571) at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:346) at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:398) at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:41) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:473) at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:171) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ... 43 more Caused by: org.osgi.framework.BundleException: Exception in org.eclipse.core.resources.ResourcesPlugin.start() of bundle org.eclipse.core.resources. at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:864) at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:792) at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1015) at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:365) at org.eclipse.osgi.container.Module.doStart(Module.java:605) at org.eclipse.osgi.container.Module.start(Module.java:468) at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:493) at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117) ... 50 more Caused by: java.lang.NullPointerException at org.eclipse.core.internal.resources.ProjectDescriptionReader.endFilterElement(ProjectDescriptionReader.java:537) at org.eclipse.core.internal.resources.ProjectDescriptionReader.endElement(ProjectDescriptionReader.java:340) at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:618) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1727) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2898) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:541) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224) at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635) at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:324) at org.eclipse.core.internal.resources.ProjectDescriptionReader.read(ProjectDescriptionReader.java:930) at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:897) at org.eclipse.core.internal.resources.SaveManager.restoreMetaInfo(SaveManager.java:888) at org.eclipse.core.internal.resources.SaveManager.restoreMetaInfo(SaveManager.java:868) at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:724) at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1555) at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2452) at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2210) at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:489) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:843) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1) at java.base/java.security.AccessController.doPrivileged(AccessController.java:554) at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:835) ... 57 more Root exception: java.lang.NoClassDefFoundError: org/eclipse/jdt/core/JavaCore at org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager.initialize(PreferenceManager.java:79) at org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager.(PreferenceManager.java:70) at org.eclipse.jdt.ls.core.internal.preferences.StandardPreferenceManager.(StandardPreferenceManager.java:44) at org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin.start(JavaLanguageServerPlugin.java:173) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:843) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1) at java.base/java.security.AccessController.doPrivileged(AccessController.java:554) at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:835) at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:792) at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1015) at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:365) at org.eclipse.osgi.container.Module.doStart(Module.java:605) at org.eclipse.osgi.container.Module.start(Module.java:468) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1845) at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1838) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1743) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1665) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) Caused by: java.lang.ClassNotFoundException: An error occurred while automatically activating bundle org.eclipse.jdt.core (41). at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:126) at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:571) at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:346) at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:398) at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:41) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:473) at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:171) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ... 22 more Caused by: org.osgi.framework.BundleException: Error starting module. osgi.identity; type="osgi.bundle"; version:Version="3.22.0.v20200530-2032"; osgi.identity="org.eclipse.jdt.core"; singleton:="true" [id=41] at org.eclipse.osgi.container.Module.doStart(Module.java:614) at org.eclipse.osgi.container.Module.start(Module.java:468) at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:493) at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117) ... 29 more Caused by: java.lang.NoClassDefFoundError: org/eclipse/core/resources/IResource at org.eclipse.jdt.core.JavaCore.(JavaCore.java:222) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) at org.eclipse.osgi.internal.framework.BundleContextImpl.loadBundleActivator(BundleContextImpl.java:826) at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:778) at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1015) at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:365) at org.eclipse.osgi.container.Module.doStart(Module.java:605) ... 32 more Caused by: java.lang.ClassNotFoundException: An error occurred while automatically activating bundle org.eclipse.core.resources (21). at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:126) at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:571) at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:346) at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:398) at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:41) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:473) at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:171) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ... 43 more Caused by: org.osgi.framework.BundleException: Exception in org.eclipse.core.resources.ResourcesPlugin.start() of bundle org.eclipse.core.resources. at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:864) at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:792) at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1015) at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:365) at org.eclipse.osgi.container.Module.doStart(Module.java:605) at org.eclipse.osgi.container.Module.start(Module.java:468) at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:493) at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117) ... 50 more Caused by: java.lang.NullPointerException at org.eclipse.core.internal.resources.ProjectDescriptionReader.endFilterElement(ProjectDescriptionReader.java:537) at org.eclipse.core.internal.resources.ProjectDescriptionReader.endElement(ProjectDescriptionReader.java:340) at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:618) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1727) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2898) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:541) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224) at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635) at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:324) at org.eclipse.core.internal.resources.ProjectDescriptionReader.read(ProjectDescriptionReader.java:930) at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:897) at org.eclipse.core.internal.resources.SaveManager.restoreMetaInfo(SaveManager.java:888) at org.eclipse.core.internal.resources.SaveManager.restoreMetaInfo(SaveManager.java:868) at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:724) at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1555) at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2452) at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2210) at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:489) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:843) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1) at java.base/java.security.AccessController.doPrivileged(AccessController.java:554) at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:835) ... 57 more ````
snjeza commented 4 years ago

@freelancer1845 could you attach your .project file with filteredResources?

freelancer1845 commented 4 years ago
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>complete</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.m2e.core.maven2Builder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.m2e.core.maven2Nature</nature>
    </natures>
    <filteredResources>
        <filter>
            <matcher>
                <id>org.eclipse.core.resources.regexFilterMatcher</id>
                <arguments>node_modules</arguments>
            </matcher>
        </filter>
    </filteredResources>
</projectDescription>

From the NPE I guess the filter needs to go into a \<project> tag somehow.

snjeza commented 4 years ago

@freelancer1845 could you try the following:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>complete</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.m2e.core.maven2Builder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.m2e.core.maven2Nature</nature>
    </natures>
    <filteredResources>
        <filter>
                       <id>1</id>
            <name></name>
            <type>30</type>
            <matcher>
                <id>org.eclipse.core.resources.regexFilterMatcher</id>
                <arguments>node_modules</arguments>
            </matcher>
        </filter>
    </filteredResources>
</projectDescription>
freelancer1845 commented 4 years ago

@snjeza

I tried your suggestion and the project loads but the filter is not applied. The log contains these entries

[...]

!ENTRY org.eclipse.jdt.ls.core 1 0 2020-07-02 19:29:30.861
!MESSAGE >> initialized

!ENTRY org.eclipse.jdt.ls.core 1 0 2020-07-02 19:29:30.942
!MESSAGE Creating the Java project jdt.ls-java-project

!ENTRY org.eclipse.jdt.ls.core 1 0 2020-07-02 19:29:31.092
!MESSAGE Finished creating the Java project jdt.ls-java-project

!ENTRY org.eclipse.jdt.ls.core 1 0 2020-07-02 19:29:32.757
!MESSAGE Importing Maven project(s)

!ENTRY org.eclipse.core.resources 2 567 2020-07-02 19:29:32.799
!MESSAGE Failure occurred reading .project file.
!SUBENTRY 1 org.eclipse.core.resources 2 567 2020-07-02 19:29:32.799
!MESSAGE Illegal filter type "-1" detected for filtered resource with name '' and id '<missing argument>'.

!ENTRY org.eclipse.jdt.ls.core 1 0 2020-07-02 19:31:25.626
!MESSAGE Importing Maven project(s)

!ENTRY org.eclipse.jdt.ls.core 1 0 2020-07-02 19:31:25.645
!MESSAGE Importing Maven project(s)

!ENTRY org.eclipse.jdt.ls.core 1 0 2020-07-02 19:31:25.670
!MESSAGE Workspace initialized in 114838ms

[...]

So I guess the filter loading fails

snjeza commented 4 years ago

@freelancer1845 could you attach a project example?

snjeza commented 4 years ago

@freelancer1845 you may want to take a look at https://github.com/redhat-developer/vscode-java/issues/1460#issuecomment-655649041

freelancer1845 commented 4 years ago

Works for me :)

Still interested in a project example? Couldn't find the time yet

Thanks a lot!

Maybe this should be configurable like the "import-filters"

snjeza commented 4 years ago

Still interested in a project example? Couldn't find the time yet

@freelancer1845 It is not important anymore.

Ornel21 commented 6 days ago

Hi,

I'm using a multi project build with a Spring Boot backend and an Angular frontend. The Gradle build is used to create a jar for the frontend that serves as a dependency for the Spring Boot project. Each project has its own build.gradle file. No issues there.

The problem is that the Java Language Server spends a large of amount of time (~15 minutes) updating and refreshing the root project. It seems that this is due to the large amount of files in the frontend project (node_modules) because removing this directory considerably improves the refresh time. Also, completely removing the frontend project makes everything work quickly as expected.

The refresh is slow even when the frontend project is not referenced at all in the Gradle build (not declared as a subproject and not referenced as a dependency).

Using the Gradle CLI, everything works normally. Configuration is fast.

I tried to remove the build.gradle files from the frontend project and configure it from the root project's build.gradle but same result.

Is the Language Server indexing or browsing all the files from the frontend project even though it is not a Java project? Is there any way to make it ignore files or directories or non Java projects?

Thanks for your pointers.

Environment
  • Operating System: Windows 10 Pro
  • JDK version: openjdk11
  • Visual Studio Code version: 1.43.2
  • Java extension version: 0.59.0