[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.newcomer] java.lang.IllegalStateException: Workspace is closed.
|
- From: Bill Winspur <bwinspur@xxxxxxxxxx>
- Date: Tue, 14 Mar 2006 13:29:19 -0700
- Newsgroups: eclipse.newcomer
- Organization: EclipseCorner
- User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)
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/msg50146.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.