question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"java.lang.IllegalStateException: Workspace is closed" with eclipse('4.7.2')

See original GitHub issue

spotless 3.8.0

21:21:13.863 [ERROR] [com.diffplug.spotless.Formatter] Step 'eclipse formatter' found problem in 'src/main/java/com/[...]/config/schema/[FieldSchema.java](https://github.com/diffplug/spotless/files/1650522/FieldSchema.txt)
':
null

java.lang.reflect.InvocationTargetException
        at com.diffplug.spotless.extra.java.EclipseFormatterStep$State.lambda$createFormat$0(EclipseFormatterStep.java:100)
        at com.diffplug.spotless.FormatterStepImpl$Standard.format(FormatterStepImpl.java:78)
        at com.diffplug.spotless.FormatterStep$Strict.format(FormatterStep.java:76)
        at com.diffplug.spotless.Formatter.compute(Formatter.java:230)
        at com.diffplug.spotless.Formatter.isClean(Formatter.java:167)
        at com.diffplug.gradle.spotless.SpotlessTask.check(SpotlessTask.java:263)
        at com.diffplug.gradle.spotless.SpotlessTask.performAction(SpotlessTask.java:205)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
        at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
        at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.IllegalStateException: Workspace is closed.
        at org.eclipse.core.resources.ResourcesPlugin.getWorkspace(ResourcesPlugin.java:412)
        at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.createParser(DefaultCodeFormatter.java:332)
        at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.parseSourceCode(DefaultCodeFormatter.java:317)
        at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.prepareFormattedCode(DefaultCodeFormatter.java:213)
        at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.prepareFormattedCode(DefaultCodeFormatter.java:206)
        at org.eclipse.jdt.internal.formatter.CommentsPreparator.formatCode(CommentsPreparator.java:1063)
        at org.eclipse.jdt.internal.formatter.CommentsPreparator.handleFormatCodeTag(CommentsPreparator.java:801)
        at org.eclipse.jdt.internal.formatter.CommentsPreparator.handleHtml(CommentsPreparator.java:665)
        at org.eclipse.jdt.internal.formatter.CommentsPreparator.endVisit(CommentsPreparator.java:621)
        at org.eclipse.jdt.core.dom.TagElement.accept0(TagElement.java:282)
        at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2796)
        at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2867)
        at org.eclipse.jdt.core.dom.Javadoc.accept0(Javadoc.java:205)
        at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2796)
        at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.prepareComments(DefaultCodeFormatter.java:399)
        at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.prepareFormattedCode(DefaultCodeFormatter.java:222)
        at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:177)
        at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:160)
        at com.diffplug.gradle.spotless.java.eclipse.EclipseFormatterStepImpl.format(EclipseFormatterStepImpl.java:38)
        ... 47 more

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:29 (14 by maintainers)

github_iconTop GitHub Comments

5reactions
fvghcommented, Apr 5, 2018
Problem
The problem is in the JDT code formatter. Due to pre it tries to created a new parser for the Java code within pre tags. The formatter requires a compilation unit (so in the end files). Since JDT now supports Java 9, it also requires a module-info.java. So what JDT now does is an assembly of fake paths. To make up these fakes, it uses the Eclipse work-space. But spotless has/requires no work-space, so the module is not initialized.
Work-Around
The only work-around I see is to set the following properties to FALSE:
  • org.eclipse.jdt.core.formatter.comment.format_html
  • org.eclipse.jdt.core.formatter.comment.format_source_code

Note that both must be set to false.

Solution
Will provide a fix ASAP, but it will take a while before it'll be available on Maven Central.
3reactions
d1ss0nanzcommented, Mar 11, 2018

Setting this to false isn’t a workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.IllegalStateException: Workspace is closed. - Eclipse
Hi, I am developing a plugin and trying to get descriptors for all projects within the workspace but I face with the following...
Read more >
112038 – java.lang.IllegalStateException: Workspace ... - Bugs
It appears someone is calling PackageAdmin#refreshpackages as the ui bundle is being started. AFAIK this should not happen because only org.eclipse.update.
Read more >
Newcomers » Workspace is closed exception - Eclipse
I have written following code to open a project. public static void test() throws CoreException { // IWorkspace workspace = ResourcesPlugin.
Read more >
Eclipse Platform » Workspace is closed error
java.lang.IllegalStateException: Workspace is closed. at org.eclipse.core.resources.ResourcesPlugin.getWorkspace(Reso urcesPlugin.java:320)
Read more >
Eclipse Platform » "Workspace is closed" [URGENT]
error, java.lang.IllegalStateException: Workspace is closed. at org.eclipse.core.resources.ResourcesPlugin.getWorkspace ResourcesPlugin.java: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found