Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » java.lang.IllegalStateException: Workspace is closed.
java.lang.IllegalStateException: Workspace is closed. [message #143068] Tue, 14 March 2006 20:29
Bill Winspur is currently offline Bill WinspurFriend
Messages: 180
Registered: July 2009
Senior Member
Background
---------- I have a java project in which I'm developing a package, that
ends up in .jar file used by several other projects. The package uses
JAXB, and for the Junit test cases, I have included in the project an
..xml document that gets marshalled and unmarshalled, plus the XMLSchema
to which the doc conforms.

Problem
------- In my test cases, I can not get at the document using the
ResourcePlugin, because the statment

IWorkspace ws = ResourcesPlugin.getWorskspace();

throws:
java.lang.IllegalStateException: Workspace is closed.

Google Result
------------- I found this from Alex Blewitt at
http://dev.eclipse.org/newslists/news.eclipse.platform/msg50 146.html

'You can't open the workspace unless you're running inside Eclipse. That
does not include running a Java application with a main method.

If your code is being called from a method like Plugin.start() and it's
being called from Eclipse, this will work. If the line above this code
reads 'public static void main(String args[]) then it won't work.'

Questions
--------
1. I'm executing my test classes from their source files in the
navigator view, using the right button menu 'Run As.. > Ju 2 unit test'
.. Since Junit is a plugin (org.Junit(3.8.1)), why is the workspace
showing closed ?

2. My ugly workaround is to use POJ File and FileStream to reach into
the project with an absolute filepath, but is there a way I can use
project-relative paths to my test files from Junit test cases ?.

Bill.
Previous Topic:Worksets, Filters, and/or Folders for Run Configurations?
Next Topic:debugging has become a pain in eclipse
Goto Forum:
  


Current Time: Thu Apr 25 07:16:00 GMT 2024

Powered by FUDForum. Page generated in 0.07586 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top