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

NullPointerException on RemoteProject #1283

Closed
jacek187 opened this issue Jul 22, 2021 · 8 comments
Closed

NullPointerException on RemoteProject #1283

jacek187 opened this issue Jul 22, 2021 · 8 comments
Assignees
Labels
Milestone

Comments

@jacek187
Copy link

GroovyClassLoader is not bootstraped on Remote Project (created with Remote System Explorer plugin) with included libraries.
When project is opened (or Groovy COmpiler poperty tab is opened) exception is thrown:

Steps to reproduce error:

  1. Environemnt:
    Eclipse 4.20
    Remote System Explorer (latest 3.5.0)
    GroovyEclipse (latest 4.2.0.RELEASE)
  2. Create new connection in Remote Systems View
  3. Create new folder on remote system.
  4. Create Remote Project on this folder
  5. Create new subfolder and place any jar file into subfolder
  6. Add Java Nature and Groovy Nature to project
  7. Add file from lib subdirectory as java library
  8. Restart Eclipse (or close/Open project)

There are 2 errors:

  1. When project is opened GroovyClassLoader for this project is not bootsraped and failed with error in .metadata/logs:
java.lang.RuntimeException: Failed to bootstrap GroovyClassLoaders for project 'dev_test-groovy'
	at org.codehaus.jdt.groovy.internal.compiler.GroovyClassLoaderFactory.getProjectGroovyClassLoaders(GroovyClassLoaderFactory.java:203)
	at org.codehaus.jdt.groovy.internal.compiler.GroovyClassLoaderFactory.getGroovyClassLoaders(GroovyClassLoaderFactory.java:122)
	at org.codehaus.jdt.groovy.integration.internal.GroovyLanguageSupport.newGroovyClassLoader(GroovyLanguageSupport.java:289)
	at org.codehaus.groovy.eclipse.dsl.script.DSLDScriptExecutor.getGroovyClassLoader(DSLDScriptExecutor.java:136)
	at org.codehaus.groovy.eclipse.dsl.script.DSLDScriptExecutor.executeScript(DSLDScriptExecutor.java:72)
	at org.codehaus.groovy.eclipse.dsl.RefreshDSLDJob.refreshProject(RefreshDSLDJob.java:189)
	at org.codehaus.groovy.eclipse.dsl.RefreshDSLDJob.run(RefreshDSLDJob.java:118)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
	at org.codehaus.jdt.groovy.internal.compiler.GroovyClassLoaderFactory.calculateClasspath(GroovyClassLoaderFactory.java:240)
	at org.codehaus.jdt.groovy.internal.compiler.GroovyClassLoaderFactory.lambda$2(GroovyClassLoaderFactory.java:159)
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
	at org.codehaus.jdt.groovy.internal.compiler.GroovyClassLoaderFactory.getProjectGroovyClassLoaders(GroovyClassLoaderFactory.java:157)
	... 7 more
Caused by: java.lang.NullPointerException
	at java.base/java.io.File.<init>(File.java:278)
	at org.codehaus.jdt.groovy.internal.compiler.GroovyClassLoaderFactory.getAbsoluteLocation(GroovyClassLoaderFactory.java:260)
	at org.codehaus.jdt.groovy.internal.compiler.GroovyClassLoaderFactory.calculateClasspath(GroovyClassLoaderFactory.java:234)
	... 10 more
  1. It's not possible to display Groovy Compiler project preference page.
java.lang.NullPointerException: Cannot invoke "org.eclipse.core.runtime.IPath.toFile()" because the return value of "org.eclipse.core.resources.IProject.getLocation()" is null
	at org.codehaus.groovy.eclipse.preferences.CompilerPreferencesPage.createProjectCompilerSection(CompilerPreferencesPage.java:212)
	at org.codehaus.groovy.eclipse.preferences.CompilerPreferencesPage.createDescriptionLabel(CompilerPreferencesPage.java:99)
	at org.eclipse.jface.preference.PreferencePage.createControl(PreferencePage.java:238)
	at org.eclipse.jface.preference.PreferenceDialog.createPageControl(PreferenceDialog.java:1433)
	at org.eclipse.jface.preference.PreferenceDialog$8.run(PreferenceDialog.java:1196)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:174)
	at org.eclipse.jface.preference.PreferenceDialog.showPage(PreferenceDialog.java:1188)
	at org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.showPage(FilteredPreferenceDialog.java:630)
	

@eric-milles eric-milles added this to the v4.3.0 milestone Jul 22, 2021
@eric-milles eric-milles self-assigned this Jul 22, 2021
@eric-milles
Copy link
Member

Thanks for submitting this issue. Is there a simple way that I could test this out? I do not have a remote system to connect to. Can you provide a sample or is this something that I can recreate through the Local Files section of Remote Systems?

@jacek187
Copy link
Author

Yes,
You can recreate this error using Local Files section of Remote System.

Please extract attached project anywhere on local file system, than find this project in Local Files View and than right-click on directory and choose Create Remote Project on localRemoteNPEProject Directory.

Restart Eclipse and try Open project and open Test.groovy file and try open Groovy compiler preference page of project.
localRemoteNPEProject.zip

Attachment contains one of possibile sample solution to this problem - this solution creates temporary files on local bundle metadata directory and return local file URL as result of files scanning. Maybe this helps you to solve this problem ;)
groovy-eclipse-1283-proposition.zip

@eric-milles
Copy link
Member

Thanks for the details and the patch. I managed to get some of this going yesterday. I think there is a means through org.eclipse.core.filesystem.EFS (the Eclipse File System) to convert workspace paths to local files so that we do not need to implement it ourselves. This does not help the classpath entry for an output directory.

I'm not sure what your overall goal is here. The NPEs definitely get in the way of just viewing files and the prefs page. But in terms of building a project that is hosted remotely, I don't think JDT is quite capable of that. I tried with a very basic project and it couldn't even delete the compiled class files.

@jacek187
Copy link
Author

THanks
It looks, that JDT is capable to build project hosted remotly (i.e. import attached example java only project (localJavaProject.zip))

localJavaProject.zip
If we add Groovy nature - error is thrown and build is blocked.

Remote Groovy project is very usefull in some specific scenarios - groovy scripts hosted remotly on server (DEV or TEST) on file system. Server is continously checking for changes and reload scripts if change is detected (live reload).
We can edit scripts remotly using text editor, but we can attach Eclipse remotly to server and import Groovy code into editor with full syntax highlinting, code assist, validations etc.

Very nice and important feature is Custom AST Transformation annotation - we can add features ito system that can be enabled only with one anotation.
But this needs working Groovy Code Editor, because AST Transformations are loaded from GroovyClassLoaders. But if GroovyClassLoaders failed to initialize, Code Editor doesn't help in this scenario...

@eric-milles
Copy link
Member

I think we can get to a working editor. I will stop short of a working builder because that will require a lot of effort that is not widely beneficial.

@jacek187
Copy link
Author

Proposed solution (working Code Editor and disabled builder for remote project) is absolutely good enough. I'm waiting for release with fix ;)

@eric-milles
Copy link
Member

ready to test

@jacek187
Copy link
Author

It works perfectly ;) Thanks.

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

No branches or pull requests

2 participants